Bellman-Ford Algorithm Overview
- Bellman–Ford algorithm is a classical method for computing single-source shortest paths in weighted graphs, even with negative edge weights.
- It iteratively relaxes edges over up to n-1 rounds to update distances and detect reachable negative cycles, ensuring correctness in the absence of negative cycles.
- The algorithm serves as a baseline for various extensions including hop-bounded approaches, reweighting techniques, and generalized dynamic programming templates.
The Bellman–Ford algorithm is a classical algorithm for the single-source shortest-paths problem on a directed weighted graph with source , where edge weights may be negative and shortest paths are well-defined only if no negative cycle is reachable from the source. It repeatedly relaxes edges and computes exact distances in time, equivalently , which has made it the canonical general-purpose baseline for negative-weight SSSP and the reference point for later attempts to improve worst-case complexity (Elmasry, 2024, Atalig et al., 6 Aug 2025).
1. Problem model and dynamic-programming formulation
In the standard formulation, Bellman–Ford maintains tentative distances from to every vertex. The textbook initialization is
and the primitive operation is edge relaxation: for an arc ,
A round-based dynamic-programming view writes for the length of a shortest path from to 0 using at most 1 edges, with
2
and, for 3,
4
Computing one layer from the previous one takes 5 time by scanning all edges, and repeating this process for successive hop budgets yields the classical 6 running time (Elmasry, 2024, Kociumaka et al., 2022).
This recurrence expresses the Bellman optimality principle in its additive shortest-path form: a shortest path to 7 with at most 8 edges either already uses at most 9 edges, or its last edge is some 0 whose prefix to 1 uses at most 2 edges. The algorithm is therefore both a shortest-path method and a layered dynamic program over path length (Kociumaka et al., 2022).
2. Correctness, simple paths, and negative-cycle detection
Bellman–Ford’s correctness rests on the fact that, in a graph without reachable negative cycles, every shortest path can be taken to be simple and therefore has at most 3 edges. After the 4-th full pass over the edges, all vertices whose shortest paths use at most 5 edges have correct labels. Consequently, after 6 passes, all shortest-path distances are correct (1111.07325).
Negative-cycle detection is integrated into the standard algorithm by performing one additional full pass after the first 7 passes. If any label can still be decreased, then some negative cycle is reachable from the source. This mechanism is the classical certificate that the shortest-path problem is undefined in the usual sense for that source-reachable region (1111.07325).
The same recurrence also explains why Bellman–Ford applies beyond the ordinary source-to-all setting. Restricting the outer loop to 8 rounds computes shortest paths that use at most 9 edges, which is the standard hop-bounded formulation. This observation underlies both lower-bound work and several later generalizations of the algorithmic template (Kociumaka et al., 2022).
3. Complexity, scan order, and non-adaptive relaxational models
The standard non-adaptive dense-graph implementation relaxes every edge in each of 0 rounds, giving
1
relaxations on the complete digraph. Yen’s 1970 improvement partitions edges into forward and backward acyclic sets under a fixed vertex order and alternates topological sweeps, reducing the dense-graph count to
2
A randomized variant that keeps Yen’s two-DAG schedule but chooses the vertex numbering uniformly at random with the source first achieves at most
3
relaxations in expectation, with corresponding dense-graph expectation 4 (Hu et al., 2024, Bannister et al., 2011).
| Variant | Bound in the dense regime | Main point |
|---|---|---|
| Standard non-adaptive Bellman–Ford | 5 relaxations | Full edge scan in each round |
| Yen’s improvement | 6 relaxations | Forward/backward acyclic sweeps |
| Randomized Yen-style ordering | expected 7 relaxations | Random permutation reduces alternations |
| Deterministic lower bound for non-adaptive schedules | 8 relaxations | Yen is asymptotically optimal in this model |
The dense-graph lower-bound story is now sharp for deterministic non-adaptive schedules: every deterministic non-adaptive relaxation-based algorithm on the complete digraph requires
9
relaxations, establishing Yen’s improvement as asymptotically optimal in that model (Hu et al., 2024). More broadly, lower bounds for non-adaptive shortest-path relaxation show 0 on complete directed graphs, 1 when 2, and 3 in general sparse regimes, so Bellman–Ford is asymptotically optimal for dense graphs and near-optimal for sparse graphs within the non-adaptive relaxation framework (Eppstein, 2023).
4. Hop-bounded Bellman–Ford and conditional optimality
One of Bellman–Ford’s most basic dynamic-programming interpretations is the shortest hop-bounded path problem: given 4, 5, and a hop bound 6, compute the length of a shortest 7-8 path using at most 9 edges. The Bellman–Ford recurrence solves this in 0 time by truncating the number of rounds to 1 (Kociumaka et al., 2022).
Recent fine-grained lower bounds show that this 2 dependence is conditionally optimal up to subpolynomial factors, even in undirected graphs with non-negative edge weights. Under the APSP Hypothesis, there is neither an 3-time algorithm nor an 4-time algorithm for arbitrary 5; under the stronger Min-Plus Convolution Hypothesis, the same conclusion extends to the full parameter range. This establishes Bellman–Ford’s round-based dynamic program as the correct complexity benchmark for hop-bounded shortest paths, rather than merely a classical baseline (Kociumaka et al., 2022).
This result also clarifies a common misconception. Improvements for negative-weight SSSP do not automatically transfer to all Bellman–Ford-style tasks. In the hop-bounded setting, even the benign combination of undirected graphs and non-negative weights does not permit a polynomial-factor improvement over the Bellman–Ford recurrence under the cited hypotheses (Kociumaka et al., 2022).
5. Reweighting, attempts to beat the 6 barrier, and their correction
A major line of work reinterprets Bellman–Ford through potentials and reduced costs. Given a potential 7, reduced weights take the Johnson-style form
8
For any path 9,
0
so shortest paths between fixed endpoints are preserved under reweighting. If one can construct a potential that makes every reduced weight nonnegative, then a final Dijkstra computation suffices (Elmasry, 2024).
A 2024 paper claimed to “break the Bellman-Ford bound” by converting a graph with negative weights into one with nonnegative weights using at most
1
calls to a modified Dijkstra algorithm, leading to
2
time with Fibonacci heaps. Its progress analysis tracked “snakes,” maximal zero-weight segments followed by one negative edge, and argued that these structures grow quickly enough to force only 3 alternating iterations (Elmasry, 2024).
That claimed deterministic breakthrough was later refuted. The refutation showed that the runtime analysis is incorrect, not that the computed shortest paths are wrong. In particular, it constructed a family of weighted DAGs 4 with
5
on which the algorithm performs 6 iterations; since each iteration costs 7, the total runtime is
8
The structural flaw is that shortest nbp-paths need not extend monotonically: a minimizing path to one vertex need not extend the minimizing path to its predecessor, so a negative edge can remain negative after reweighting even when the snake argument predicts otherwise (Atalig et al., 6 Aug 2025).
At the same time, randomized progress on negative-weight SSSP has continued. A 2025 result gives an expected-time randomized algorithm running in
9
and a 2026 dense-graph result achieves
0
time for directed graphs with real-valued possibly negative edge weights. These developments preserve Bellman–Ford as the conceptual benchmark while showing that the 1 barrier is not absolute in the randomized or dense-graph regimes (Rao, 28 Mar 2025, Li et al., 18 Feb 2026).
6. Bellman–Ford as a general algorithmic template
Bellman–Ford has also become a template for broader dynamic-programming and algebraic constructions. One generalization replaces additive edge-weight path cost by an arbitrary path function 2 on a path system 3, and defines the generalized single-source shortest path problem by minimizing 4 over 5 for every terminal 6. The resulting extended Moore–Bellman–Ford algorithm uses the update
7
and runs in 8 time when evaluating 9 takes 0 time, provided 1 is order-preserving and has no negative circles (Cheng, 2017).
A second line of generalization lifts Bellman–Ford from ordinary graphs to hyper-graphs arising in symbolic optimal control. There the Bellman operator is
2
and a generalized Bellman–Ford algorithm computes the value function with 3 time, where
4
A later modification tracks which successors currently realize the relevant supremum and reactivates only predecessor states that depend on them, reducing the number of processed nodes per iteration while preserving the same Bellman-style fixed-point objective (Weber et al., 2020, Kreuzer et al., 29 Jan 2025).
More abstractly, Bellman–Ford can be viewed as iterative propagation over semirings and semimodules. In that algebraic view, classical shortest paths correspond to the min-plus semiring, while widest paths, multi-source propagation, and related “MBF-like” algorithms arise by changing the aggregation and extension operators (Friedrichs et al., 2015). The same viewpoint motivates “Neural Bellman-Ford Networks,” which reinterpret Bellman–Ford as a learned path-aggregation architecture with three components—INDICATOR, MESSAGE, and AGGREGATE—for link prediction on graphs and knowledge graphs (Zhu et al., 2021).
These extensions underscore a final point. Bellman–Ford is not only the classical negative-weight shortest-path algorithm; it is also a durable computational pattern: iterative relaxation, path extension, and aggregation under a monotone progress invariant. That pattern continues to reappear in lower-bound theory, reweighting-based SSSP, distributed computation, symbolic control, algebraic graph algorithms, and learned graph models (Friedrichs et al., 2015, Zhu et al., 2021).