Travelling Salesman Problem (DP IB Applications & Interpretation (AI)): Revision Note
Did this video help you?
Hamiltonian paths & cycles
What are Hamiltonian paths and cycles?
A Hamiltonian path is a path which visits each vertex in a graph exactly once
A Hamiltonian cycle is a path which visits each vertex in a graph exactly once and begins and ends at the same vertex
The start and end vertex is the only vertex that is repeated
A graph which contains a Hamiltonian cycle is called a Hamiltonian graph
A semi-Hamiltonian graphs contains a Hamiltonian path but not a Hamiltonian cycle
The only way to show that a graph is Hamiltonian or semi-Hamiltonian is to find a Hamiltonian cycle or Hamiltonian path
Examiner Tips and Tricks
The only way to show that a graph is Hamiltonian or semi-Hamiltonian is to find a Hamiltonian cycle or Hamiltonian path. This is different to Eulerian and semi-Eulerian graphs where you can identify them using the degrees of the vertices.
Worked Example
Let G be the graph shown below.

Show that G is a Hamiltonian graph.

Travelling salesman problem
What is the travelling salesman problem?
The travelling salesman problem requires you to find the route of least weight such
it starts and finishes at the same vertex
and it visits every other vertex in the graph exactly once
The classical problem has the following conditions:
the graph is complete
the direct route between two vertices is the shortest route
it is said to satisfy the triangle inequality
Examiner Tips and Tricks
To remember the difference between the travelling salesman problem and the Chinese postman problem, remember that the salesman is interested in selling at each destination (vertex) whereas the postman wants to walk along every road (edge) in order to deliver the letters.
How do I solve the classical travelling salesman problem?
There is no known algorithm that guarantees finding the shortest Hamiltonian cycle in a graph
List all the possible Hamiltonian cycles
Add together the edges for each cycle
Find the cycle of least weight
This method is only suitable for small graphs
Number of vertices in the complete graph | Number of possible Hamiltonian cycles |
---|---|
3 (A, B, C) | 2 (ABCA, ACBA) |
4 (A, B, C, D) | 6 (ABCDA, ADCBA, ABDCA, ACDBA, ACBDA, ADBCA) |
5 | 24 |
Examiner Tips and Tricks
This method is only suitable for small graphs because the number of possible Hamiltonian cycles increases rapidly.
Worked Example
The graph below shows four towns and the distances between them in km.

A salesman lives in city A and wishes to travel to each of the other three cities before returning home.
Find the shortest route that the salesman could take and state the total length of the route.

Unlock more, it's free!
Did this page help you?