Floyd–Warshall algorithm
Builds on Directed graphPathCycleAlgorithm
Definition
Let be a finite directed graph with vertex set and edge weights . Assume that has no cycle of negative total weight. The Floyd–Warshall algorithm is the algorithm that computes numbers for as follows.
- ; if and is an edge; and otherwise.
- For , .
It returns for all pairs . Here is the least weight of a directed path from to whose intermediate vertices all lie in . So is the shortest path distance from to .
Remarks
Example: with edges of weight , of weight and of weight , one has and .
Non-example: if the hypothesis fails, say has the cycle of total weight , then no shortest walk from to exists. The recurrence still runs, and the negative cycle shows up as for a vertex on it.
The table can be updated in place, so the algorithm needs memory and time.
Reading path
To understand this page from the ground up, read these 5 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Algorithm concept
- Cycle concept
- Directed graph concept
- Path concept
- Floyd–Warshall algorithm definition
Further reading
About this page
| Tag | PXNQBKSQ9F |
|---|---|
| URI | m2://PXNQBKSQ9F |
| Kind | definition |
| Writing | W0 stub |
| MSC | 05C85, 90C35, 68W40 |
| Defines | Floyd–Warshall algorithm |
| Uses | Directed graph, Path, Cycle, Algorithm |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.