Section 13 3 Hamilton Paths and Hamilton Circuits

  • Slides: 36
Download presentation
Section 13. 3 Hamilton Paths and Hamilton Circuits 13. 3 -1 Copyright 2017, 2013,

Section 13. 3 Hamilton Paths and Hamilton Circuits 13. 3 -1 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

What You Will Learn Upon completion of this section, you will be able to:

What You Will Learn Upon completion of this section, you will be able to: • Understand Hamilton paths, Hamilton circuits, and complete graphs. • Solve traveling salesman problems. 13. 3 -2 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Paths A Hamilton path is a path that contains each vertex of a

Hamilton Paths A Hamilton path is a path that contains each vertex of a graph exactly once. 13. 3 -3 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Paths The graph shown has Hamilton path A, B, C, E, D. The

Hamilton Paths The graph 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? 13. 3 -4 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Paths The graph shown has Hamilton path A, B, C, F, H, E,

Hamilton Paths The graph 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? 13. 3 -5 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Circuits A Hamilton circuit is a path that begins and ends at the

Hamilton Circuits 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. 13. 3 -6 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Circuits The graph shown has Hamilton circuit A, B, C, E, D, A.

Hamilton Circuits The graph shown has Hamilton circuit A, B, C, E, D, A. Can you find another? 13. 3 -7 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Hamilton Circuits The graph shown has Hamilton circuit A, B, D, G, E, H,

Hamilton Circuits The graph shown has Hamilton circuit A, B, D, G, E, H, F, C, A. A Hamilton circuit starts and ends at the same vertex. 13. 3 -8 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Complete Graph A complete graph is a graph that has an edge between each

Complete Graph A complete graph is a graph that has an edge between each pair of its vertices. 13. 3 -9 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 2: Finding Hamilton Circuits Determine a Hamilton circuit for the complete graph shown.

Example 2: Finding Hamilton Circuits Determine a Hamilton circuit for the complete graph shown. Solution One is: A, B, C, D, E, A There are many more. 13. 3 -10 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Number of Unique Hamilton Circuits in a Complete Graph The number of unique Hamilton

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) 13. 3 -11 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 4: American Idol Travel Keith Urban, Jennifer Lopez, Harry Connick, Jr. , and

Example 4: American Idol Travel Keith Urban, Jennifer Lopez, Harry Connick, Jr. , and Ryan Seacrest, the cast of the television show American Idol, are in Hollywood (H). They need to travel to the following cities to judge contestants’ auditions: San Antonio (SA), East Rutherford (ER), Birmingham (B), Memphis (M), and Seattle (S). In how many different ways can the cast, traveling together, visit each of these cities and return to Hollywood? 13. 3 -12 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 4: American Idol Travel Solution Represent this problem with the complete graph. 6

Example 4: American Idol Travel Solution Represent this problem with the complete graph. 6 vertices represent the 6 locations. Edges represent the one-way flights between these locations. 13. 3 -13 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 4: American Idol Travel Solution Determine the number of Hamilton circuits. There are

Example 4: American Idol Travel Solution Determine the number of Hamilton circuits. There are (6 – 1)! = 5 • 4 • 3 • 2 • 1 = 120 different Hamilton circuits. There are 120 ways to start in Hollywood, visit the 5 cities and return to Hollywood. 13. 3 -14 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Traveling Salesman Problems Complete graphs can represent cities and the process of traveling between

Traveling Salesman Problems Complete graphs can represent cities and the process of traveling between these cities. • Our goal in a traveling salesman problem is to find the least expensive or shortest way to visit each city once and return home. • In terms of graph theory, our goal is to find the Hamilton circuit with the lowest associated cost or distance. • 13. 3 -15 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Traveling Salesman Problems The Hamilton circuit with the lowest associated cost (or shortest distance,

Traveling Salesman Problems The Hamilton circuit with the lowest associated cost (or shortest distance, etc. ) is called the optimal solution. • We will discuss two methods, the brute force method and the nearest neighbor method, for determining the optimal solution. • A complete, weighted graph is a complete graph with the weights (or numbers) listed on the edges. • 13. 3 -16 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

The Brute Force Method of Solving Traveling Salesman Problems To determine the optimal solution:

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. 3 -17 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method In Example 1 in your book, we

Example 5: Using the Brute Force Method In Example 1 in your book, we introduced Priya, the chief operating officer for Hard Rock Café International. We now want to use the brute force method to determine the optimal solution for Priya to start at her home in Orlando (O), visit restaurants in Atlanta (A), Memphis (M), and New Orleans (N), and then return to her home in Orlando. 13. 3 -18 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method She will start in Orlando (O); visit

Example 5: Using the Brute Force Method She will start in Orlando (O); visit offices in Atlanta (A), Memphis (M), and New Orleans (N); and then return to Orlando. 13. 3 -19 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method Solution There are (4 – 1)! =

Example 5: Using the Brute Force Method Solution There are (4 – 1)! = 3! = 6 possible unique Hamilton circuits we need to examine for costs. We list these Hamilton circuits in the table on the next slide. 13. 3 -20 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method 13. 3 -21 Copyright 2017, 2013, 2009,

Example 5: Using the Brute Force Method 13. 3 -21 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method Solution Hamilton circuits in column 1. Columns

Example 5: Using the Brute Force Method Solution Hamilton circuits in column 1. Columns 2 – 5 contain the cost associated with each leg of the circuit. Last column contains the total cost of travel using the given circuit. Two circuits have the lowest cost, $545. These two Hamilton circuits are shown on the maps on the next slide. 13. 3 -22 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method 13. 3 -23 Copyright 2017, 2013, 2009,

Example 5: Using the Brute Force Method 13. 3 -23 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 5: Using the Brute Force Method Solution • The second circuit is the

Example 5: Using the Brute Force Method Solution • The second circuit is the exact reverse order of the first circuit. • Although these are different circuits, the cost is the same regardless of the direction flown. • Either circuit provides Priya with the least expensive way to visit each city and return to her home in Orlando. 13. 3 -24 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Nearest Neighbor Method Now we introduce a method for finding an approximate solution to

Nearest Neighbor Method Now we introduce a method for finding an approximate solution to a traveling salesman problem. • Approximate solutions can be used in cases where determining the optimal solution is not reasonable. • One method for finding an approximate solution is the nearest neighbor method. • 13. 3 -25 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem To

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem To approximate the optimal solution: 1. Represent the problem with a complete, weighted graph. 2. Identify the starting vertex. 13. 3 -26 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 3.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 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. 13. 3 -27 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 4.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 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. 13. 3 -28 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 5.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem 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. 13. 3 -29 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method In Example 4, we discussed the American

Example 6: Using the Nearest Neighbor Method In Example 4, we discussed the American Idol cast’s plan to visit five cities in which auditions would take place and then return to Hollywood. Use the nearest neighbor method to determine an approximate solution for the judges’ visits. The one-way person flight prices between cities are given in the table on the next slide. 13. 3 -30 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method 13. 3 -31 Copyright 2017, 2013, 2009,

Example 6: Using the Nearest Neighbor Method 13. 3 -31 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method Solution Here’s the complete, weighted graph. Start

Example 6: Using the Nearest Neighbor Method Solution Here’s the complete, weighted graph. Start at H, go to S. From S, go to SA. From SA, go to B. From B, go to ER. From ER, go to M. From M, go to H. 13. 3 -32 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method Solution H to S, $108 S to

Example 6: Using the Nearest Neighbor Method Solution H to S, $108 S to SA, $119 SA to B, $274 B to ER, $258 ER to M, $104 M to H, $144 Total cost is $1007. 13. 3 -33 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method Solution For comparison, here are 4 randomly

Example 6: Using the Nearest Neighbor Method Solution For comparison, here are 4 randomly chosen Hamilton circuits with costs. 13. 3 -34 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method Solution From the table, we see that

Example 6: Using the Nearest Neighbor Method Solution From the table, we see that the Hamilton circuit H, ER, M, B, S, SA, H results in a person cost of $965, which is less than the $1007. Thus, we see that the nearest neighbor method does not always produce the optimal solution. 13. 3 -35 Copyright 2017, 2013, 2009, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method Solution The nearest neighbor method produces an

Example 6: Using the Nearest Neighbor Method Solution The nearest neighbor method produces an approximation for the optimal solution. Without using the brute force method, we cannot determine if the Hamilton circuit H, ER, M, B, S, SA, H is the optimal solution. 13. 3 -36 Copyright 2017, 2013, 2009, Pearson, Education, Inc.