Upload
allyson-sims
View
222
Download
0
Embed Size (px)
Citation preview
Chapter 14 Section 4 - Slide 1Copyright © 2009 Pearson Education, Inc.
AND
Copyright © 2009 Pearson Education, Inc. Chapter 14 Section 4 - Slide 2
Chapter 14
Graph Theory
Chapter 14 Section 4 - Slide 3Copyright © 2009 Pearson Education, Inc.
WHAT YOU WILL LEARN
• Graphs, paths and circuits• The Königsberg bridge problem• Euler paths and Euler circuits• Hamilton paths and Hamilton
circuits• Traveling salesman problem• Brute force method
Chapter 14 Section 4 - Slide 4Copyright © 2009 Pearson Education, Inc.
WHAT YOU WILL LEARN
• Nearest neighbor method• Trees, spanning trees, and
minimum-cost spanning trees
Copyright © 2009 Pearson Education, Inc. Chapter 14 Section 4 - Slide 5
Section 4
Trees
Chapter 14 Section 4 - Slide 6Copyright © 2009 Pearson Education, Inc.
Definitions
A tree is a connected graph in which each edge is a bridge.
A spanning tree is a tree that is created from another graph by removing edges while still maintaining a path to each vertex.
Chapter 14 Section 4 - Slide 7Copyright © 2009 Pearson Education, Inc.
Examples
Graphs that are trees. Graph that are not trees.
Chapter 14 Section 4 - Slide 8Copyright © 2009 Pearson Education, Inc.
Example: Determining Spanning Trees
Determine two different spanning trees for the graph shown.
A
B
C
E F H
D G
A
B
C
E F H
D G A
B
C
E F H
D G
Chapter 14 Section 4 - Slide 9Copyright © 2009 Pearson Education, Inc.
Minimum-cost spanning tree
A minimum cost spanning tree is the least expensive spanning tree of all spanning trees under consideration.
Chapter 14 Section 4 - Slide 10Copyright © 2009 Pearson Education, Inc.
Kruskal’s Algorithm
To construct the minimum-cost spanning tree from a weighted graph:1. Select the lowest-cost edge on the graph.2. Select the next lowest-cost edge that does not
form a circuit with the first edge.3. Select the next lowest-cost edge that does not
form a circuit with the previously selected edges.4. Continue selecting the lowest-cost edges that do
not form circuits with the previously selected edges.
5. When a spanning tree is complete, you have the minimum-cost spanning tree.
Chapter 14 Section 4 - Slide 11Copyright © 2009 Pearson Education, Inc.
Example: Kruskal’s Algorithm
Use Kruskal’s algorithm to determine the minimum spanning tree for the weighted graph shown. The numbers along the edges represent dollars.
A
B
C
G
D
E
F
12
11
10 5
22
14
4
17
22
18
Chapter 14 Section 4 - Slide 12Copyright © 2009 Pearson Education, Inc.
Solution
Pick the lowest-cost edge of the graph, edge CD which is $4.
Next we select the next lowest-cost edge that does not form a circuit; we select edge CG which is $5.
A
B
C
G
D
E
F
12
11
10 5
22
14
4
17
22
18
Chapter 14 Section 4 - Slide 13Copyright © 2009 Pearson Education, Inc.
Solution (continued)
Continue selecting edges, being careful not to form a circuit.
The total cost would be
$12 + $10 + $5 + $14 +$18 + $4 = $63.
A
B
C
G
D
E
F
12
11
10 5
22
14
4
17
22
18