100 likes | 163 Views
Minimum Spanning Trees. Standard ST1 Construct a minimum spanning tree for weighted and unweighted graphs. Minimizing costs. Suppose you want to supply a set of houses (say, in a new subdivision) with: electric power water sewage lines telephone lines
E N D
Minimum Spanning Trees Standard ST1 Construct a minimum spanning tree for weighted and unweighted graphs
Minimizing costs • Suppose you want to supply a set of houses (say, in a new subdivision) with: • electric power • water • sewage lines • telephone lines • To keep costs down, you could connect these houses with a spanning tree (of, for example, power lines) • However, the houses are not all equal distances apart • To reduce costs even further, you could connect the houses with a minimum-cost spanning tree
16 16 A B A B 6 6 21 11 11 5 5 19 F C F C 14 33 10 18 18 E D E D A connected, undirected graph A minimum-cost spanning tree Minimum-cost spanning trees • Suppose you have a connected undirected graph with a weight (or cost) associated with each edge • The cost of a spanning tree would be the sum of the costs of its edges • A minimum-cost spanning tree is a spanning tree that has the lowest cost
Kruskal’s algorithm • An algorithm for finding a graph's minimum spanning tree. • Sort the edges of a graph in order from smallest to largest. • Repeatedly add edges that bridge separate components until the graph is fully connected. • By sorting the weights for each edge largest to smallest, the algorithm can also be used to find a maximum spanning tree.
Use Kruskal’s algorithm to construct a minimum spanning tree.
The minimum spanning tree uses the edges 27+30+40+40+42 = 179
Use Kruskal’s algorithm to construct a minimum spanning tree.
The minimum spanning tree uses the edges 1+1+2+2+2+2+3+5 = 18