Propagate later improvements
The fixed graph has s,a,b,t and only sa,sb,ab,ba,at,bt. No edge enters s or leaves t. All six weights are integer dimensionless costs from −100 through 100. Its only simple cycle links a and b; both are reachable from s and lead to t.[1]
Understand the calculation
- Set d(s)=0 and all other distances to infinity. Every finite label must be justified by a path from s.
- Relax directed edge u→v using d(v)←min(d(v),d(u)+w(u,v)) when u is reachable.
- Without a reachable negative cycle, a simple shortest path has at most |V|−1 edges. Thus |V|−1 complete relaxation rounds suffice.
- If another round still improves a label, a negative cycle is reachable from s. The check must not originate from unreachable infinity labels.
Synchronous round: paths of at most j edges[1]
Visualize the learning idea
A path found in a later round still matters
Free with a Quanta account. Your download stays ready after registration.
Two fully checked examples
A negative edge improves the route
- Given
- Vertices s,a,b,t. Only directed edges sa=4,sb=5,ab=−2,ba=3,at=6,bt=2.
- Find
- Find distances from s and explain the final round.
After one synchronous round only direct neighbors have finite labels.
Round two adds a→b and two possible routes to t.
Round three permits the three-edge route s→a→b→t.
Result: d(a)=4,d(b)=2,d(t)=4. The only simple cycle a→b→a costs 1.
Check: Simple s→t routes cost 10,7,4,14. Minimum is 4; another round yields no improvement.
The negative edge points the other way
- Given
- Only sa=8,sb=3,ab=4,ba=−1,at=2,bt=8.
- Find
- Find the cheapest s→t route.
Reaching a through b beats the direct edge.
Append a→t to the improved prefix.
Result: Path s→b→a→t costs 4; d(b)=3. Negative-edge direction matters.
Check: Two-edge routes cost 10 and 11, the other three-edge route costs 20. Cycle a→b→a costs 3, preventing indefinite improvement.
Recall the method later with the formula’s flashcards.
11 flashcards · English materials
Already have an account? Sign in for flashcardsAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Interpret the quantities
Negative costs can make sense in a model; negative geometric lengths do not. An infinite label indicates no known route or unreachability. It must not be interpreted as zero or copied into the calculation as a real finite edge cost.
Five solved exercises
Calculate · Foundation
Only sa=2,sb=8,ab=−1,ba=2,at=9,bt=3. Calculate d(s,t).
Show hint
Check s→a→b→t.
Learning goal: Relax negative edges correctly.
Show solution and calculation
2−1+3=4.
Alternatives cost 11,11 and 19; cycle ab+ba=1 is nonnegative.
Rearrange · Application
sa=4,sb=5,ab=x,ba=6,at=6,bt=2. Which x improves s→a→b over the direct route to b without a negative cycle?
Show hint
Write improvement and cycle conditions separately.
Learning goal: State improvement under an existence constraint.
Show solution and calculation
4+x<5 gives x<1; x+6≥0 gives x≥−6.
Together −6≤x<1.
Interpret · Foundation
Why do three synchronous rounds suffice for four vertices without a reachable negative cycle?
Show hint
A simple path never repeats a vertex.
Learning goal: Justify rounds from path structure.
Show solution and calculation
A simple path has at most three edges.
Nonnegative cycles can be removed from an optimal walk, leaving a simple representative.
Error analysis · Application
For sa=4,sb=5,ab=−2,ba=3,at=6,bt=2, a program immediately rejects ab<0. Is that necessary?
Show hint
Bellman–Ford permits negative edges.
Learning goal: Preserve valid inputs.
Show solution and calculation
No.
Cycle a→b→a costs 1 and finite shortest paths exist.
Rejecting every negative edge would remove a key capability of this algorithm.
Transfer · Challenge
sa=1,sb=4,ab=−3,ba=1,at=5,bt=2. Why is there no finite d(s,t)?
Show hint
a and b are reachable from s; their cycle can repeat before continuing to t.
Learning goal: Connect reachability with negative cycles.
Show solution and calculation
a→b→a costs −2.
Arbitrarily many repetitions drive the cost to t downward without bound.
An extra relaxation round detects the reachable negative cycle.
Check your understanding with the formula’s reference test.
8 test questions · English materials
Already have an account? Sign in for the testAvailable from Essential. A ready-made formula set, no AI credits required. Article exercises are not all included.
Limits and connections
Dijkstra uses a different finalization strategy under nonnegative weights. Floyd–Warshall instead handles all sources and destinations together. Graph assumptions and query requirements determine the method; Bellman–Ford does not universally replace every shortest-path algorithm.
Sources for this explanation
Quanta · Updated November 9, 2026
Editorial responsibility: Quanta Study editorial team
Review scope
This explanation, 2 worked examples and 5 exercises are available in German and English. Structure, source references and mathematical notation undergo automated checks. Calculations, model assumptions and both language versions receive a separate AI review.
An independent, named human subject review has not yet been documented. Our exercise numbers are worked examples, rather than measurements published by the cited sources.
Editorial responsibility, sources and methodsChange history
- Expanded a fully specified directed teaching graph with synchronous relaxation and reachable-negative-cycle detection.
Cite this reference page
Quanta. Bellman–Ford algorithm for shortest paths. Updated November 9, 2026. https://quanta-study.de/en/formula-sheet/bellman-ford-kuerzeste-wege-negative-kanten
When citing a specific scientific statement, also cite the specialist source linked to that statement.