The rst numbers are edge weights and the second

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The numbers a, b associated with each edge are as follows. The first numbers are edge weights and the second numbers give the order in which the edges are examined. The procedure stops when we have v (G) − 1 = 5 − 1 = 4 edges. (b) The table of values for t(x) and parent(x) (or pred(x)), both discussed in class, are as follows: Step Step Step Step 0 1 2 3 v1 0,- v2 10∗ , v1 - v3 20, v1 15∗ , v2 - v4 ∞, v1 32, v2 30, v3 25∗ , v5 v5 17, v1 17, v1 17∗ , v1 - The numbers with an ∗ are shortest distances from vertex v1 . The spanning tree is given below: v 1 0 1 1 0 1 0 v 11 00 2 11 00 11 00 10 17 v 5 v 1 0 3 1 0 1 0 5 v 11 00 8 1 0 111111 0000004 11 00 1 0 11 00 1 0 2 Question 3. (2 points) Exercise 2.3.10. [Prim’s algorithm] Consider this algorithm for finding a minimum weight spanning tree in weighted and connected graph G. Input. A connected (finite) graph G, with edge weight wt : E (G) → [0, ∞). Output. A graph T = (V (G), E (T )) of G. 1. Take a vertex x in G; S := {x}; E (T ) := ∅; 2. while (|S | < v (G)) do 3. among all edges e = {x, y } with x ∈ S and y ∈ V (G) − S choose an edge e = {x, y } with minimum weight; 4. add e to E (T ); add y to S ; 5. end do; (a) Explain why the algorithm always terminates. (b) Prove that T is a spanning tree of G. (c) Prove that T is a minimum weight spanning tree of G. Solution. (a) The algorithm always terminates because initially |S | = 1 and |S | increases by 1 for each intermediate step. The algorithm stops when |S | reaches |V (G)| (and G is a finite graph). (b) The graph T has v (G) vertices. Since the graph is connected, there is always an edge joining a vertex in S to a vertex in V (G) − S . Thus, there is always a choice for the edge e in line 3. Also, the algorithm is iterated v (G) − 1 times (see line 2), and an edge is added to E (T ) in each iteration. In addition, each edge added is a cut edge and so no cycle is created during the process. Therefore, the graph T finally constructed by the algorithm i...
View Full Document

This note was uploaded on 01/13/2014 for the course MAD 5305 taught by Professor Suen during the Spring '12 term at University of South Florida.

Ask a homework question - tutors are online