aqr unit 7-wk2-packet3balgie.weebly.com/uploads/2/2/9/2/22922006/aqr_unit_7-wk... · 2019. 12....
TRANSCRIPT
-
AQR UNIT 7
NETWORKS AND GRAPHS:
Spanning Trees
Packet #3
BY:_____________________
-
Cycles:
_________________________________________________________________________________________________________________ SpanningTrees:
Designamoreefficientnetworkandindicatehowmanylengthsofcableareused.
Writeasetofstep-by-stepinstructionstoformanalgorithmforconvertinganinefficientnetworkintoanefficientnetwork.
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 6: High-speed Internet
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 6, 5 pages
VII-54
3. Compare your efficient network with others in the class.
a. Did everyone use the same number of cable lengths?
Yes. Every efficient network only needs four lengths of cable (edges). If students used a different number of cable lengths, encourage them to compare with a partner who used four lengths of cable and discuss why only four are needed.
b. Did everyone’s network have the same shape?
No. Different shapes are possible. 4. A cycle in a graph is a path that starts and ends at the same vertex and does not use any
edge more than once.
a. Identify two cycles in the graph from Question 1.
There are many cycles in this graph. The following are examples:
Cycle 1 Cycle 2
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 6: High-speed Internet
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010) Activity Sheet 6, 5 pages
VII-53
Your company must run Ethernet cables to five different offices so that all five offices have high-speed Internet access. For each computer to be on the office network, there must be a way to get from each computer to the other computers by following the cable.
1. One worker proposed running cable between the five offices as illustrated in the following diagram. The vertices represent the offices, and the edges represent segments of cable.
How many lengths of cable (edges) are used? Explain why this an inefficient way to run the cable.
Eight lengths of cable are used in this network. This is inefficient because the office in the upper left, for example, is connected to the office in the lower right in more than one way, thereby using more cable than necessary.
2. Design a more efficient network and indicate how many lengths of cable are used.
Two possible solutions are shown below. Each uses four lengths of cable.
Solution 1 Solution 2
-
Mathematicallyspeakingtreesareaspecialclassofagraph.TherelationshipofatreestoagraphisveryimportantinsolvingmanyproblemsinMathandComputerScience.
Drawyourownspanningtreewith6verticesandasmanyedgesasneeded.
__________________________________________________________________________________________________________________WeightedSpanningTrees:
Createagraphtomodelthecostscontainedinthetable.
115
JJIIJI
Back
Close
Definition 2.27 (Tree).
A tree T is a connected graph that has no cycles.
Example 2.16 (Simple Trees).
1
1
116
JJIIJI
Back
Close
Theorem 2.28 (Equivalent definitions of a tree).
Let T be a graph with n vertices.
Then the following statetments are equivalent.
• T is connected and has no cycles.• T has n� 1 edges and has no cycles.• T is connected and has n� 1 eges.• T is connected and the removal of any edge disconnects T .• Any two vertices of T are connected by exactly one path.• T contains no cycles, but the additon of any new edge creates a cycle.
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 7: Minimal Spanning Trees
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 7, 4 pages
VII-58
A railroad system connecting five cities is being planned. The goal is to build this system
using the least amount of money, while ensuring that each city can be reached by any other
city in the system. Based on the distance and terrain, the following chart gives estimates for
the cost, in hundreds of thousands of dollars, to build a railroad between any two cities.
City A City B City C City D City E
City A 10 5 4 2
City B 7 9 11
City C 5 10
City D 12
1. Create a graph to model the costs contained in the table.
These relationships can be depicted in more than one way, and it is fine to use edges that are curved. The edges should be labeled with the correct weight (dollar figure) obtained from the table.
2. Restate the railroad problem using the terminology associated with graphs (for example,
vertices, edges, paths, cycles).
Remove edges from the graph in such a way that the graph stays connected and the sum of the final edges is minimal.
10 7
5
12
2
11 5
9 10 4
A
B
C
D E
-
Constructtwodifferentgraphsthatrepresentpossiblerailroadnetworks,andcalculatethetotalcosttobuildeachrailsystem.__________________________________________________________________________________________________________________MinimalSpanningTree:Thenumbersinthefollowinggraphsdepictthecostassociatedwithbuildingarailroadbetweencitiesrepresentedbyvertices.Forthegraph,testyouralgorithm.Doesityieldthemostefficientnetwork?Ifnot,trymodifyingyouralgorithm.
__________________________________________________________________________________________________________________MinimalSpanningTreeAlgorithm:
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 7: Minimal Spanning Trees
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 7, 4 pages
VII-60
5. How did you arrive at the most efficient rail system? State your answer in a step-by-step algorithm that someone else could follow.
Solutions will vary.
Sample Solution 1
Step 1: Delete the edge with the highest value.
Step 2: Repeat Step 1 unless that leaves a city disconnected. Try deleting the second highest value.
Sample Solution 2
Step 1: Find an edge with the smallest value and keep it (unless keeping it creates a cycle).
Step 2: Repeat Step 1, keeping the edges with the smallest values associated with them unless that creates a cycle.
6. The numbers in the following graphs depict the cost associated with building a railroad
between cities represented by vertices. For each graph, test your algorithm. Does it yield the most efficient network? If not, try modifying your algorithm.
Network I Network II
Solutions will vary depending on the algorithm from Question 5. Any correct algorithm produces the most efficient network that has the following total cost:
• Network I has a minimum total cost of 16. • Network II has a minimum total cost of 20.
2 7
9
5
4
4 6
8 5 8
10 7
9
5
8
4 6
8 5 6
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 8: Kruskal’s Algorithm
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 8, 5 pages
VII-62
A graph whose edges are given numerical values is called a weighted graph. Keeping all the vertices connected by a path resulting in a minimum total weight is called finding a minimal spanning tree. The word spanning means that each vertex remains connected to the graph, and the word tree indicates that there are no cycles.
The following procedure, known as Kruskal’s Algorithm, can be used to find a minimal
spanning tree in a weighted graph.
Kruskal’s Algorithm
Assume that you start with a table of the weights associated with each
edge (just like the Railroad problem in Student Activity Sheet 7).
Step 1: Put all of the weights in a list from smallest to largest.
Step 2: Find the smallest weight in the list and include the associated
edge and two vertices, as long as that does not create a cycle.
Step 3: Remove this weight from the list.
Step 4: Repeat Steps 2 and 3 until all vertices are connected.
-
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 8: Kruskal’s Algorithm
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 8, 5 pages
VII-62
A graph whose edges are given numerical values is called a weighted graph. Keeping all the vertices connected by a path resulting in a minimum total weight is called finding a minimal spanning tree. The word spanning means that each vertex remains connected to the graph, and the word tree indicates that there are no cycles.
The following procedure, known as Kruskal’s Algorithm, can be used to find a minimal
spanning tree in a weighted graph.
Kruskal’s Algorithm
Assume that you start with a table of the weights associated with each
edge (just like the Railroad problem in Student Activity Sheet 7).
Step 1: Put all of the weights in a list from smallest to largest.
Step 2: Find the smallest weight in the list and include the associated
edge and two vertices, as long as that does not create a cycle.
Step 3: Remove this weight from the list.
Step 4: Repeat Steps 2 and 3 until all vertices are connected.
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 8: Kruskal’s Algorithm
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 8, 5 pages
VII-63
1. A series of bridges will be constructed to connect a group of seven islands. The highway
department wants to make sure that a vehicle can be driven from one island to the
others in this new network of bridges. The cost of building a bridge is directly
proportional to the length of the bridge. The following table provides the distances
in miles between each pair of islands.
Island A Island B Island C Island D Island E Island F Island G
Island A 10 8 8 7 10 9
Island B 4 9 13 3 7
Island C 12 11 5 9
Island D 9 10 6
Island E 6 11
Island F 8
Use Kruskal’s Algorithm to determine which islands should be connected by bridges. Draw
a graph that represents the seven islands with the bridges that will be constructed.
I. The smallest weight is 3, so add the bridge between Islands B and F and remove 3 from the list.
II. The smallest weight is now 4, so add the bridge between Islands B and C and remove this weight from the list.
III. The smallest weight is now 5. If a bridge is added from Island C to Island F, this creates a cycle (BCFB). Therefore, do not add the bridge, but remove it from the list.
IV. There are two edges with a weight of 6 (Island D to Island G and Island E to Island F). Since neither creates a cycle, pick either one (say Island D to Island G).
V. Add the other edge with a weight of 6 (Island E to Island F). VI. There are two edges with a weight of 7. Pick either one. VII. Add the other edge of a weight of 7. VIII. Stop. (See the resulting network of bridges on the next page.)
-
__________________________________________________________________________________________________________________Prim’sAlgorithm:Algorithmtofindaminimumspanningtreeinaconnectedgraph.
STARTwithalltheverticesofaweightedgraph.Step1:Chooseanddrawanyvertex.Step2:Findtheedgeofleastweightjoiningadrawnvertextoavertexnotcurrentlydrawn.Drawthisweightededgeandthecorrespondingnewvertex.REPEATStep2untilalltheverticesareconnected,thenSTOP.
AttemptPrim’sAlgorithmwiththebridgeandislandproblemabove.__________________________________________________________________________________________________________________Follow-upQuestions:1)Whatdoestheexistenceofcyclestellyouabouttheefficiencyofanetwork?2)REFLECTION:DescribehowacycleissimilartoanEulercircuitandhowitisdifferent.3)Restatetherailroadproblemusingtheterminologyassociatedwithgraphs(forexample,vertices,edges,paths,cycles).4)Howdidyouarriveatthemostefficientrailsystem?Stateyouranswerinastep-by-stepalgorithmthatsomeoneelsecouldfollow.5)REFLECTION:Givenanyweightedgraph(liketheonesfromthisactivity),doesanefficientnetworkofminimalcostalwaysexist?Whyorwhynot?
-
6)REFLECTION:Doallgraphshavespanningtrees?Arespanningtreesunique?__________________________________________________________________________________________________________________Problems:1)Applyyouralgorithmtothefollowinginefficientnetworkandindicatethenumberofedgesinthefinalefficientnetwork.Listoutallofthesteps/decisionsyoumadeforthealgorithm.
2)Drawoutasmanyspanningtreesasyoucanfind.
3)
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 6: High-speed Internet
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 6, 5 pages
VII-56
7. Have another student apply your algorithm to the following inefficient network and indicate the number of edges in the final efficient network.
Answers will vary. The following is a sample solution:
There are two other ways to break this cycle and many other cycles to start with. Thus, following this algorithm means making choices that affect the shape of the final network.
• Remove Edge A to break Cycle ABC. • Remove Edge K to break Cycle BKI. • Remove Edge J to break Cycle HIJ. • Remove Edge G to break Cycle DHG. • Remove Edge F to break Cycle FCD. • Remove Edge C to break Cycle CHE. • Stop, because there are no more cycles. This process results in the following:
A B
C
D E
F
G
H
I
J
K
B
D E H
I
Spanning Trees
Spanning Trees: A subgraph of a undirected graphis a spanning tree of if it is a tree and
contains every vertex of .
Example:
a b
cd
e
a b
cd
e
a b
cd
e
a b
cd
e
Graph spanning tree 1
spanning tree 2 spanning tree 3
2
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 7: Minimal Spanning Trees
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 7, 4 pages
VII-60
5. How did you arrive at the most efficient rail system? State your answer in a step-by-step algorithm that someone else could follow.
Solutions will vary.
Sample Solution 1
Step 1: Delete the edge with the highest value.
Step 2: Repeat Step 1 unless that leaves a city disconnected. Try deleting the second highest value.
Sample Solution 2
Step 1: Find an edge with the smallest value and keep it (unless keeping it creates a cycle).
Step 2: Repeat Step 1, keeping the edges with the smallest values associated with them unless that creates a cycle.
6. The numbers in the following graphs depict the cost associated with building a railroad
between cities represented by vertices. For each graph, test your algorithm. Does it yield the most efficient network? If not, try modifying your algorithm.
Network I Network II
Solutions will vary depending on the algorithm from Question 5. Any correct algorithm produces the most efficient network that has the following total cost:
• Network I has a minimum total cost of 16. • Network II has a minimum total cost of 20.
2 7
9
5
4
4 6
8 5 8
10 7
9
5
8
4 6
8 5 6
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 7: Minimal Spanning Trees
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 7, 4 pages
VII-60
5. How did you arrive at the most efficient rail system? State your answer in a step-by-step algorithm that someone else could follow.
Solutions will vary.
Sample Solution 1
Step 1: Delete the edge with the highest value.
Step 2: Repeat Step 1 unless that leaves a city disconnected. Try deleting the second highest value.
Sample Solution 2
Step 1: Find an edge with the smallest value and keep it (unless keeping it creates a cycle).
Step 2: Repeat Step 1, keeping the edges with the smallest values associated with them unless that creates a cycle.
6. The numbers in the following graphs depict the cost associated with building a railroad
between cities represented by vertices. For each graph, test your algorithm. Does it yield the most efficient network? If not, try modifying your algorithm.
Network I Network II
Solutions will vary depending on the algorithm from Question 5. Any correct algorithm produces the most efficient network that has the following total cost:
• Network I has a minimum total cost of 16. • Network II has a minimum total cost of 20.
2 7
9
5
4
4 6
8 5 8
10 7
9
5
8
4 6
8 5 6
-
4)
5)
6)UsePrim’sAlgorithmtofindtheminimalspanningtreeinthefollowinggraph.
143
JJIIJI
Back
Close
Minimum Connector Problem (2)
The minimum connector problem can now be stated as follows:
Given a weighted graph G, find a minimum spanning tree.
Problem 2.20 (Minimum Connector Problem).Find the minimum spanning tree of the following graph:
A
E B
D C
6
48
2
58
6
9
47
1
Teacher Version
Networks and Graphs: Spanning Trees
VII.B Student Activity Sheet 8: Kruskal’s Algorithm
Charles A. Dana Center at The University of Texas at Austin
Advanced Mathematical Decision Making (2010)
Activity Sheet 8, 5 pages
VII-65
2. Use Kruskal’s Algorithm to find a minimal spanning tree in the following graph.
The resulting minimal spanning tree is as follows:
8
6
5
5 4
9
8
6 10
10 12
7 8
5
6
5 4 Prim’s Algorithm
Prim’s Example – Continued
b
c
d
e
f
g
4
8
98
2
1
9
7
10
5
6
2
c
d
e
f
g
8
9
10
8
2
1
7
95
6
2
a
a
Step 1.1
Step 1.1 after4
S={a}
S={a,b}b
before
V \ S = {b,c,d,e,f,g}
V \ S = {c,d,e,f,g}
lightest edge = {a,b}
lightest edge = {b,d}, {a,c}
A={}
A={{a,b}}
18