18 Graphs Part 4

# 18 Graphs Part 4 - Graphs part 4 Minimum Spanning Trees...

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

Graphs, part 4 Minimum Spanning Trees 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 25 March 2010

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

View Full Document
2 Announcements HW5 (KevinBacon) is available You must work alone
3 Last time: Relax! (shortest paths) For each node v store d[v] , the best-known distance so far An algorithm: 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 While there exists a tense edge Relax some edges Relax(u,v): if (d[v] > d[u] + w u,v ) d[v] = d[u] + w u,v v u w u,v s d[u]

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

View Full Document
4 Relaxing the frontier Suppose we’ve computed the shortest distances for some vertices C , and we’ve relaxed all edges out of C Then d[v] is a shortest distance for some vertex v in the frontier C s s 1 s 2 s 3 s k v 1 v j v 2 v 3 v 0 w 0 w 1 w 2 w 3 w 4 w 5 w 6 w 7 V-C
5 Dijkstra’s algorithm If edge weights are non-negative then the smallest d[v] in the frontier is the shortest distance to v C s s 1 s 2 s 3 s k v 1 v j v 2 v 3 v 0 w 0 w 1 w 2 w 3 w 4 w 5 w 6 w 7 V-C

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

View Full Document
6 Bellman-Ford algorithm We don’t know which vertices are in C Relax all edges in the graph We know this adds some vertex to C C s s 1 s 2 s 3 s k v 1 v j v 2 v 3 v 0 w 0 w 1 w 2 w 3 w 4 w 5 w 6 w 7 V-C
7 Minimum Spanning Trees (MSTs) Minimum Spanning Trees Algorithms for MSTs The Red Rule Prim’s algorithm Kruskal’s algorithm

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

View Full Document
8 Problem: Laying telephone wire Central office
9 Wiring: A naïve approach Central office

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

View Full Document
10 Wiring: A better approach Central office
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 33

18 Graphs Part 4 - Graphs part 4 Minimum Spanning Trees...

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

View Full Document
Ask a homework question - tutors are online