Bellman–Ford algorithm
Builds on Directed graphPathCycleAlgorithm
Definition
Let be a finite directed graph with vertices, let be a weight function, and let be a source vertex. The Bellman–Ford algorithm is the following algorithm.
- Set and for every vertex .
- Repeat times: for each edge , if , set ; this step is called a relaxation of the edge.
- Then, for each edge , if , report that a cycle of negative total weight is reachable from .
If no such cycle is reported, the output is the least total weight of a directed path from to . In that case exactly when no path from to exists.
Remarks
Example: take with , and . After the first round, if the edges are scanned in the order , one has , and . The check in step 3 reports nothing, so the shortest distance from to is .
Non-example of the conclusion: if the edges of weight and of weight form a cycle reachable from , the cycle has weight . Going around it lowers the weight without bound, so no shortest walk exists, and step 3 reports the cycle.
The correctness rests on the fact that after rounds, is at most the least weight of a walk from to with at most edges. The running time is , where .
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
- Bellman–Ford algorithm definition
Further reading
About this page
| Tag | YK3AHP1SSS |
|---|---|
| URI | m2://YK3AHP1SSS |
| Kind | definition |
| Writing | W0 stub |
| MSC | 05C85, 90C35, 68W40 |
| Defines | Bellman–Ford algorithm |
| Uses | Directed graph, Path, Cycle, Algorithm |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- 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.