Travelling Salesman Problem (DP IB Applications & Interpretation (AI)): Revision Note

Naomi C

Written by: Naomi C

Reviewed by: Dan Finlay

Updated on

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.

3-10-5-ib-ai-hl-travelling-salesman-problem-we-1

Show that G is a Hamiltonian graph.

3-10-5-ib-ai-hl-travelling-salesman-problem-we-1-solution

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

x

x factorial

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.

3-10-5-ib-ai-hl-travelling-salesman-problem-we-2

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.

3-10-5-ib-ai-hl-travelling-salesman-problem-we-2-solution

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Naomi C

Author: Naomi C

Expertise: Maths Content Creator

Naomi graduated from Durham University in 2007 with a Masters degree in Civil Engineering. She has taught Mathematics in the UK, Malaysia and Switzerland covering GCSE, IGCSE, A-Level and IB. She particularly enjoys applying Mathematics to real life and endeavours to bring creativity to the content she creates.

Dan Finlay

Reviewer: Dan Finlay

Expertise: Maths Subject Lead

Dan graduated from the University of Oxford with a First class degree in mathematics. As well as teaching maths for over 8 years, Dan has marked a range of exams for Edexcel, tutored students and taught A Level Accounting. Dan has a keen interest in statistics and probability and their real-life applications.