利用Dijkstra可以计算最短路径,那么次短路径和次次短路径呢,下面wiki说明了实现方法,与之前自己的想象一致。
来源:wiki:http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Related problems and algorithms[edit]
The functionality of Dijkstra’s original algorithm can be extended with a variety of modifications. For example, sometimes it is desirable to present solutions which are less than mathematically optimal. To obtain a ranked list of less-than-optimal solutions, the optimal solution is first calculated. A single edge appearing in the optimal solution is removed from the graph, and the optimum solution to this new graph is calculated. Each edge of the original solution is suppressed in turn and a new shortest-path calculated. The secondary solutions are then ranked and presented after the first optimal solution.
计算K Shortest Path最短路径还有专门的方法: