All-Pairs Shortest Paths

Go to:
> Material
> Lecture Recap


Material


Lecture Recap

The final topic of this course is the All-Pairs Shortest Paths (APSP) problem. We saw two algorithms that outperform the naive approach of running Bellman-Ford $n$ times ($O(n^2m)$), depending on whether the graph is dense or sparse.

Floyd-Warshall

This DP approach is best suited for dense graphs.

Johnson

The best choice for sparse graphs, effectively running Dijkstra $n$ times even with negative weights.

Matrix Multiplication

We also saw that finding shortest paths is equivalent to matrix multiplication over the $(\min, +)$ semiring. While we can’t use fast matrix multiplication (like Strassen’s) for distances due to the lack of additive inverses, we can use it to solve Transitive Closure (reachability) in roughly $O(n^{2.37})$.