Research Article

Content-Based Efficient Messages Transmission in WSNs

Algorithm 3

Get_logic_son_nodes (Nk, content_type).
1 Nk.current_physical_node = 1; // 1th physical son-node is being handled currently
2 push Nk into the stack: s;
3 while (s is not empty)
4  get the uppermost element of s: Ncurrent;
5  i = Ncurrent.current_physical_son;
6  get the ith physical son node of Ncurrent: Ntmp;
7  if (Ntmp.type != content_type)
8   if (Ntmp has at least one son node)
9    Ntmp.current_physical_son = 1;
10    push Ntmp into s;
11   else
12    construct father-son relation: Ntmp is logical-son-node of Nk;
13    if (Ncurrent has another physical node)
14     Ncurrent.current_physical_node = i++;
15    else
16     pop Ncurrent from s;
17 return;