Skip to main content
. 2018 Apr 16;18(4):1216. doi: 10.3390/s18041216
Algorithm 1 Node assignment algorithm
1: For each σij| j from 1 to ni//collect all the nodes whose aggregation queue is ready to aggregate.
2: If l(σij)Ntij or t(σij)Ttij then
3:   σijΣi
4: End if
5: End for
6: IfΣi=then//if Σi=, no node in Li send the aggregation queue.
7: Return
8: End if
9: For each σi1k|k from 1 to ni1//collect all the nodes whose Ωωi1k<1.
10: If Ωωi1k<1 then
11:   σi1kΣi1
12: End if
13: End for
14: For each σi1k| from σi1k with max ωi1k to σi1k with min ωi1k in Σi1//assign σij to σi1k with the priority of large ωi1k to small.
15: While l(σi1k)<Nt and Σi then //assign σi1k with sufficient aggregation queues to make the node aggregate.
16:   l(σi1k)=l(σi1k)+l(σij)λ
17:   σijΣi
18: End while
19: σi1kΣi1
20: End for
21: IfΣithen//the remaining queues of nodes in Σi are transmitted to τ(σij).
22: While Σi then
23:   l(τ(σi1j))=l(τ(σi1j))+l(σij)λ
24:   σijΣi
25: End while
26: End if