AlgoPlus//structures / floyd-warshall
Read the theory

Floyd-Warshall · All-Pairs Shortest Paths

Relax every pair through each intermediate node — a full distance matrix.

Nodes
6
Intermediate
Legend
Current intermediate (row/col k)
AI Tutor Workspace
In a nutshell
Floyd-Warshall finds the shortest distance between every pair of vertices at once, not just from a single source. It keeps a grid of best-known distances and, one vertex at a time, allows that vertex as an intermediate stop: for every pair it checks whether routing through the new stop is shorter. After every vertex has had its turn, the grid holds all the true shortest distances.
Ready
Press play to begin the cinematic walkthrough.
Consider every node as a possible 'layover'. For each intermediate k, check if going i → k → j beats the best i → j so far — filling a full shortest-distance matrix.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Floyd-Warshall · All-Pairs Shortest Paths.