(1) **procedure** **RP**-**MS** () |

(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 by calling RP-MR (*G, L, v*), where ; |

(7) * * Insert into the candidate set *SET*; |

(8) * * Insert the children of into queue ; |

(9) * ***end while** |

(10) Find the global optimal trajectory with minimum from the candidate set *SET*; |

(11) return and ; |

(12) **end procedure** |