Download presentation
Presentation is loading. Please wait.
1
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm The Nearest Neighbour algorithm: Choose an arbitrary starting node. Choose the smallest arc from this node to a node not yet in the tour. Repeat until all nodes are in the tour. Then add an arc back to the starting node.
2
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example A B C D E 3 5 4 2 6
3
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Start from node A. All nodes are now in the tour, so return to the starting point. From B, the only node not yet in the tour is E. The nearest node is D. From C, the nearest node not yet in the tour is B. From D, the nearest node not yet in the tour is C. Length of tour = = 18
4
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Next, start from node B. The nearest node is C. However, from C, A and D are equally near. Choosing A gives the route A, D, E and then back to B. Length of tour = = 19
5
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Next, start from node B. The nearest node is C. However, from C, A and D are equally near. Choosing D gives the route D, A, E and then back to B. Length of tour = = 18
6
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Next, start from node C. This gives the route C, B, A, D, E and then back to C. Length of tour = = 19
7
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Next, start from node D. This gives the route D, A, B, C, E and then back to D. Length of tour = = 19
8
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Finally, start from node E. A and B are equally near. Choosing A gives the route E, A, D, C, B and then back to E. Length of tour = = 18
9
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Finally, start from node E. A and B are equally near. Choosing B gives two possible routes: either E, B, C, D, A, E Length of tour = = 18
10
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Example 3 B A 2 4 2 5 5 5 C 4 6 6 E D Finally, start from node E. A and B are equally near. Choosing B gives two possible routes: or E, B, C, A, D, E Length of tour = = 19
11
The travelling salesman problem
Finding a tour using the nearest neighbour algorithm Starting vertex Tour(s) Length A ADCBEA 18 B BCADEB BCDAEB 19 C CBADEC D DABCED E EADCBE EBCDAE EBCADE The shortest tour has length 18. Note that all the tours of length 18 are the same, starting at different points, some in reverse order.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.