Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every.

Similar presentations


Presentation on theme: "The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every."— Presentation transcript:

1 The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every vertex and returning to the start Unlike the postman problem you do not have to go along every edge There is not a method for finding the shortest route but there are 2 methods which will home in on the answer

2 Nearest Neighbour Algorithm This is used to find an Upper Bound This is a value which represents the largest distance that needs to be covered. It may be possible to do the problem in a shorter distance but this algorithm gives a quick answer to a possible solution

3 Nearest Neighbour Algorithm 1. Start with any vertex 2. Look for the shortest edge that joins this vertex to a vertex not on the tree and add this to the tree. 3. Keep joining vertices to the last chosen vertex using the smallest edge available. Repeat until all the vertices are joined to the tree. 4. Join the last chosen vertex to the first chosen. Note DO NOT visit any vertex twice on the outward route

4 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 If it is not possible to return to the start directly then it will be necessary to revisit certain vertices on the return route. Starting at A visit every vertex and return to A

5 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 1. Choose vertex A 2. Choose vertex B as it is the Nearest Neighbour 3. Next choose vertex C, as it is the Nearest Neighbour 4. Repeat to get vertex D, then E, then F, then G 5. Return to A using the shortest route i.e 9

6 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 Total distance = 24

7 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 Starting at F 1. Choose vertex G as it is the Nearest Neighbour 2. Next choose vertex E, as it is the Nearest Neighbour 3. Repeat to get vertex D, then C, then B, then A 4. Return to F using the shortest route i.e 4+1+2+4 Total distance = 28

8 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 Since the first route gave a better answer this means that the answer is 24 or less 24 is called an Upper Bound The smaller the Upper Bound the better

9 B A D C 3 2 1 4 8 E G F 2 4 6 5 3 10 7 9 In fact for this problem the shortest route is 24 Applet


Download ppt "The Travelling Salesman Algorithm A Salesman has to visit lots of different stores and return to the starting base On a graph this means visiting every."

Similar presentations


Ads by Google