1. for {i = 1, i <= k − 1, i + +} do 2. if {PVx<= (Pi + r/2)} then 3. if { PVx > (Pi − r/2)} then 4. {Vx become the candidate of a AHPi} 5. {Comparing the |PVx − Pj| and |PVNx − Pi|} 6. if {|PVx − Pi| is the smallest one} then 7. {Vx becomes the AHPi} 8. if {i ∈ IDAHP} then 9. {Vx relays the packets with its new transmission range } 10. else 11. {Vx doesn’t relay the packets } 12. end if 13. end if 14. end if 15. end if 16. end for |