Download presentation
Presentation is loading. Please wait.
Published bySuzan Flynn Modified over 9 years ago
1
The Travelling Salesperson Problem A salesperson needs to visit London, Nottingham, Manchester and Leeds, he lives in Birmingham. Find the shortest route he can travel to visit all the cities and get home again. Le M N B Lo 43m 194m 72m 117m 87m 121m 52m 130m
2
The Travelling Salesperson Problem Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem.
3
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. For example, we can easily find all the possible Hamiltonian cycles in the following diagram. (Start and finish at A) A 4 4 B D C 4 6 2 5
4
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ACBDA has weight 16 A 4 4 B D C 4 6 2 5
5
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ACBDA has weight 16 A 4 4 B D C 4 6 2 5
6
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ABCDA has weight 17 A 4 4 B D C 4 6 2 5
7
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ABCDA has weight 17 A 4 4 B D C 4 6 2 5
8
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ABDCA has weight 17 A 4 4 B D C 4 6 2 5
9
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. A Hamiltonian cycle is defined to be a tour that visits every node precisely once. There are 3 essentially different Hamiltonian cycles: ABDCA has weight 17 A 4 4 B D C 4 6 2 5
10
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. Not all graphs have a Hamiltonian cycle We can replace this network by the complete network of shortest distances. A B DC 21 38 35 23 33 12 The shortest route from A to B is 35
11
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. The Nearest Neighbour algorithm Step 1Choose any starting node The Nearest Neighbour algorithm Step 1Choose any starting node
12
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle.
13
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle. Step 3Repeat Step 2 until all the nodes have been chosen. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle. Step 3Repeat Step 2 until all the nodes have been chosen.
14
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle. Step 3Repeat Step 2 until all the nodes have been chosen. Step 4Then add the arc that joins the last-chosen node to the first-chosen node. The Nearest Neighbour algorithm Step 1Choose any starting node Step 2Consider the arcs which join the previously chosen nodes. From these arcs pick one that has minimum weight. Choose this arc, and the new node on the end of it, to join the cycle. Step 3Repeat Step 2 until all the nodes have been chosen. Step 4Then add the arc that joins the last-chosen node to the first-chosen node.
15
Aim: to be able to… find a Hamiltonian cycle by using the Nearest Neighbour algorithm to find a solution to the problem.
16
Le M N B Lo 43m 194m 72m 117m 87m 121m 52m 130m Use the Nearest Neighbour algorithm to solve the problem we considered earlier. Starting from Birmingham.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.