(1) procedure  RP-MS ( 𝐺 , 𝐿 / 2 )
(2)  Find median( 𝑚 ) of the tree-shaped topology;
(3)  Orient tree-shaped topology into directed one which is rooted at 𝑚 ;
(4)  push 𝑚 into queue 𝑞 ;
(5)  while 𝑞 𝑁 𝑈 𝐿 𝐿 do
(6)    Find the optimal trajectory 𝑝 o p t by calling RP-MR (G, L, v), where 𝑣 = 𝑞 p o p ( ) ;
(7)    Insert 𝑝 o p t into the candidate set SET;
(8)    Insert the children of 𝑣 into queue 𝑞 ;
(9)  end while
(10)  Find the global optimal trajectory with minimum 𝐶 ( o p t ) from the candidate set SET;
(11)  return 𝑝 o p t and 𝐶 ( o p t ) ;
(12) end procedure
Algorithm 2: RP-MS algorithm.