Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
As in many of the previous lessons, this lesson focuses on optimization.Problems and applications here center on two types of problems: findingways of connecting the vertices of a graph with the least number of edgesand finding ways of connecting them with the least number of edges thathave the smallest total weight.
Explore ThisIn making earthquake preparedness plans, the St. Charles Countygovernment needs a design for repairing the county roads in case of anemergency. Figure 5.17 is a map of the towns in the county and theexisting major roads between them. Devise a plan that repairs the leastnumber of roads but keeps a route open between each pair of towns.
Figure 5.17. The towns in St. Charles County.
Lesson 5.5St Charles County
Wentzville O'Fallon
New Melle
Peruque
St. Peters
Augusta
Orchard Farm
St. Charles
Harvester
Minimum SpanningTrees
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 263
264 Chapter 5 • More Graphs, Subgraphs, and Trees
Examine your graph. If it connects each of the towns (vertices) andhas no cycles, you’ve found a spanning tree. A spanning tree of aconnected graph G is a tree that is a subgraph of G and contains everyvertex of G. A spanning tree of the graph in Figure 5.17 would model theminimum number of roads (edges) needed to connect each town in caseof an emergency.
Compare your plan with the other plans developed in your class.They should all contain the same number of edges but not necessarily thesame edges. It is possible for a graph to have many different spanningtrees. And as you may have guessed, for a graph that is not connected, nospanning tree is possible.
One systematic way to find a spanning tree for a graph is to deletean edge from each cycle in the graph. Unfortunately, this is not an easyprocedure for a very large graph. But there are other ways of finding aspanning tree for a graph if one exists. One such method that can beeasily adapted to computers is called the breadth-first search algorithm.
Breadth-First Search Algorithm for Finding Spanning Trees1. Pick a starting vertex, S, and label it with a 0.
2. Find all vertices that are adjacent to S and label them with a 1.
3. For each vertex labeled with a 1, find an edge that connects itwith the vertex labeled 0. Darken those edges.
4. Look for unlabeled vertices adjacent to those with the label 1and label them 2. For each vertex labeled 2, find an edge thatconnects it with a vertex labeled 1. Darken that edge. If morethan one edge exists, choose one arbitrarily.
5. Continue this process until there are no more unlabeled verticesadjacent to labeled ones. If not all vertices of the graph arelabeled, then a spanning tree for the graph does not exist. If allvertices are labeled, the vertices and darkened edges are aspanning tree of the graph.
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 264
265Lesson 5.5 • Minimum Spanning Trees
ExampleUse the breadth-first search algorithm to find a spanning tree for thefollowing graph.
Solution:
As shown in the following figure, the algorithm begins by picking astarting vertex, calling it S, and labeling it with a 0. The labeling anddarkening of edges then proceed according to steps 2 through 5 of thealgorithm. As you probably noticed, this is not a unique solution. It is justone of the graph’s many spanning trees.
D G J
AC
F I
B E H
0
1 3B3
D G J
A
CS
F I2
2 1 3
22
E H
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 265
266 Chapter 5 • More Graphs, Subgraphs, and Trees
Many applications are best modeled with weighted graphs. Whenthis is the case, it is often not sufficient to find just any spanning tree, butto find one with minimal or maximal weight.
Return to the earthquake preparedness situation and reconsider theproblem when distances between towns are added to the graph (seeFigure 5.18).
Figure 5.18. Map of St. Charles County with mileage shown.
Refer back to your solution of the original problem and find the totalnumber of miles of road that would need to be repaired if your plan wereimplemented. Compare your plan with others in your class. Which planor plans yield the minimum number of miles?
Figure 5.19. Spanning tree of minimum weight for the towns in St. Charles County.
For this particular problem, the minimum possible number of miles ofroad is 66. A spanning tree with that total weight is shown in Figure 5.19.
A spanning tree of minimal weight is called a minimum spanningtree. One algorithm for finding a minimum spanning tree for a graph isknown as Kruskal’s algorithm. It was developed in 1956 and named afterits designer, Joseph B. Kruskal, a leading mathematician at BellLaboratories.
Wentzville O'Fallon
New Melle
Peruque
St. Peters
Augusta
Orchard Farm
St. Charles
Harvester
13
10
5
15
20
12
16
15
95
78
6
9
15
Wentzville O'Fallon
New Melle
Peruque
St. Peters
Augusta
Orchard Farm
St. Charles
Harvester
13
10
5
12
5
78
6
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 266
267Lesson 5.5 • Minimum Spanning Trees
ExampleUse Kruskal’s algorithm to find a minimumspanning tree for the following graph.
Solution:
There are five vertices in the graph, sofour edges must be chosen. List the edgesfrom shortest to longest. First on the list isAB (4). Darken it. Then darken AE (5). Thenext shortest edge is BE, but if picked, it willform a cycle. So pick EC (7). For the lastedge there are two edges of length 8. EitherCD or ED can be darkened. The darkenededges of the following graph form one of the minimumspanning trees of the graph. It has a minimal weight of 4 + 5 + 7 + 8 = 24.
Notice that both Kruskal’s and Dijkstra’s (Lesson 5.3)algorithms produce spanning trees. But unlike Dijkstra’sshortest path algorithm, which gives you a spanning tree of shortestpaths, Kruskal’s algorithm yields a spanning tree of minimal total weight.
Kruskal’s MinimumSpanning Tree Algorithm1. Examine the graph. If it is not
connected, there will be nominimum spanning tree.
2. List the edges in order fromshortest to longest. Ties arebroken arbitrarily.
3. Darken the first edge on the list.
4. Select the next edge on the list.If it does not form a cycle withthe darkened edges, darken it.
5. For a graph with n vertices,continue step 4 until n – 1 edgesof the graph have beendarkened. The vertices and thedarkened edges are a minimumspanning tree for the graph.
C
DE
A
B
5
4
6
7
8
9
9
8
10
List of Edges from Shortest to Longest
Edge Length
AB 4AE 5BE 6EC 7CD 8ED 8BD 9BC 9AC 10
5
4
7
8
8
C
DE
A
B
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 267
ExercisesIn Exercises 1 through 5, find a spanning tree for each graph if one exists.
1. 2.
3. 4.
5.
6. Draw a spanning tree for a K4 graph.
268 Chapter 5 • More Graphs, Subgraphs, and Trees
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 268
269Lesson 5.5 • Minimum Spanning Trees
7.
Sid began using the breadth-first search algorithm to try to find aspanning tree for the preceding graph. He began with vertex A,labeled it with a 0, and labeled B and C with 1s. He then darkenededges AB and AC, looked for vertices adjacent to the 1s, and selectedvertex D. He labeled it with a 2 and darkened edge BD.
a. Could Sid have darkened CD instead of BD?
Copy Sid’s graph and complete the search for Sid by answering thefollowing questions.
b. Which vertices receive 3s for labels? Label these vertices.
c. Which edges subsequently are darkened? Darken these edges.
d. Three vertices should belabeled 4. Which ones?Label these vertices anddarken the appropriateedges. Your graph couldlook like the one at right.
Continue the algorithm untilall vertices are labeled.Check your darkened edgesto make sure they form aspanning tree.
A
B
D
E F
GH
IJ
KL
C
1
A
B
D
E F
GH
J
K
C
0
I
L
1
2
0
1 4 3
L
1
2
3
4
4
A
B
D
E F
GH
IJ
K
C
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 269
270 Chapter 5 • More Graphs, Subgraphs, and Trees
8. Use the breadth-first search algorithm to find a spanning tree forthis graph. Begin at vertex A.
9. Use mathematical induction on the number of edges to prove thatevery connected graph has a spanning tree.
10. The breadth-first search algorithm can be applied to digraphs ifslight changes are made. Modify the algorithm on page 264 so thatit can be used with digraphs. Apply your modified breadth-firstsearch algorithm to the following digraph.
Use Kruskal’s algorithm to find a minimum spanning tree for the graphsin Exercises 11 through 14. What is the minimal weight in each case?
11. 12.
A
B
EFG
HI
J
C
D
A
B
FH
I
C
D
GE
A
B
D
4
33
5
64
C A
B
C
D
48
5
8
5
E
6
7
3
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 270
271Lesson 5.5 • Minimum Spanning Trees
13.
14.
15. The computers in each of the offices at Pattonville High Schoolneed to be linked by cable. The following map shows the cost ofeach link in hundreds of dollars. What is the minimum cost oflinking the five offices?
16. Suppose that the cable in Exercise 15 was installed by adisreputable firm that used only the most expensive links. Whatwould be the maximum cost for the four links?
17. How might Kruskal’s minimum spanning tree algorithm bemodified to make it a maximum spanning tree algorithm?
A B C D
E F G H
I J
K L M N
4 8 6
5 5 57
5
64
38
2
2
4
684
63
6
8
D
E
12 242
F
C 410
14 G
B
18
A
16
BA
D C
6
E
8
311
8
8
9
5
5
10
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 271
272 Chapter 5 • More Graphs, Subgraphs, and Trees
Another algorithm that can be used to find a minimum spanning tree isattributed to R. C. Prim, a mathematician at the Mathematics Center atBell Labs.
18. Use Prim’s algorithm to find a minimum spanning tree for thefollowing graph. What is the minimal weight?
19. Use Prim’s algorithm to find a minimum spanning tree for thefollowing graph. What is the minimal weight?
Prim’s Minimum Spanning Tree Algorithm1. Find the shortest edge of the graph. Darken it and circle its two
vertices. Ties are broken arbitrarily.
2. Find the shortest remaining undarkened edge having one circledvertex and one uncircled vertex. Darken this edge and circle itsuncircled vertex.
3. Repeat step 2 until all vertices are circled.
A
C
D
B
4
4
3
6
3
5
A
C
D
B4
8
8
6
3
5
E
7
5
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 272
273Lesson 5.5 • Minimum Spanning Trees
20. When the shortest path algorithm from Lesson 5.3 is applied untilall vertices of a graph are used, it yields a spanning tree of thegraph. Is it always a minimum spanning tree?
Check your answer to this question by doing the following.
a. Find a minimum spanning tree of the graph above using eitherKruskal’s or Prim’s algorithm. What is the total weight of theminimum spanning tree?
b. Find the shortest route from A to each of the other vertices usingthe shortest path algorithm (page 248). Give the lengths of eachof these routes.
c. Is the shortest route tree from A to each of the other vertices aminimum spanning tree of this graph? Explain why or why not.
21. Traveling salesperson problems, shortest route problems, andminimum spanning tree problems are often confused because eachtype of problem can be solved by finding a subgraph that includesall of the vertices of the graph. Compare and contrast what eachtype of problem asks and when each type of problem is used.
Project22. In this lesson, you have applied two of the three classical minimum
spanning tree algorithms, Kruskal’s and Prim’s. The thirdalgorithm of this group was designed by O. Boruvka. InvestigateBoruvka’s algorithm, learn to apply it, and report on how it differsfrom Kruskal’s and Prim’s algorithms.
B C
A
D
E
F
3 8
5
7
8
10
9
10 4
9
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 273
274 Chapter 5 • More Graphs, Subgraphs, and Trees
Splitting Terrorist Cells
Science News Online
How can you tell if enough members of aterrorist cell have been captured or killed sothere’s a high probability that the cell canno longer carry out an attack? Amathematical model of terroristorganizations might provide some clues. Thequestion is what sort of mathematical modelwould work best.
One way to describe a terrorist organizationis in terms of a graph. In this model, eachnode would represent an individual memberof a given cell, and a line linking two nodeswould indicate direct communicationbetween those two members.
In this hypothetical four-member cell, represented by agraph, Boromir,Celeborn, andDenethor communicatedirectly with eachother, but Aragorncommunicates onlywith Boromir.
When a cellmember is removed, the corresponding nodeis deleted from the graph. Deleting enoughnodes leads to disruption. Mathematically,you could ask the question: How many nodesmust you remove from a given graph beforeit splits into two or more separate pieces?
In this seven-member cell, removing A would have littleeffect on theorganization. RemovingE and G instead wouldsplit the cell into twounits that presumablywould be less effective ontheir own.
A graph model, however, may not be the bestone available for representing a typicalterrorist organization, mathematicianJonathan D. Farley of the MassachusettsInstitute of Technology contends.
Farley has proposed an alternative approachthat reflects an organization’s hierarchy.“My method uses order theory to quantifythe degree to which a terrorist network is stillable to function,” he says.
In this case, the relationship of oneindividual to another in a cell becomesimportant. Leaders are represented by thetopmost nodes in a diagram of the orderedset representing a cell and foot soldiers arenodes at the bottom. Disrupting theorganization would be equivalent todisrupting the chain of command, whichallows orders to pass from leaders to footsoldiers.
In this ordered-setrepresentation of a terroristcell, points representindividual members andlines show communicationlinks. Members A, B, and Care leaders and rankhigher than all othermembers. I, J, and K havethe lowest rank.
A given ordered set may have several suchchains of command that link a leader with afoot soldier. All of these chains must bebroken for a cell (or remnant) to beconsidered ineffective.
Farley’s model has several shortcomings. Lawenforcement often doesn’t know how aterrorist cell is organized or even its fullmembership. Nonetheless, Farley contends,“this model enables law enforcement to planits operations in less of an ad hoc fashionthan they might be able to do otherwise.”
Aragorn
Denethor
Celeborn
Boromir
A B C
E
D
G
F
A B C
KJ
F
D
I
G H
E
DM05_Final.qxp:DM05.qxp 5/12/14 8:35 AM Page 274