910 likes | 969 Views
Excursions in Modern Mathematics Sixth Edition. Peter Tannenbaum. Chapter 6 The Traveling Salesman Problem. Hamilton Joins the Circuit. The Traveling Salesman Problem Outline/learning Objectives. To identify and model Hamilton circuit and Hamilton path problems.
E N D
Excursions in Modern MathematicsSixth Edition Peter Tannenbaum
Chapter 6The Traveling Salesman Problem Hamilton Joins the Circuit
The Traveling Salesman ProblemOutline/learning Objectives • To identify and model Hamilton circuit and Hamilton path problems. • To recognize complete graphs and state the number of Hamilton circuits that they have. • To identify traveling-salesman problems and the difficulties faced in solving them. • To implement brute-force, nearest-neighbor, repeated nearest-neighbor, and cheapest-link algorithms to find approximate solutions to traveling –salesman problems. • To recognize the difference between efficient and inefficient algorithms. • To recognize the difference between optimal and approximate algorithms.
The Traveling Salesman Problem 6.1 Hamilton Circuits and Hamilton Paths
Hamilton Circuits and Paths • Hamilton path A path that visits each vertex of the graph once and only once. • Hamilton circuit A circuit that visits each vertex of the graph once and only once (at the end, of course, the circuit must return to the starting vertex).
Hamilton Circuits and Paths • Dodecahedron
Hamilton Circuits and Paths • Herschel Graph • Smallest polyhedral that does not contain a Hamilton circuit.
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (b) shows a graph that has no Euler circuits but does have Euler paths (for example C, D, E, B, A, D), has no Hamilton circuits (sooner or later you have to go to C, and then you are stuck) but does have Hamilton paths (for example, A, B, E, D, C). Aha, a graph can have a Hamilton path but no Hamilton Circuit!
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (b) shows a graph that has no Euler circuits but does have Euler paths (for example C, D, E, B, A, D), has no Hamilton circuits (sooner or later you have to go to C, and then you are stuck) but does have Hamilton paths (for example, A, B, E, D, C). Aha, a graph can have a Hamilton path but no Hamilton Circuit!
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (c) shows a graph that has neither Euler circuits nor paths (it has four odd vertices), has Hamilton circuits (for example A, B, C, D, E, A– there are plenty more), and consequently has Hamilton paths (for example, A, B, C, D, E).
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (d) shows a graph that has Euler circuits (the vertices are all even), has no Hamilton circuits (no matter what, your are going to have to go through E more than once!) but has Hamilton paths (for example, A, B, E, D, C).
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (e) shows a graph that has no Euler circuits but has Euler paths (F and G are the two odd vertices), had neither Hamilton circuits nor Hamilton paths.
Hamilton Circuits and Paths Hamilton Circuit (Paths vs Euler Circuit Path) • Figure (f) shows a graph that has neither Euler circuits nor Euler paths (too many odd vertices), has neither Hamilton circuits nor Hamilton paths.
Hamilton Circuits and Paths • The lesson in the previous Example is that the existence of an Euler path or circuit in a graph tells us nothing about the existence of a Hamilton path or circuit in that graph. • This is important because it implies that Euler’s circuit and path theorems from Chapter 5 are useless when it comes to Hamilton circuits and paths.
Hamilton Circuits and Paths There are, however, nice theorems that identify special situations where a graph must have a Hamilton circuit. • This best known of these theorems is Dirac’s theorem: If a connected graph has N vertices (N > 2) and all of them have degree bigger or equal to N/2, then the graph has a Hamilton circuit.
The Traveling Salesman Problem 6.2 Complete Graphs
Complete Graphs If a graph has a Hamilton circuit, then how many different Hamilton circuits does a it have? A graph with N vertices in which every pair of distinct vertices is joined by an edge is called a complete graphon N vertices and denoted by the symbol KN.
Complete Graphs • Every vertex has a degree of N-1 • Therefor the sum of all the degrees are N(N-1) • Thus the number of edges is N(N-1)/2
Complete Graphs Number of Edges in KN • KN has N(N – 1)/2 edges. • Of all graphs with N vertices and no multiple edges or loops, KN has the most edges.
Complete Graphs Hamilton Circuits in K4 If we travel the four vertices of K4 in an arbitrary order, we get a Hamilton path. For example, C, A, D, B is a Hamilton path.
Complete Graphs Hamilton Circuits in K4 D, C, A, B is another Hamilton Path.
Complete Graphs Hamilton Circuits in K4 Each of these Hamilton paths can be closed into a Hamilton circuit-- the path C, A, D, B begets the circuit D, A, D, B, C.
Complete Graphs Hamilton Circuits in K4 The path D, C, A, B begets the circuit D, C, A, B, D.
Complete Graphs Hamilton Circuits in K4 It is important to remember that the same Hamilton circuit can be written in many ways.
Complete Graphs Hamilton Circuits in K4 For example, C, A, D, B, C is the same circuit as A, D, B, C, A– the only difference is that in the first case we used C as the reference point in the second case we used A.
Complete Graphs Number of Hamilton Circuits in KN There are (N – 1)! Distinct Hamilton circuits in KN.
The Traveling Salesman Problem 6.3 Traveling Salesman Problems
The Traveling Salesman Problem The “traveling salesman” is a convenient metaphor for many different important real-life applications, all involving Hamilton circuits in complete graphs but only occasionally involving salespeople.
The Traveling Salesman Problem Any graph whose edges have numbers attached to them is called a weighted graph, and the numbers are called the weights of the edges. The graph is called a complete weighted graph.
The Traveling Salesman Problem The problem we want to solve is fundamentally the same– find an optimal Hamilton circuit (a Hamilton circuit with least total weight) for the given weighted graph.
The Traveling Salesman Problem • 15,112 Cities in Germany • Solved in 2001 • Network of 110 processors • Total computer time: 22.6 years
The Traveling Salesman Problem • 24,978 Cities in Sweden • Solved in 2004 • Cluster of 96 dual processor Intel Xenon 2.8 Ghz workstations
The Traveling Salesman Problem Currently the largest solved travelling salesman problem • 85,900 “cities” • Solved in 2006 • Bell Laboratories computer chip • It exhibits the shortest path a laser cutter can follow to sculpt the chip. http://www.math.uwaterloo.ca/tsp/optimal/
The Traveling Salesman Problem • Traveler – person going from site to site. • Sites – where the person is going. • Cost – each leg of the trip has a cost. • Tour – the path taken from beginning to end. • Optimal Tour – a tour with the least total cost.
The Traveling Salesman Problem Other ways to look at it: • Sites – vertices of the graph • Costs – weights of the edges • Tour – Hamilton Circuit • Optimal Tour – Hamilton Circuit of the least total weight
The Traveling Salesman Problem Other examples: • Routing School Busses • Delivering Packages • Fabricating Circuit Boards • Running Errands Around Town • Ant Colony Optimization
The Traveling Salesman Problem 6.4 Simple Strategies for Solving TSPs
The TSP Strategies • Strategy 1 (Exhaustive Search) • Make a list of all possible Hamilton circuits. For each circuit in the list, calculate the total weight of the circuit. From all the circuits, choose the circuit with smallest total weight.
The TSP Strategies Cheapest: $676
The TSP Strategies • Strategy 2 (Go Cheap) • Start from the home city. From there go to the city that is the cheapest to get to. From each new city go to the next city that is cheapest to get to. When there are no more new cities to go to, go back home.
The TSP Strategies Cheapest routes: • A to C = $119 • C to E = $120 • E to D = $199 • D to B = $150 • B to A = $185 {A, C, E, D, B, A} = $773
The TSP Strategies A Tour of 10 Cities (start at A)
The Traveling Salesman Problem 6.5 The Brute-Force and Nearest Neighbor Algorithms
Brute-Force and Nearest-Neighbor • The Exhaustive Search strategy can be formalized into an algorithm generally known as the brute-force algorithm; the Go Cheap strategy can be formalized into an algorithm known as the nearest-neighbor algorithm. • In both cases, the objective of the algorithm is to find an optimal (cheapest, shortest, fastest) Hamilton circuit in a complete weighted graph.
Brute-Force and Nearest-Neighbor Algorithm 1: The Brute-Force Algorithm • Step 1. Make a list of all the possible Hamilton circuits of the graph. Exhaustive Search