10.4 Spanning Trees
Def Def: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every vertex of G See handout for examples
Thm. 1 Thm 1.: A simple graph is connected iff it has a spanning tree Recall some def: – Connected ____ – Spanning tree______ – Tree_________
Proof of Thm. 1 A simple graph is conn.iff it has a spanning tree: Proof Suppose G has a spanning tree T Because it is spanning, ________ Because it is a tree, 10.1 Thm. 1 says _________ Since T is a subgraph of G, G is ________ Suppose G is connected If G is NOT a tree it must ___________ Remove an edge. The resulting graph has ___ edge and contains ___vertices of G and is ________ Repeat until _____ This is possible because______________
Algorithms for constructing spanning trees See handout and use the following methods – Depth first (backtracking) Start with a root Form a path by adding vertices as long as possible (without adding a circuit) When you can’t add any more, go back to previous one and add more… – Breath first Start with a root Add all edges incident to this vertex (level 1), arbitrarily order them For each vertex in level 1, add each edge incident (as long as it doesn’t form a circuit),…
Depth example adij cefhk bg Start at f
Breadth example abcl defg hij mkstart at e
Use backtracking to find a subset, if possible, … Of the set {27, 24, 19, 14, 11, 8} with the sum of 20
Use backtracking to find a subset, if possible, … Of the set {27, 24, 19, 14, 11, 8} with the sum of 41
Use backtracking to find a subset, if possible, … Of the set {27, 24, 19, 14, 11, 8} with the sum of 60
Ex with colors See if a graph has 3 colors– use a tree
10.5 Minimum spanning trees Prim’s Algorithm – Start with smallest weight – Successively add edges that are incident, choosing smallest weights, and not forming a circuit – Stop after n-1 edges selected (with n vertices) Kruskal’s Algorithm – Start with smallest weight – Successively add edges that are smallest weight (not necessarily incident) and not forming a circuit – Stop after n-1 edges selected (with n vertices) See handout or book ex