17 Graphs Part 3

17 Graphs Part 3 - Graph Algorithms, part 3 15-211...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Graph Algorithms, part 3 15-211 Fundamental Data Structures and Algorithms Margaret Reid-Miller 23 March 2010 Reading for today: Chapter 14
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements Homework 6 is available Theory due Tuesday, April 6 in class Programming due Thursday, April 8 11:59pm Reading: Weiss Chapter 14 2
Background image of page 2
Last time … Topological Sorting c d a f g b e NOT YET VISITED BEING VISITED NOW DONE VISITING f g Step: 8 3 8 g d c e a Stack 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Last time … Topological Sorting c d a f g b e NOT YET VISITED BEING VISITED NOW DONE VISITING f g d c e a b Step: 14 3 8 9 10 11 12 14 Notice these are monotonically decreasing b Stack
Background image of page 4
The correctness of toposort Let G=(V,E) be a DAG and (u,v) 2 E. We must show that u was added to the head of the list after v was added (and thus appears in front of v in the list). Intuition: During the recursive call on u what colors can v be? Not GREY, or we’d have a cycle (and it’s a DAG). Black: Then v is already on list. White (green): The algorithm will make a recursive call on v; When the the recursive call finishes (backtracks), it will put v on the list. But the recursive call on u has not completed. Therefore u will be put on the head of the list after v was added.
Background image of page 5

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

View Full DocumentRight Arrow Icon
Today: More graph algorithms Shortest paths Preliminaries… BFS for unweighted graphs Single source weighted paths Dijkstra’s algorithm for weighted graphs without negative weights Weighted graphs without negative cycles img sources: Google Maps and Discover magazine
Background image of page 6
Single-Source Shortest Paths 7
Background image of page 7

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

View Full DocumentRight Arrow Icon
Airline routes PVD BOS JFK ORD LAX SFO DFW BWI MIA 337 2704 1846 1464 1235 2342 802 867 849 740 187 144 1391 184 1121 946 1090 1258 621 8
Background image of page 8
Shortest path Suppose we live in Baltimore (BWI) and want the shortest path to San Francisco (SFO). 9
Background image of page 9

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

View Full DocumentRight Arrow Icon
Many applications Shortest paths model many useful real- world problems. Minimization of latency in the Internet. Minimization of cost in power delivery. Job and resource scheduling. Route planning. Counting change for large denominations. (!?) 10
Background image of page 10
Distance in a graph Let G(V,E) be a directed graph with edge weights W. Definition : The cost of a path P = v 0 ,v 1 …,v k-1 ,v k is the sum of the weights of its edges. Confusion alert: the length of a path P is the number of edges in P We define the δ (s,v) as cost of shortest path from s to v. If no such path exits δ (s, v) = 11
Background image of page 11

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

View Full DocumentRight Arrow Icon
A path is simple if it contains any vertex at most once. Note that there are only finitely many simple paths (even if there are cycles in the graph). Enumerate all simple paths starting at s. Collect all simple paths with target t. Compute their cost, determine the min. 12
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/10/2011.

Page1 / 82

17 Graphs Part 3 - Graph Algorithms, part 3 15-211...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online