The Bellman-Ford algorithm computes shortest paths from a source vertex to all other vertices in a weighted graph. Unlike Dijkstra's algorithm, Bellman-Ford can handle graphs with negative weight edges and detect negative weight cycles.
This visualization demonstrates the Bellman-Ford algorithm on a graph with vertices A, B, C, and D, with some negative edges.
Vertex | A | B | C | D |
---|---|---|---|---|
Distance | 0 | ∞ | ∞ | ∞ |
Previous | - | - | - | - |