next up previous
Next: Up: Previous:

Relaxation

This is a tightening of the upper bound d(v) on the shortest path weight from s to v.

Maintain d(v) and pred(v) for each vertex v.



\psfig{figure=figures/f18-3.ps}

Relax(u, v, w)
$\;\;\;\;\;$if d(v) > d(u) + w(u,v)
$\;\;\;\;\;$then d(v) = d(u) + w(u,v)
$\;\;\;\;\;$ $\;\;\;\;\;$pred(v) = u



Init-Single-Source(G, s) $\;\;\;\;\;$ $\;\;\;\;\;$; G = (V, E)
$\;\;\;\;\;$foreach v in V
$\;\;\;\;\;$ $\;\;\;\;\;$d(v) = $\infty$
$\;\;\;\;\;$ $\;\;\;\;\;$pred(v) = NIL
$\;\;\;\;\;$d(s) = 0



Lemmas 25.4 - 25.9 show Relaxing after Init-Single-Source will eventually reach the shortest path weight and predecessor graph will be a shortest path tree (assuming no negative-weight cycles).


next up previous
Next: Up: Previous: