1 / 16

§15.4, Trees

§15.4, Trees. Learning Targets Understand the definition and properties of a tree. Find a spanning tree for a connected graph. Find the minimum spanning tree for a weighted graph. Trees. A tree is a graph that is connected and has no circuits. All trees have the following properties:

audra
Download Presentation

§15.4, Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. §15.4, Trees

  2. Learning Targets • Understand the definition and properties of a tree. • Find a spanning tree for a connected graph. • Find the minimum spanning tree for a weighted graph.

  3. Trees A tree is a graph that is connected and has no circuits. All trees have the following properties: • There is one and only one path joining any two vertices. • Every edge is a bridge. • A tree with n vertices must have n – 1 edges.

  4. Example 1: Identifying Trees Which of the following graphs are trees? Why or why not? A tree because it is connected, i.e., there is only one path joining any two vertices. If any edge is removed, then the graph would be disconnected. Not a tree because it has a circuit, i.e., a tree with five vertices must have four edges and there are five vertices and five edges. Not a tree because it is disconnected, i.e., a tree with five vertices must have four edges.

  5. Practice: Pg 857, #1 – 5

  6. Spanning Trees • A subgraph is a set of vertices and edges chosen from among those of the original graph. • A subgraph that contains all of a connected graph’s vertices, is connected, and contains no circuits is called a spanning tree. • The two subgraphs in the previous example are spanning trees.

  7. Example 2: Finding a Spanning Tree Find a spanning tree for the graph. Solution: A possible spanning tree must contain all eight vertices shown in the connected graph above. The spanning tree must have 8 – 1 = 7 edges. • Since the previous graph has 12 edges, we must remove 5 edges.

  8. Example 2: Finding a Spanning Tree We break the inner rectangular circuit removing edge FG. • We break the outer rectangular circuit by removing all four of its edges while retaining the edges leading to vertices A, B, C, and D. This leaves us the spanning tree seen on the right. Notice that each edge is a bridge and no circuits are present.

  9. Practice: Pg 857, #17, 18

  10. Minimum Spanning Trees • The minimum spanning tree for a weighted graph is a spanning tree with the smallest possible total weight. From the spanning trees below, we see (c) has a smaller weight than (b), but is this the minimum spanning tree or should we continue to find other possible spanning trees that may have a total weight less than 107?

  11. Kruskal’s Algorithm Here is a procedure for finding the minimum spanning tree from a weighted graph: • Find the edge with the smallest weight in the graph. If there is more than one, pick one at random. Mark it in red. • Find the next-smallest edge in the graph. If there is more than one, pick one at random. Mark it inred. • Find the next-smallest unmarked edge in the graph that does not create a red circuit. If there is more than one, pick one at random. Mark it inred. • Repeat step 3 until all vertices have been included. The red edges are the desired minimum spanning tree.

  12. Example 3: Using Kruskal’s Algorithm Seven buildings on a college are connected by the sidewalks shown in the figure. The weighted graph represents buildings as vertices, sidewalks as edges, and sidewalk lengths as weights. A heavy snow has fallen and the sidewalks need to be cleared quickly. Campus decides to clear as little as possible and still ensure that students walking from building to building will be able to do so along cleared paths. Determine the shortest series of sidewalks to clear. What is the total length of the sidewalks that need to be cleared?

  13. Example 3: Using Kruskal’s Algorithm Using Kruskal’s Algorithm, we complete minimizing the spanning tree in a series of steps given below. Refer to the next graph coinciding with the steps.

  14. Example 3: Using Kruskal’s Algorithm Step 1. Find the edge with the smallest weight. Select edge GF by marking it in red. Step 2. Find the next-smallest edge in the graph. Select BD by marking it in red. Step 3. Find the next-smallest edge in the graph. Select AD by marking it in red. Step 4. Find the next-smallest edge in the graph that does not create a circuit. Select DG, since it does not create a circuit, by marking it in red.

  15. Example 3: Using Kruskal’s Algorithm Step 5. Find the next-smallest edge in the graph that does not create a circuit. Select CD, since it does not create a circuit, by marking it in red. Step 6. Find the next-smallest edge in the graph that does not create a circuit. Select CE, since it does not create a circuit, by marking it in red. The minimum spanning tree is completed. The red subgraph contains all seven vertices, six edges, and no circuits.

  16. Example 3: Using Kruskal’s Algorithm The total length of the sidewalks that need to be cleared is 242 + 245 + 249 + 251 + 253 + 259, or 1499 feet. Homework: Pg 857, #6 – 16, 20 – 25.

More Related