Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.

Similar presentations


Presentation on theme: "Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND."— Presentation transcript:

1 Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND

2 Copyright © 2009 Pearson Education, Inc. Chapter 14 Section 3 - Slide 2 Chapter 14 Graph Theory

3 Chapter 14 Section 3 - Slide 3 Copyright © 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

4 Copyright © 2009 Pearson Education, Inc. Chapter 14 Section 3 - Slide 4 Section 3 Hamilton Paths and Hamilton Circuits

5 Chapter 14 Section 3 - Slide 5 Copyright © 2009 Pearson Education, Inc. Definitions A Hamilton path is a path that contains each vertex of a graph exactly once. A Hamilton circuit is a path that begins and ends at the same vertex and passes through all other vertices of the graph exactly one time.

6 Chapter 14 Section 3 - Slide 6 Copyright © 2009 Pearson Education, Inc. Example: Hamilton Path Graph (a) shown has Hamilton path A, B, C, E, D. The graph also has Hamilton path C, B, A, D, E. Can you find some others? Graph (b) shown has Hamilton path A, B, C, F, H, E, G, D. The graph also has Hamilton path G, D, E, H, F, C, B, A. Can you find some others?

7 Chapter 14 Section 3 - Slide 7 Copyright © 2009 Pearson Education, Inc. Example: Hamilton Circuit Graph (a) shown has Hamilton circuit A, B, D, G, E, H, F, C, A. A Hamilton circuit starts and ends at the same vertex. Graph (b) shown has Hamilton circuit A, B, C, E, D, A. Can you find another?

8 Chapter 14 Section 3 - Slide 8 Copyright © 2009 Pearson Education, Inc. Definition A complete graph is a graph that has an edge between each pair of its vertices.

9 Chapter 14 Section 3 - Slide 9 Copyright © 2009 Pearson Education, Inc. Example: Finding Hamilton Circuits Determine a Hamilton circuit for the graph shown. One solution is A, G, F, E, C, D, B, A A B C E F G D

10 Chapter 14 Section 3 - Slide 10 Copyright © 2009 Pearson Education, Inc. Number of Unique Hamilton Circuits in a Complete Graph The number of unique Hamilton circuits in a complete graph with n vertices is (n  1)!, where (n  1)! = (n  1)(n  2)(n  3)…(3)(2)(1)

11 Chapter 14 Section 3 - Slide 11 Copyright © 2009 Pearson Education, Inc. Example: Number of Hamilton Circuits How many unique Hamilton circuits are there in a complete graph with the following number of vertices? a) 4b) 9 a) 4 = (4  1)! = 321 = 6 b) 9 = (9  1)! = 87654321 = 40,320

12 Chapter 14 Section 3 - Slide 12 Copyright © 2009 Pearson Education, Inc. The Brute Force Method of Solving Traveling Salesman Problems To determine the optimal solution: 1.Represent the problem with a complete, weighted graph. 2.List all possible Hamilton circuits for this graph. 3.Determine the cost (or distance) associated with each of these Hamilton circuits. 4.The Hamilton circuit with the lowest cost (or shortest distance) is the optimal solution.

13 Chapter 14 Section 3 - Slide 13 Copyright © 2009 Pearson Education, Inc. Example: Brute Force Method Find a minimum Hamilton circuit for the complete, weighted graph shown. List all the Hamilton circuits. Since there are 4 vertices there are (4  1)! = 3! = 6 possible circuits. AB CD 6 12 8 2 2 6

14 Chapter 14 Section 3 - Slide 14 Copyright © 2009 Pearson Education, Inc. Example: Brute Force Method continued 2661262 A, D, C, B, A 2421282 A, D, B, C, A 226862 A, C, D, B, A 2 2 2 Fourth Leg 248122 A, C, B, D, A 22686 A, B, D, C, A 266126 A, B, C, D, A Total Third Leg Second Leg First Leg Circuit The minimum amount for the graph would be 22. AB CD 6 12 8 2 2 6

15 Chapter 14 Section 3 - Slide 15 Copyright © 2009 Pearson Education, Inc. Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem To approximate a optimal solution: 1. Represent the problem with a complete, weighted graph. 2.Identify the starting vertex. 3.Of all the edges attached to the starting vertex, choose the edge that has the smallest weight. This edge is generally either the shortest distance or the lowest cost. Travel along this edge to the second vertex.

16 Chapter 14 Section 3 - Slide 16 Copyright © 2009 Pearson Education, Inc. Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem (continued) 4.At the second vertex, choose the edge that has the smallest weight that does not lead to a vertex already visited. Travel along this edge to the third vertex. 5.Continue this process, each time moving along the edge with the smallest weight until all vertices are visited. 6.Travel back to the original vertex.

17 Chapter 14 Section 3 - Slide 17 Copyright © 2009 Pearson Education, Inc. Example: Nearest Neighbor An appliance repair man must repair four appliances at the locations shown in the graph on the next slide. The estimated travel time (in minutes) is shown between the four locations. The repair man wants to visit the four locations in an order that takes the least amount of time. Use the nearest neighbor algorithm to find an approximate solution to the problem.

18 Chapter 14 Section 3 - Slide 18 Copyright © 2009 Pearson Education, Inc. Example: Nearest Neighbor (continued) Choose a starting vertex. Let’s choose vertex A. Choose the edge that has the smallest weight. Either AD or AB, lets choose AD (8). At D choose the edge that has the smallest weight DE (4). E start here 2 nd vertex C B A D 188 13 4 7 6 9 7 3 8

19 Chapter 14 Section 3 - Slide 19 Copyright © 2009 Pearson Education, Inc. Example: Nearest Neighbor (continued) Continue moving along the edge with the smallest weight. Circuit would be: A, D, E, B, C, A 8 + 4 + 3 + 9 + 13 = 37 This route would take about 37 minutes. start here 2 nd vertex C B A E D 188 13 4 7 6 9 7 3 8

20 Chapter 14 Section 3 - Slide 20 Copyright © 2009 Pearson Education, Inc. Example: Nearest Neighbor (continued) Other circuits and weights. 3 + 7 + 6 + 13 + 18 = 47E, B, D, C, A, EE 4 + 3 + 8 + 13 + 6 = 34 D, E, B, A, C, D D 6 + 4 + 3 + 8 + 13 = 34 C, D, E, B, A, C C 3 + 4 + 6 + 13 + 8 = 34B, E, D, C, A, BB Total WeightCircuitStarting Vertex


Download ppt "Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND."

Similar presentations


Ads by Google