How is the path matrix created by the Floyd Warshall algorithm used for path lookup?

The 2 images show the graph (b) and the path matrix (c). Both are taken from the book: Foundations of Algorithms by Richard E. Neapolitan.

Path Matrix & The Related Graph Used To Get The Path Matrix

To lookup the best path from a node to another, how would I use this path matrix (c)?

The method I used:
From Node 5 to Node 3: 5 - 3

First go to the 3rd column in node 5's row, this says 4, path => 5 - ...4 - 3
Then go to the 4th column in node 5's row, this says 1, path => 5 - ...1 - 4 - 3
Finally, go to the 1st column in node 5's row, this says 0, so the final path is 5 - 1 - 4 - 3.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.