






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







BellmanFord()
for each v ∈ V
d[v] = ∞;
d[s] = 0;
for i=1 to |V|-
for each edge (u,v) ∈ E
Relax(u,v, w(u,v));
for each edge (u,v) ∈ E
if (d[v] > d[u] + w(u,v))
return “no solution”;
Relax(u,v,w): if (d[v] > d[u]+w) then d[v]=d[u]+w
Initialize d[], which
will converge to
shortest-path value δ
Relaxation:
Make |V|-1 passes,
relaxing each edge
Test for solution:
have we converged yet?
Ie, ∃ negative cycle?
Note: this
is really a
call to Q->DecreaseKey()