Bellman Ford Algorithm
Bellman Ford algorithm is used to find the shortest distance from given node. It is a dynamic programming algorithm.
We have to be given a set of edges with their weights and total number of nodes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  |  | 
BFA for undirected graph
For undirected graph BFA should be modified to relax the edges in both the directions, the modification of the graph will take place as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  |  |