Research Article

A Distributed Relation Detection Approach in the Internet of Things

Algorithm 3

Routing tree reuse algorithm.
   Function: reuseRoutingTree(Relation r, Set rSet)
(1)  sharedTree =
(2)  foreach    rSet  do
(3)  find the max subtree in i’s routing tree that matched
(4)  if    >  sharedTree  then
(5)    sharedTree = s
(6)  end
(7)  endfch
(8)  get the node that is the root of sharedTree
(9)  find the node in r that connects to sharedTree
(10)  calculate the energy consumption when transmitting the result of sharedTree from to
(11)  calculate the energy consumption when using an independent routing tree
(12)  if    then
(13)  reuse sharedTree for r
(14)  else
(15)  construct an independent routing tree for r
(16)  end