Skip to main content
. 2019 May 26;19(10):2402. doi: 10.3390/s19102402
Algorithm 1 Tree Formation.
  • 1:

    Pu = ∅                           ▹ initially parent is empty

  • 2:

    Qu = ∅                      ▹ initially buffer for parent is empty

  • 3:

    for each Node i∈Nudo          ▹Nu is the set of all neighbor nodes of u in G

  • 4:

        if Pu is empty then

  • 5:

            if di,BS <du,BS then

  • 6:

               Pu=i                      ▹ Assign current node as parent

  • 7:

               add i in Qu

  • 8:

            end if

  • 9:

        else

  • 10:

            if (di,BS <du,BS && di,u <du,Pu) && hcounti,BS≤hcountPu,BS then

  • 11:

               Pu=i

  • 12:

               add i in Qu             ▹ Add current node into the parent queue

  • 13:

            end if

  • 14:

        end if

  • 15:

    end for

  • 16:

    Sort Qu according to distance and hop count

  • 17:

    for∀Qu each element in buffer do

  • 18:

        Pu = Dequeue(Qu)

  • 19:

        Ack ←GetAcknowledgement(Pu)

  • 20:

        if (Ack ≠ Overflow) then

  • 21:

            Exit from loop and Pu is the parent of u

  • 22:

        end if

  • 23:

    end for