Jump to content

User:SummonedToDIe/sandbox

From Wikipedia, the free encyclopedia
SummonedToDIe/sandbox
ClassSingle-source shortest path problem (for weighted directed graphs)
Data structureGraph
Worst-case performance
Worst-case space complexity

The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph.[1] It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers. The algorithm is usually named after two of its developers, Richard Bellman and Lester Ford, Jr., who published it in 1958 and 1956, respectively; however, Edward F. Moore also published the same algorithm in 1957, and for this reason it is also sometimes called the Bellman–Ford–Moore algorithm.[1]

Negative edge weights are found in various applications of graphs, hence the usefulness of this algorithm.[2] If a graph contains a "negative cycle" (i.e. a cycle whose edges sum to a negative value) that is reachable from the source, then there is no cheapest path: any path can be made cheaper by one more walk around the negative cycle. In such a case, the Bellman–Ford algorithm can detect negative cycles and report their existence. [3][1]

  1. ^ a b c Bang-Jensen & Gutin (2000)
  2. ^ Sedgewick (2002).
  3. ^ Kleinberg & Tardos (2006).