[ DIST, PATH ] = graphkshortestpaths( G, S, T, K ) determines the K shortest paths from node S to node T. weights of the edges are all positive entries in the n-by-n adjacency matrix represented by the sparse matrix G. DIST are the K distances from S to T; PATH is a cell array with the K shortest paths themselves.
the shortest path algorithm used is Dijkstra's algorithm (graphshortestpath).
**Please note that the algorithm implemented here is an undirected version of Yen's algorithm**
- Yen, JY. Finding the k shortest loopless paths in a network; Management Science 17(11):712-6.
03/01/2013: I would like to thank Oskar Blom GĂ¶ransson for helping me find a bug in the previous version. |