{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture7 - CS 473 Algorithms Chandra Chekuri...

This preview shows pages 1–19. Sign up to view the full content.

CS 473: Algorithms Chandra Chekuri [email protected] 3228 Siebel Center University of Illinois, Urbana-Champaign Fall 2009 Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Part I Dijkstra’s Algorithm Recap Chekuri CS473ug
Dijkstra’s Algorithm using Priority Queues Shortest paths from node s to all nodes in V : Q = makePQ() insert(Q, (s,0)) for each node u 6 = s insert(Q, (u, )) S = for i = 1 to |V| do (v, dist(s,v)) = extractMin(Q) S = S ∪ { v } For each u in Adj(v) do decreaseKey(Q, (u, min (dist(s,u), dist(s,v) + (v,u)))) Algorithm adds nodes to S in order of increasing distance from s Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 Chekuri CS473ug
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 6 6 Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 6 9 6 Chekuri CS473ug
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 6 13 9 13 6 Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 19 6 13 9 13 6 10 Chekuri CS473ug
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 19 25 6 13 9 13 6 10 6 Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 19 36 25 6 13 9 13 6 10 11 6 Chekuri CS473ug
Example s 2 3 4 5 6 7 t 9 13 6 10 8 20 30 18 11 16 6 19 6 6 25 0 9 19 36 25 6 13 38 9 13 6 10 11 6 25 Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Shortest Path Tree Dijkstra’s algorithm finds the shortest path distances from s to V . Question: How do we find the paths themselves? Chekuri CS473ug
Shortest Path Tree Dijkstra’s algorithm finds the shortest path distances from s to V . Question: How do we find the paths themselves? Q = makePQ() insert(Q, (s,0)) prev(s) = null for each node u 6 = s insert(Q, (u, )) prev(u) = null S = for i = 1 to |V| do (v, dist(s,v)) = extractMin(Q) S = S ∪ { v } For each u in Adj(v) do if (dist(s,v) + (v,u) < dist(s,u) ) then decreaseKey(Q, (u, dist(s,v) + (v,u))) prev(u) = v Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Shortest Path Tree Lemma The edge set ( u , prev ( u )) is the reverse of a shortest path tree rooted at s. For each u, the reverse of the path from u to s in the tree is a shortest path from s to u. Proof Sketch. The edgeset { ( u , prev ( u )) | u V } induces a directed in-tree rooted at s (Why?) Use induction on | S | to argue that the tree is a shortest path tree for nodes in V . Chekuri CS473ug
Shortest paths to s Dijkstra’s algorithm gives shortest paths from s to all nodes in V . How do we find shortest paths from all of V to s ? Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Shortest paths to s Dijkstra’s algorithm gives shortest paths from s to all nodes in V . How do we find shortest paths from all of V to s ? In undirected graphs shortest path from s to u is a shortest path from u to s so there is no need to disjtinguish. In directed graphs, use Dijkstra’s algorithm in G rev ! Chekuri CS473ug
Part II Shortest Paths with Negative Length Edges Chekuri CS473ug

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Single-Source Shortest Paths with Negative Edge Lengths Single-Source Shortest Path Problems Input A directed graph G = ( V , E ) with arbitrary (including negative) edge lengths. For edge e = ( u , v ), ( e ) = ( u , v ) is its length.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 78

lecture7 - CS 473 Algorithms Chandra Chekuri...

This preview shows document pages 1 - 19. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online