### Similar presentations

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-2 Chapter 15: Graph Theory 15.1 Basic Concepts 15.2 Euler Circuits 15.3 Hamilton Circuits and Algorithms 15.4 Trees and Minimum Spanning Trees

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-4 Trees and Minimum Spanning Trees Connected Graphs and Trees Spanning Trees Minimum Spanning Trees Kruskal’s Algorithm Number of Vertices and Edges

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-5 Trees In the previous two sections, we looked at graphs with special kinds of circuits, In this section we examine graphs (called trees) that have no circuits.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-6 Connected Graph A connected graph is one in which there is at least one path between each pair of vertices.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-11 Unique Path Property of Trees In a tree there is always exactly one path from each vertex in the graph to any other vertex in the graph.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-12 Spanning Tree A spanning tree for a graph is a subgraph that includes every vertex of the original, and is a tree.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-13 Example: Finding a Spanning Tree Find a spanning tree for the graph below. We must break two circuits by removing a single edge from each. One of several possible ways to do this is shown. Solution

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-14 Minimum Spanning Tree A spanning tree that has total minimum total weight is called a minimum spanning tree for the graph.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-15 Kruskal’s Algorithm for Finding a Minimum Spanning Tree Choose edges for the spanning tree as follows. Step 1:First edge: choose any edge with the minimum weight. Step 2: Next edge: choose any edge with minimum weight from those not yet selected. (The subgraph can look disconnected at this stage.)

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-16 Kruskal’s Algorithm for Finding a Minimum Spanning Tree Step 3: Continue to choose edges of minimum weight from those not yet selected, except do not select any edge that creates a circuit in the subgraph. Step 4:Repeat step 3 until the subgraph connects all vertices of the original graph.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-17 Example: Kruskal’s Algorithm A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 Use Kruskal’s algorithm to find a minimum spanning tree for the graph.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-18 Example: Kruskal’s Algorithm Solution A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 First, choose ED (the smallest weight).

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-19 Example: Kruskal’s Algorithm Solution A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 Now choose BF (the smallest remaining weight).

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-20 Example: Kruskal’s Algorithm Solution A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 Now CD and then BD.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-21 Example: Kruskal’s Algorithm Solution A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 Note EF is the smallest remaining, but that would create a circuit. Choose AE and we are done.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-22 Example: Kruskal’s Algorithm Solution A C B D E F 1 7 10 7.5 8 3 4 9.5 4.5 1.5 The total weight of the tree is 16.5.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-23 Number of Vertices If a graph is a tree, then the number of edges in the graph is one less than the number of vertices. A tree with n vertices has n – 1 edges.

© 2008 Pearson Addison-Wesley. All rights reserved 15-4-24 Example: Vertex/Edge Relation A molecule of a chemical compound contains 54 atoms and it has a tree-like structure. How many chemical bonds are there in the molecule? Solution If the atoms are like the vertices of a tree, the bonds are like the edges. This tree has 54 vertices, so the number of bonds (edges) must be 54 – 1 = 53.