Presentation is loading. Please wait.

Presentation is loading. Please wait.

A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting.

Similar presentations


Presentation on theme: "A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting."— Presentation transcript:

1 A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting and ending at his hometown of A. The chart below shows the cost of a one way airline ticket between each pair of cities. What is the cheapest possible sequence in which to visit the five cities? Trip between:Cost A and B$185 A and C$119 A and D$152 A and E$133 B and C$121 B and D$150 B and E$200 C and D$174 C and E$120 D and E$199

2 A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting and ending at his hometown of A. The chart below shows the cost of a one way airline ticket between each pair of cities. What is the cheapest possible sequence in which to visit the five cities? Trip between:Cost A and B$185 A and C$119 A and D$152 A and E$133 B and C$121 B and D$150 B and E$200 C and D$174 C and E$120 D and E$199

3 Hamilton circuit (page 199). A circuit that travels or passes through each vertex of the graph once and only once. Hamilton path (page 199). A path that travels or passes through each vertex of the graph once and only once. Traveling-Salesman Problem (TSP) (page 204). A problem in which the purpose is to find an optimal Hamilton circuit - that is, a Hamilton circuit with the least total weight. Weighted graphs (page 206). A weighted graph is any graph whose edges have numbers attached to them. The numbers are called the weights of the edges.

4 Objective 2: Communicating using precise terminology

5

6 AB CD E (a) AB CD E (b) AB CD E F G (c) AB CD E FG HI (d) FIGURE 6-3 Page 199 EXAMPLE 1. Hamilton vs. Euler

7 The complete graph with N vertices has (N-1)! Hamilton circuits. Complete graph (page 201). A complete graph (on N vertices) is a graph with N vertices in which every pair of vertices is joined by exactly one edge. It is denoted by the symbol.

8 TABLE 6-3, page 202 Each circuit is paired up with its mirror-image circuit. The 24 Hamilton circuits of(using A as a reference point). A B CD E (c)

9 TABLE 6-2, page 202 Each circuit can be written in 4 ways. The 6 Hamilton circuits of.

10 FIGURE 6-7, page 204 Optimal. An algorithm is optimal if it produces the most desired result (cheapest, shortest, …)

11 Make a list of all the possible Hamilton circuits of the graph. For each Hamilton circuit calculate its total weight by adding the weights of all the edges in the circuit. Find the circuits (there is always more than one) with the least total weight. Any one of these can be chosen as an optimal Hamilton circuit for the graph. ALGORITHM 1: The Brute-Force Algorithm (page 210)

12 TABLE 6-3, page 202 Each circuit is paired up with its mirror-image circuit. The 24 Hamilton circuits of(using A as a reference point). A B CD E (c)

13 TABLE 6-5, page 207 The 24 possible Hamilton circuits and their total costs.

14 Inefficient algorithm (page 235). An inefficient algorithm is an algorithm for which the number of steps needed to carry it out grows disproportionately with the size of the problem. Efficient algorithm (page 236). An efficient algorithm is an algorithm for which the number of steps needed to carry it out grows in proportion to the size of the problem. Optimal. An algorithm is optimal if it produces the most desired result (cheapest, shortest, …)

15 FIGURE 6-10 page 207

16 FIGURE 6-10, page 207 Circuit obtained following Nearest neighbor algorithm. Total cost: $773.

17 Pick a vertex as the starting point From the starting vertex go to the vertex for which the corresponding edge has the smallest weight. We call this vertex the nearest neighbor. If there is more than one, choose one at random. Continue building the circuit, one vertex at a time, by always going from a vertex to the nearest neighbor of that vertex from among the vertices that haven’t been visited yet. (Whenever there is a tie choose at random.) Keep doing this until all the vertices have been visited. ALGORITHM 2: The Nearest-Neighbor Algorithm Page 210 From the last vertex return to the starting point.

18 FIGURE 6-10, page 207 Circuit obtained following Nearest neighbor algorithm. Total cost: $773.

19 Approximate algorithm. An approximate algorithm that produces solutions that are, most of the time, reasonably close to the optimal solution.

20

21 Homework Read pages 196 – 214, 219 - 220 Page 221: 2 – 7, 9 – 13, 19, 20, 29, 30, 33 – 36, 50 Test on Chapter 5 and 6: Thursday April 12 See next slides for topics covered

22 Test 3 Information Textbook sections 5.1 – 5.7 Graphs –vertices, edges, loops, bridges, adjacent vertices, adjacent edges, degree of a vertex Connected graphs Paths Circuits Euler Paths (Euler’s Theorem 1) Euler Circuits (Euler’s Theorem 2) Eulerization Semi-Eulerization Routing problems (Konigsburg Bridges, mailman, garbage man, etc…)

23 Test 3 Information Textbook sections 6.1 – 6.8 Hamilton Path Hamilton Circuit Complete graphs Brute Force Algorithm Nearest Neighbor Algorithm Repetitive Nearest Neighbor Algorithm Cheapest Link Algorithm Traveling Salesmen problems


Download ppt "A traveling salesman has customers in 5 cities which we will call A, B, C, D, and E. The salesman needs to travel to all 5 cities with his trip starting."

Similar presentations


Ads by Google