Presentation is loading. Please wait.

Presentation is loading. Please wait.

3/29/05Tucker, Sec. 4.21 Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta.

Similar presentations


Presentation on theme: "3/29/05Tucker, Sec. 4.21 Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta."— Presentation transcript:

1 3/29/05Tucker, Sec. 4.21 Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta

2 3/29/05Tucker, Sec. 4.22 Recall: A spanning tree of a graph G is a subgraph of G that is a tree containing all vertices of G. 3 2 6 9 1 5 1 11 3 2 7 4 3 6 2 2 Recall

3 3/29/05Tucker, Sec. 4.23 Definition A minimal spanning tree in a network is a spanning tree whose sum of edge lengths k(e) is as small as possible. 12 3 2 6 9 1 5 1 3 2 7 4 3 6 2 2

4 3/29/05Tucker, Sec. 4.24 Kruskal’s Algorithm Let T be a minimal spanning set (which is initially empty). Add to T the shortest edge that does not form a circuit with edges already in T. Repeat adding edges in this manner until set T has n-1 edges

5 3/29/05Tucker, Sec. 4.25 Example First include all 3 edges of length 1: (a, f), (l, q), (r, w) Next add all the edges of length 2: (a, b), (e, j), (g, l), (h, i), (l, m), (p, u), (s, x), (x, y) Next add almost all the edges of length 3: (c, h), (d, e), (k, l), (k, p), (q, v), (r, s), (v, w), but not (w, x) unless (r, s) were omitted [if both were present we would get a circuit containing these 2 edges together with edges (r, w) and (s, x) Next add all the edges of length 4 (f, g), (h, m), (c, d), (n, o), (s, t) Finally add either (m, n) or (o, t) to obtain a minimal spanning set f o p t j a y k w x q l n mr s v u i h g d c b e 2 5 5 7 3 7 3 3 28 7 4 3 5 2 95 42 6 8 1 10 3 1 3 4 2 732 4 6 2 4 8 2 1 5 3 X

6 3/29/05Tucker, Sec. 4.26 Prim’s Algorithm Let T be a minimal spanning tree, initially including any one edge of shortest length. Add to T the shortest edge between a vertex in T and a vertex not in T. Repeat adding edges in this manner until T has n-1 edges.

7 3/29/05Tucker, Sec. 4.27 Example There are 3 edges of length 1: (a, f), (l, q), (r, w) Suppose we pick (a, f) Next add (a, b), of length 2 Then (f, g), of length 4 Then (g, l), (l, q), (l, m) and so forth The next-to-last addition can be either (m, n), (o, t) (both of length 5) – in this case we’ll use (m, n) Then follow with (n, o) a y k w x q l n mr s v u i h g d c b e 2 5 5 7 3 7 3 3 28 7 4 3 5 2 95 42 6 8 1 10 3 1 3 4 2 732 4 6 2 4 8 2 1 5 3 f j p o t

8 3/29/05Tucker, Sec. 4.28 Theorem Prim’s algorithm yields a minimal spanning tree. Proof Assume that all edges have different lengths. Let T ' be a minimal spanning tree chosen to have as many edges as possible in common with T* (which will be constructed by Prim’s algorithm).

9 3/29/05Tucker, Sec. 4.29 Proof (cont’d)

10 3/29/05Tucker, Sec. 4.210 Proof (cont’d) a b

11 3/29/05Tucker, Sec. 4.211 Proof (cont’d) a b

12 3/29/05Tucker, Sec. 4.212 Proof (cont’d) a b

13 3/29/05Tucker, Sec. 4.213 For the class to try: The red numbers indicate the value of each edge. Find a minimal spanning tree. a 7 5 5 4 3 3 2 8 g f e d c b 5 Hint: use Kruskal’s Algorithm

14 3/29/05Tucker, Sec. 4.214 Solution a 5 First, add (c,f) to T Then, add (a,b) and (d,g) Then, add (a,e) Then add (e,f) and (f,g). Don’t add (b,e), because we can’t have a circuit! 7 5 5 4 3 3 2 8 g f e d c b


Download ppt "3/29/05Tucker, Sec. 4.21 Applied Combinatorics, 4th Ed. Alan Tucker Section 4.2 Minimal Spanning Trees Prepared by Amanda Dargie and Michele Fretta."

Similar presentations


Ads by Google