edited by
918 views
2 votes
2 votes
A pseudo code for Bellman Ford where each edge is relaxed k times where k>=1. Let the graph G be a simple connected and undirected graph . Let number of vertices be V, and number of edges be E .

 int i=1;
            for( i=1;i<=k;i++)
            {
                     For each edge (u,v) in G
                      {
                      if( d[v] > d[u] +cost(u,v))
                      then d[v] =d[u] +cost(u,v)
                       }
            }

// Now we relax every edge again to detect negative weight cycle
Where d[v] denotes the cost of shortest path from source S to node v, at any instant of time. Initially d[v]=0 if v=S else d[v] =infinite

Cost (u,v) denotes weight of the edge (u,v).

Which of the following statement is true.

(i) For any, k d[v] denotes the shortest path from source to node v using atmost k edges.
(ii) For proper running of the algorithm k can be equal to V-1.
(iii) For proper running of the algorithm k must be equal to E.
edited by

1 Answer

0 votes
0 votes
1 and 3 is true..  2 is false as bellman ford do relaxation over each edge , and number of relaxation denotes shortest path upto relaxations.

Related questions

0 votes
0 votes
2 answers
2
2 votes
2 votes
4 answers
4
Bongbirdie asked Apr 6, 2017
1,875 views
Is the below statement correct:Bellman Ford finds all negative weight cycles in the graph.This is true or false?