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 σi−1k|k from 1 to ni−1//collect all the nodes whose Ω≤ωi−1k<1.
10:  If Ω≤ωi−1k<1 then
11:   σi−1k∈Σi−1
12:  End if
13: End for
14: For each σi−1k′| from σi−1k′ with max ωi−1k′ to σi−1k′ with min ωi−1k′ in Σi−1//assign σij′ to σi−1k′ with the priority of large ωi−1k′ to small.
15:  While l(σi−1k′)<Nt and Σi≠∅ then //assign σi−1k′ with sufficient aggregation queues to make the node aggregate.
16:   l(σi−1k′)=l(σi−1k′)+l(σij′)∗λ
17:   σij′∉Σi
18:  End while
19:  σi−1k′∉Σi−1
20: End for
21: IfΣi≠∅then//the remaining queues of nodes in Σi are transmitted to τ(σij).
22:  While Σi≠∅ then
23:   l(τ(σi−1j″))=l(τ(σi−1j″))+l(σij″)∗λ
24:   σij″∉Σi
25:  End while
26: End if