Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved.

Similar presentations


Presentation on theme: "Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved."— Presentation transcript:

1 Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved

2 © 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

3 © 2008 Pearson Addison-Wesley. All rights reserved 15-4-3 Chapter 1 Section 15-4 Trees and Minimum Spanning Trees

4 © 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

5 © 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.

6 © 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.

7 © 2008 Pearson Addison-Wesley. All rights reserved 15-4-7 Example: Connected Graph Below is an example of a connected graph.

8 © 2008 Pearson Addison-Wesley. All rights reserved 15-4-8 Tree We call a graph a tree if the graph is connected and contains no circuits.

9 © 2008 Pearson Addison-Wesley. All rights reserved 15-4-9 Example: Trees Each of the graphs below is a tree.

10 © 2008 Pearson Addison-Wesley. All rights reserved 15-4-10 Example: Trees Neither of the graphs below is a tree. Not connected Has a circuit

11 © 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.

12 © 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.

13 © 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

14 © 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.

15 © 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.)

16 © 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.

17 © 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.

18 © 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).

19 © 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).

20 © 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.

21 © 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.

22 © 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.

23 © 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.

24 © 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.


Download ppt "Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley. All rights reserved."

Similar presentations


Ads by Google