Which algorithm can I use to find the next to shortest path in a graph?

前端 未结 8 686
独厮守ぢ
独厮守ぢ 2020-12-05 10:50

I want to find the next shortest path between 2 vertices in a graph and the path has a positive cost.The next shortest path is allowed to share edges of the shortest path .W

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 11:24

    One way is to use Floyd-Warshall's algorithm to find all pairs shortest path and then testing all intermediate edges is a sure - but perhaps not optimal way - to solve this. Here's a great explanation http://hatemabdelghani.wordpress.com/2009/07/04/second-shortest-path/

提交回复
热议问题