I have a graph with undirected, weighted edges and have used the graphallshortestpaths function to solve the all-pairs shortest-path problem to determine the shortest distances between each pair of nodes. I would like to be able to find out the nodes that are being traversed for each path. Is this possible?
For example, given the following graph with 10 nodes and 33 edges:
nodeOrig nodeDest arcLength1 2 3.161 3 7.071 4 3.611 5 2.001 6 8.491 7 8.252 3 4.472 4 3.002 7 5.102 8 3.162 9 5.002 10 11.003 4 7.283 5 8.603 6 11.053 9 9.223 10 15.134 5 3.004 6 5.004 7 6.404 8 6.084 10 8.005 6 7.215 7 8.945 9 3.616 7 8.256 8 10.776 9 3.616 10 5.007 8 6.327 10 13.008 9 8.069 10 6.00
and the following graphallshortestpaths solution:
0.00 3.16 7.07 3.61 2.00 8.49 8.25 6.32 5.61 11.613.16 0.00 4.47 3.00 5.16 8.00 5.10 3.16 5.00 11.007.07 4.47 0.00 7.28 8.60 11.05 9.57 7.63 9.22 15.133.61 3.00 7.28 0.00 3.00 5.00 6.40 6.08 6.61 8.002.00 5.16 8.60 3.00 0.00 7.21 8.94 8.32 3.61 9.618.49 8.00 11.05 5.00 7.21 0.00 8.25 10.77 3.61 5.008.25 5.10 9.57 6.40 8.94 8.25 0.00 6.32 10.10 13.006.32 3.16 7.63 6.08 8.32 10.77 6.32 0.00 8.06 14.065.61 5.00 9.22 6.61 3.61 3.61 10.10 8.06 0.00 6.0011.61 11.00 15.13 8.00 9.61 5.00 13.00 14.06 6.00 0.00
is there a way to determine that the shortest path from node 1 to node 10 is 1-5-9-10 (for a total distance of 11.61)?
Thanks for your help!
Best Answer