...

/

Implementation of Floyd-Warshall

Implementation of Floyd-Warshall

Learn about the details of implementing Floyd-Warshall.

Implementation notes

The implementation of Floyd-Warshall is relatively straightforward compared to Dijkstra’s algorithm. We’ll construct the matrices A0,P0A_0, P_0 from the weighted adjacency list and then iteratively compute the distance and predecessor matrices Ak,PkA_k, P_k, for k=1,,Vk = 1, \ldots, |V|.

One important observation to reduce the memory footprint of the algorithm is that the computation of Ak+1A_{k+1} ...