Skip to main content
. 2018 Oct 30;18(11):3697. doi: 10.3390/s18113697
Algorithm 2. The spanning tree algorithm
  • 1. 

    Input: an OCRG;

  • 2. 

    Output: a spanning tree with the mobile sink as the root node;

  • 3. 

    Add vsink into set K;

  • 4. 

    Add the remaining nodes in the OCRG into set U;

  • 5. 

    for each node vi in set U do //  initialization

  • 6. 

    if (vi is directly connected to vsink)

  • 7. 

    PCpath(vsink,vi,) = Pvsinkvi;   //PCpath(vsink,vi,) is the PC of the path from vsink to vi

  • 8. 

    PATH(vsink,vi,) = {vsink,vi}; //PATH(vsink,vi,) is used to store the nodes on the path from vsink to vi

  • 9. 

    else

  • 10. 

    PCpath(vsink,vi,) = 0;

  • 11. 

    PATH(vsink,vi,) = ∅;

  • 12. 

    end if

  • 13. 

    end for

  • 14. 

    PCpath(vsink,vsink,) = 1;    // set the PC of the path from vsink to vsink is 1

  • 15. 

    while (set U is not empty)

  • 16. 

    Select the node vi with max PCpath(vsink,vi,) from set U;

  • 17. 

    Transfer vi from set U to set K;

  • 18. 

    for each neighbor vj of vi do    //vj is still in set U

  • 19. 

    temp ←PCpath(vsink,vi,)×Pvivj;

  • 20. 

    if (temp > PCpath(vsink,vj,))

  • 21. 

    PCpath(vsink,vj,)← temp;  // update the PC of the path from vsink to vj

  • 22. 

    PATH(vsink,vj,)PATH(vsink,vi,) + vj; // update the nodes on the path from vsink to vj

  • 23. 

    end if

  • 24. 

    end for

  • 25. 

    end while