36
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.3 Hamilton Paths, and Hamilton Circuits

Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.3 Hamilton Paths, and Hamilton Circuits

Embed Size (px)

Citation preview

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Section 14.3

Hamilton Paths, and Hamilton Circuits

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

What You Will Learn

Hamilton PathsHamilton CircuitsComplete GraphsTraveling Salesman Problems

14.3-2

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Hamilton Paths

A Hamilton path is a path that contains each vertex of a graph exactly once.

14.3-3

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Hamilton PathsThe 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?

14.3-4

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Hamilton PathsThe 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 findsome others?

14.3-5

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

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.

14.3-6

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Hamilton CircuitsThe graph shown has Hamilton circuit A, B, C, E, D, A. Can you find another?

14.3-7

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Hamilton CircuitsThe graph shown has Hamilton circuit A, B, D, G, E, H, F, C, A. A Hamilton circuitstarts and ends atthe same vertex.

14.3-8

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Complete Graph

A complete graph is a graph that has an edge between each pair of its vertices.

14.3-9

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

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

SolutionOne is:A, B, C, D, E, AThere are many more.

14.3-10

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Number of Unique Hamilton Circuits in a Complete GraphThe 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)

14.3-11

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 4: American Idol TravelSteven Tyler, Jennifer Lopez, and Randy Jackson, the judges for 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 Steven, Jennifer, and Randy, traveling together, visit each of these cities and return to Hollywood?

14.3-12

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 4: American Idol TravelSolutionRepresent this problem with the complete graph.6 vertices representthe 6 locations.Edges represent theone-way flightsbetween theselocations.

14.3-13

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 4: American Idol TravelSolutionDetermine the number of Hamilton circuits.There are (6 – 1)!= 5! = 5•4•3•2•1= 120 differentHamilton circuits.There are 120 waysto start in Hollywood,visit the 5 cities andreturn to Hollywood.

14.3-14

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Traveling Salesman ProblemsComplete 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.

14.3-15

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Traveling Salesman ProblemsThe 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.

14.3-16

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

The Brute Force Method of Solving Traveling Salesman ProblemsTo 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.

14.3-17

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force MethodJulienne Ward is the Southeast District Sales Director for Addison Wesley. On the next slide is a complete, weighted graph, whose numbers represent one-way fares, in dollars, between the cities. We want to use the brute force method to determine the optimal solution for Julienne to visit her regional sales offices.

14.3-18

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force MethodShe will start in Orlando (O); visit offices in Atlanta (A), Memphis (M), and New Orleans (N); and then return to Orlando.

14.3-19

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force MethodSolutionThere are (4 – 1)! = 3! = 6 possible unique Hamilton circuits we need to examine for costs.We list theseHamilton circuitsin the table on thenext slide.

14.3-20

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force Method

14.3-21

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force MethodSolutionHamilton 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, $289.These two Hamilton circuits are shown on the maps on the next slide.

14.3-22

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force Method

14.3-23

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 5: Using the Brute Force MethodSolutionThe 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 Julienne with the least expensive way to visit each of her regional sales offices.

14.3-24

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

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.

14.3-25

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman ProblemTo approximate a optimal

solution:

1. Represent the problem with a complete, weighted graph.

2.Identify the starting vertex.14.3-26

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem3.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.

14.3-27

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem4.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.

14.3-28

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem5.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.

14.3-29

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodIn Example 4, we discussed the American Idol judges’ 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 per person flight prices between cities are given in the table on the next slide.

14.3-30

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor Method

14.3-31

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodSolutionHere’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.

14.3-32

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodSolutionH to S, $108S to SA, $119SA to B, $274B to ER, $258ER to M, $104M to H, $144Total cost is $1007.

14.3-33

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodSolutionFor comparison, here are 4 randomly chosen Hamilton circuits with costs.

14.3-34

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodSolutionFrom the table, we see that the Hamilton circuit H, ER, M, B, S, SA, H results in a per 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.

14.3-35

Copyright 2013, 2010, 2007, Pearson, Education, Inc.

Example 6: Using the Nearest Neighbor MethodSolutionThe 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.

14.3-36