Bellman–Ford
A shortest-path algorithm that computes the minimum-cost paths from a single source vertex to all other vertices in a weighted directed graph, and can detect negative-weight cycles.
Method
Relax all edges |V|−1 times. An additional relaxation pass detects negative cycles reachable from the source. Complexity O(VE). Suitable when negative weights are present (unlike Dijkstra).
Applications
Distance-vector routing protocols (RIP), arbitrage detection in currency markets, constrained shortest paths, graph analysis with negative costs.
Advantages
Handles negative edge weights; detects negative cycles; simple to implement; correct under mild conditions.
Limitations
Slower than Dijkstra for non-negative weights; does not scale as well to very large sparse graphs; requires care with negative cycles.
Alternatives
Dijkstra (non-negative), SPFA (queue-based optimization), Floyd-Warshall (all-pairs), Johnson's algorithm.
Example
Currency graph: a negative cycle means risk-free arbitrage loop.
Sources
Educational reference only, not professional advice.
All algorithms