Search⌘ K
AI Features

Shortest Paths and Matrices

Explore the relationship between shortest path algorithms and matrix multiplication through Fischer-Meyer inner loops. Understand how dynamic programming applies to graph problems and the limitations of faster matrix methods for shortest paths.

Inner loop of Fischer Meyer all-pairs shortest paths

There is a very close connection (first observed by Shimbel and later independently by Bellman) between computing shortest paths in a directed graph and computing powers of a square matrix. Compare the following algorithm for squaring an n×nn × n matrix AA with the inner loop of FischerMeyerAPSPFischerMeyerAPSP. (We’ve slightly modified the notation in the second algorithm to make the similarity clearer.)

Algorithm


MatrixSquare(A):‾for i←1 to nfor j←1 to nA′[i,j]←0for k←1 to nA′[i,j]←A′[i,j]+A[i,k ...