Download presentation
Presentation is loading. Please wait.
Published byQuentin Williamson Modified over 9 years ago
1
1 Chapter 15.3 Hamilton Paths and Hamilton Circuits Objectives 1.Understand the definitions of Hamilton paths & Hamilton circuits. 2.Find the number of Hamilton circuits in a complete graph. 3.Understand and use weighted graphs. 4.Use the Brute Force Method to solve traveling salesperson problems. 5.Use the Nearest Neighbor Method to approximate solutions to traveling salesperson problems.
2
2 Hamilton Paths & Hamilton Circuits A path that passes through each vertex of a graph exactly once is called a Hamilton path. If a Hamilton path begins and ends at the same vertex and passes through all other vertices exactly once, it is called a Hamilton circuit. Example: a.Find a Hamilton path for the graph. b.Find a Hamilton circuit for the graph.
3
3 Solution: a.A Hamilton path must pass through each vertex exactly once. The graph has many Hamilton paths. An example of such a path is A, B, C, D, E. b.A Hamilton circuit must pass through each vertex exactly once and begin and end at the same vertex. The graph has many Hamilton circuits. An example of such a path is A, B, C, D, E, A. Hamilton Paths & Hamilton Circuits
4
4 A complete graph is a graph that has an edge between each pair of its vertices. Hamilton Paths & Hamilton Circuits Not a complete graph because there are no edges for connecting the vertices A and D, and B and C. A complete graph because there are edges connecting the vertices A and D, and B and C.
5
5 The Number of Hamilton Circuits in a Complete Graph The number of Hamilton circuits in a complete graph with n vertices is (n – 1)! Example: In the graph, there are edges between each pair of vertices. Thus, the graph is complete and has a Hamilton circuit. One circuit is A, B, C, D, A. Any circuits that pass through the same vertices in the same order will be consid- ered be the same. For example,
6
6 In order to avoid duplication, in forming a Hamilton circuit, we can always assume that it begins at A. There are six different, or unique, Hamilton circuits for the graph because (n – 1)! = (4 – 1)! = 3! = 6. They are given as The Number of Hamilton Circuits in a Complete Graph Example Continued
7
7 Weighted Graphs A complete graph whose edges have numbers attached to them is called a weighted graph. The numbers shown along the edges if a weighted graph are called the weights of the edges. Example: The graph below is a model graph for one-way airfares for cities A, B, C, D. Use the weighted graph to find the cost of the trip for the Hamilton circuit A, B, D, C, A.
8
8 Solution: The trip described by the Hamilton circuit A, B, D, C, A involves the sum of the four costs: The cost of the trip is $648. Weighted Graphs Example Continued
9
9 Brute Force Method The Traveling Salesperson Problem The traveling salesperson problem is the problem of finding a Hamilton circuit in a complete weighted graph for which the sum of the weights of the edges is a minimum. –Such a Hamilton circuit is called the optimal Hamilton circuit or the optimal solution. One method for finding an optimal Hamilton circuit is called the Brute Force Method.
10
10 The optimal solution is found using the following steps: Model the problem with a complete, weighted graph. Make a list of all possible Hamilton circuits. Determine the sum of the weights of the edges for each of these Hamilton circuits. The Hamilton circuit with the minimum sum of weights is the optimal solution. Brute Force Method
11
11 Example: Use the previous weighted graph to find the optimal solution. Solution: The graph has four vertices. Thus, there are (n – 1)! = (4 – 1)! = 3! = 6 possible Hamilton circuits. The six possible Hamilton circuits and their total costs are given below. Brute Force Method Using the Brute Force Method
12
12 Brute Force Method Example Continued This indicates that two Hamilton circuits have the minimum cost of $562. The optimal solution is either A, C, B, D, A or A, D, B, C, A.
13
13 Although these are different Hamilton circuits the cost is the same regardless of the direction flown. Brute Force Method Example Continued
14
14 Nearest Neighbor Method The Nearest Neighbor Method is a method to approximate solutions to the traveling salesperson problems. The optimal solution can be approximated using the following steps: 1.Model the problem with a complete, weighted graph. 2.Identify the vertex that serves as the starting point. 3.From the starting point, choose an edge with the smallest weight. Move along this edge to the second vertex. 4.From the 2 nd vertex, choose the edge with the smallest weight that does not lead to a vertex already visited. Move along this edge to the third vertex. 5.Continue building the circuit, one vertex at a time, by moving along the edge with the smallest weight until all vertices are visited. 6.From the last vertex, return to the starting point.
15
15 Example: A sales director who lives in city A is required to fly to regional offices in cities B, C, D, and E. The weighted graph shown gives the one-way airfares. Use the Nearest Neighbor Method to find an approximate solution. What is the total cost. Solution: The Nearest Neighbor Method is carried out as follows. Start at A. Choose the edge with the smallest weight: 114. Move this edge along to C. Nearest Neighbor Method Using the Nearest Neighbor Method
16
16 From C choose the edge with the smallest weight that does not lead to A: 115. Move along this edge to E. From E, choose the edge with the smallest weight that does not lead to a city already visited: 194. Move along this edge to D. From D, there is little choice but to fly to B, the only city not visited yet. From B, close the circuit and return home to A. Nearest Neighbor Method Example Continued
17
17 An approximated solution is the Hamilton circuit A, C, E, D, B, A. The total cost is $114 + $115 + $194 + $145 + $180 = $748. Nearest Neighbor Method Example Continued
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.