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

前端 未结 8 705
独厮守ぢ
独厮守ぢ 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:23

    Use the shortest path algorithm to find the shortest path, P.

    You then can view this problem as a constraint satisfaction problem (where the constraint is "the shortest path which is not P") and, use a backtracking algorithm to find the shortest path which is not the shortest path you already found.

提交回复
热议问题