130 likes | 228 Views
Section 14.4 . Trees. Remember. A graph is connected if there is a path between any two vertices. Otherwise we say that the graph is disconnected . Connected Graph Disconnected Graph. A. A. B. C. B. C. D. D. F. F. E. E. Remember. AB is the only bridge in this graph.
E N D
Section 14.4 Trees
Remember A graph is connected if there is a path between any two vertices. Otherwise we say that the graph is disconnected. Connected GraphDisconnected Graph A A B C B C D D F F E E
Remember AB is the only bridge in this graph Every edge is a bridge in this graph A A B B C D C D F E A Bridge is an edge that when removed, it disconnects the graph.
Terminology This graph is not a tree because BC, CD, and DB are not bridges. This graph is not a tree because it is not connected. A A C B B E F C D D A TREE is a connected graph in which every edge is a bridge.
Terminology These are the tree possible spanning trees. There are 3 possible spanning trees for this graph A A A A B B B B C C D C D D C D A SPANNING TREE is a tree created from another graph by removing edges while still maintaining a path to each vertex.
Terminology A A A A 8 8 8 8 B B B B 13 5 13 5 5 13 1 1 1 C D C D D C C D Cost = 14 Weighted Graph Cost = 26 Cost = 22 Minimum – cost spanning tree A MINIMUM – COST SPANNING TREE is the least expensive spanning tree of a graph.
Kruskal’s Algorithm A 7 B 13 C 1 10 97 66 21 D 12 5 F E Select the lowers edge on the graph.
Kruskal’s Algorithm A 7 B 13 C 1 10 97 66 21 D 12 5 F E Select the lowers edge on the graph. Select the second lowest edge (not necessarily adjacent to the one already chosen)
Kruskal’s Algorithm A 7 B 13 C 1 10 97 66 21 D 12 5 F E Select the lowers edge on the graph Select the second lowest edge (not necessarily adjacent to the one already chosen) Continue selecting the next lowest edge taking care not to create any circuits.
Kruskal’s Algorithm A 7 B 13 C 1 10 97 66 21 D 12 5 F E Select the lowers edge on the graph Select the second lowest edge (not necessarily adjacent to the one already chosen) Continue selecting the next lowest edge taking care not to create any circuits. Stop when there is a path to every vertex.
Kruskal’s Algorithm A 7 B 13 C 1 10 97 66 21 D 12 5 F E A 7 B 13 1 C Cost =38 D 12 Select the lowers edge on the graph Select the second lowest edge (not necessarily adjacent to the one already chosen) Continue selecting the next lowest edge taking care not to create any circuits. Stop when there is a path to every vertex. Copy the min – cost spanning tree below the graph. 5 F E
Irrigation System Bougainvillea Juniper 75 • Try to find the minimum – cost spanning tree yourself, then go to the next slide and check your answer. 37 47 Jasmine 26 42 25 35 11 Orchid 29 24 61 Azalea (problem 28 p.971) Lucille wants to install an irrigation system to water all six of her flowerbeds. Use Kruskal’s algorithm to find the smallest length of pipes she would need to install. Passion Flower
Irrigation System Bougainvillea • Note that we do not select the edge Jasmine – Azalea (35) since selecting that edge would create a redundancy in the solution (two ways to get water to Azaleas). Juniper 37 Jasmine 26 11 Orchid 29 24 Azalea Passion Flower (problem 28 p.971) The smallest length of pipes she can use is .