Unformatted text preview: Correctness: Path relaxation property CSE 2011
Prof. J. Elder - 191 - Last Updated: 4/1/10 10:16 AM Correctness of DAG Shortest Path Algorithm Because we process vertices in topologically sorted
order, edges of any path are relaxed in order of
appearance in the path.
Edges on any shortest path are relaxed in order.
By path-relaxation property, correct. CSE 2011
Prof. J. Elder - 192 - Last Updated: 4/1/10 10:16 AM Example 2. Single-Source Shortest Path on
a General Graph (May Contain Cycles)
This is fundamentally harder, because the first paths we
discover may not be the shortest (not monotonic). CSE 2011
Prof. J. Elder - 193 - Last Updated: 4/1/10 10:16 AM Dijkstra’s algorithm (E. Dijkstra,1959)
Applies to general, weighted, directed or
undirected graph (may contain cycles).
But weights must be non-negative. (But they
can be 0!)
Essentially a weighted version of BFS.
Instead of a FIFO queue, uses a priority queue.
Keys are shortest-path weights (d[v]). Maintain 2 sets of vertices:
S = vertices whose final shortest-path weights are
Edsger Dijkstra Q = priority queue = V-S.
Prof. J. Elder - 194 - Last Updated: 4/1/10 10:16 AM Dijkstra’s Algorithm: Operation
We grow a “cloud” S of vertices, beginning with s and eventually
covering all the vertices
We store with each vertex v a label d(v) representing the distance of v
from s in the subgraph consisting of the cloud S and its adjacent vertices
At each step
We add to the cloud S the vertex u outside the cloud with the smallest
distance label, d(u)
We update the labels of the vertices adjacent to u s 9 S 1
7 CSE 2011
Prof. J. Elder - 195 - 4 11 Last Updated: 4/1/10 10:16 AM ...
View Full Document