Floyd-Warshall Algorithm for the ASSP

Use Floyd-Warshall to compute shortest paths between all pairs of nodes.

In the next lessons, we’ll focus on the All Sources Shortest Path (ASSP) problem. Of course, we could solve the ASSP problem by just running Dijkstra’s algorithm once from each starting vertex. But the Floyd-Warshall algorithm, which was designed to specifically solve the ASSP problem, is a viable alternative. Its benefits are that it is very simple to implement and it runs faster than repeated Dijkstra executions on dense graphs.

The Floyd-Warshall algorithm

To explain how the Floyd-Warshall algorithm works, let’s look at a small example graph.

Get hands-on with 1200+ tech skills courses.