Bellman Ford Algorithm
Bellman Ford Algorithm
The algorithm was first proposed by Alfonso Shimbel (1955), but is instead named after Richard
Bellman and Lester Ford Jr. who published it in 1958 and 1956, respectively.
Edward F. Moore also published a variation of the algorithm in 1959, and for this reason it is
also sometimes called the Bellman–Ford–Moore algorithm
Later on some improvements were proposed like:
Yen (1970) – arbitrary linear order of the vertices
Bennister & Eppstein – random permutation of vertex ordering.
BELLMAN-FORD ALGORITHM
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.
It is capable of handling graphs in which some of the edge weights are negative numbers.
Dijkstra’s algorithm doesn’t work for Graphs with negative weights, as it does not confirm
whether it produces the correct answer or not.
Bellman-Ford Algorithm guarantees the correct answer even if weighted graph contain negative
weighed values.
It is slower than Dijkstra's algorithm for the same problem, even though it is more versatile.
METHODOLOGY
Step 1 : Make a list of all the graphs edges. This is simple if an adjacency list represents the graph
Step 2 : ‘V-1’ is used to calculate the number of iterations where,
V=Number of vertices
Step 3 : Begin with the u=0 position and all v= infinity,
if d[v]>d[u]+c(u,v), then
d[v] = d[u]+c(u,v) where,
u=Source node (only one node)
v=Destination nodes (remaining nodes)
Step 4 : if new distance is less than previous one, update the distance for each edge in each
iteration.
Step 5 : Consideration of alliteration is mandatory to ensure all possible paths.
EXAMPLE -
4 7 -15
C D
7
IMPROVEMENTS..
If an iteration of the main loop of the algorithm terminates without making any changes, the
algorithm can be immediately terminated.
With this early termination condition, main loop, may in some cases, fewer iterations than |
v|-1 iterations.
In 1959 Edward F. Moore reduces number of relation steps that need to be performed within each
iteration of algorithm.
Yen in 1970 proposes another improvement that describes some arbitrary linear order on all
vertices and then partition the set of all edges into two subsets.
Another improvement was defined by Bannister and Eppstein in 2012 that assigns the
replacement of arbitrary linear order of vertices by random permutation.
DIJKSTRA’S V/S BELLMAN-FORD ALGORITHM