IB Maths AI HL Graph Theory: Networks, Algorithms and Route Problems

IB Maths AI HL Graph Theory

IB Maths AI HL Graph Theory: Networks, Algorithms and Route Problems

A graph theory question might describe a delivery company, a transport network, a set of connected towns, or a system of roads.

You are given locations, connections, and sometimes distances or costs. Your task is to represent the situation mathematically and choose an algorithm to solve the problem.

The challenge is knowing which method to use.

Should you find a minimum spanning tree? Are you looking for a route that travels along every edge? Do you need a cycle that visits every vertex exactly once? And how do you know whether to use Prim’s algorithm, Kruskal’s algorithm, or the Chinese postman algorithm?

These are important distinctions in IB Maths AI HL Graph Theory.

This guide explains the main graph theory concepts, with worked examples covering adjacency matrices, minimum spanning trees, Eulerian routes, the Chinese postman problem, and the travelling salesman problem.

Table of Contents

What is graph theory in IB Maths AI HL?

Graph theory is the study of networks and the relationships between connected objects.

A graph consists of:

• Vertices: The points or locations in a network.

• Edges: The connections between vertices.

• Weights: Numerical values assigned to edges, such as distance, time, or cost.

For example, a transport network can be represented using vertices for stations and edges for railway connections.

Graph theory is part of the higher level extension of the current IB Mathematics: Applications and Interpretation course. The relevant syllabus content includes graph terminology, adjacency matrices, walks, trees, Eulerian and Hamiltonian routes, minimum spanning trees, the Chinese postman problem, and the travelling salesman problem.

Quick answer: Use a minimum spanning tree when you need to connect all vertices with the smallest total weight. Use the Chinese postman problem when you need to travel along every edge at least once. Use the travelling salesman problem when you need a minimum weight cycle that visits every vertex exactly once.

1. Understanding graph theory terminology

Before using algorithms, make sure you understand the language of graph theory.

Consider a network containing four vertices, A, B, C, and D.

The connections between them are:

AB, AC, BC, BD, and CD.

This simple network can be used to explain several important terms.

TermMeaning
Adjacent verticesTwo vertices connected by an edge
DegreeNumber of edges connected to a vertex
WalkA sequence of connected vertices and edges
TrailA walk that does not repeat an edge
PathA walk that does not repeat a vertex
CircuitA closed trail that starts and finishes at the same vertex
CycleA closed path
Connected graphEvery vertex can be reached from every other vertex
SubgraphA graph formed from some of the vertices and edges of another graph
TreeA connected graph with no cycles

Understanding the degree of a vertex

The degree of a vertex is the number of edges connected to it.

Using the example above:

• Vertex A has degree 2.

• Vertex B has degree 3.

• Vertex C has degree 3.

• Vertex D has degree 2.

The sum of the degrees is:

[
2+3+3+2=10
]

There are five edges, and each edge connects two vertices.

Therefore:

[
\text{Sum of degrees}=2(\text{number of edges})
]

[
10=2(5)
]

This relationship is useful when checking whether you have counted the edges and degrees correctly.

Directed and undirected graphs

An undirected graph has edges without arrows. Movement between two connected vertices is possible in either direction.

A directed graph has arrows showing the direction of movement.

For a directed graph, you need to understand two terms:

• In degree: Number of edges entering a vertex.

• Out degree: Number of edges leaving a vertex.

Read the arrows carefully. A directed edge from A to B does not automatically allow movement from B to A.

2. Understanding weighted and unweighted graphs

An unweighted graph shows connections without assigning numerical values to the edges.

A weighted graph assigns a value to each edge.

For example, a network of four towns might have the following road distances:

ConnectionDistance
A to B4 km
A to C2 km
B to C1 km
B to D5 km
C to D8 km

The weights represent distances.

In other questions, weights might represent travel time, construction cost, or delivery expenses.

The context tells you what the weights mean. Always include the correct units when interpreting your answer.

3. Adjacency matrices and graph theory

An adjacency matrix represents the connections between vertices using a square matrix.

Consider a graph with three vertices, A, B, and C.

The edges are:

AB and BC.

The adjacency matrix is:

[
A=
\begin{pmatrix}
0&1&0\
1&0&1\
0&1&0
\end{pmatrix}
]

The rows and columns represent the vertices in the order A, B, and C.

A value of 1 means that two vertices are connected. A value of 0 means that they are not connected.

For this undirected graph, the matrix is symmetrical.

What happens when you square an adjacency matrix?

One important graph theory result is that the entries of (A^2) represent the number of walks of length two between pairs of vertices.

For the example above:

[
A^2=
\begin{pmatrix}
1&0&1\
0&2&0\
1&0&1
\end{pmatrix}
]

The value in row B, column B is 2.

This means there are two walks of length two that start at B and return to B:

[
B\rightarrow A\rightarrow B
]

and

[
B\rightarrow C\rightarrow B
]

This idea extends to higher powers.

The entries of (A^k) give the number of walks of length (k) between the corresponding vertices.

Exam tip: Do not confuse the number of walks with the number of different paths. A walk can repeat vertices and edges, while a path cannot repeat vertices.

4. What is a minimum spanning tree?

A spanning tree connects every vertex in a connected graph without creating a cycle.

A minimum spanning tree, often abbreviated to MST, is a spanning tree with the smallest possible total weight.

Imagine a company wants to connect five towns using cables. The company needs every town to be connected but wants to minimise the total installation cost.

This is a minimum spanning tree problem.

Two algorithms are particularly important:

  1. Kruskal’s algorithm.
  2. Prim’s algorithm.

Both find a minimum spanning tree, but they build it in different ways.

5. Kruskal’s algorithm explained

Kruskal’s algorithm starts by considering the edges in ascending order of weight.

You add the cheapest available edge, provided that adding it does not create a cycle.

Continue until every vertex is connected.

Worked Example 1: Using Kruskal’s algorithm

A network contains five vertices, A, B, C, D, and E.

The weighted edges are:

EdgeWeight
BC1
AC2
DE2
AB4
BD5
BE7
CD8
CE10

Find the minimum spanning tree.

Step 1: Arrange the edges by weight

The edges are already arranged from smallest to largest.

Start with the cheapest edge.

Step 2: Select BC

[
BC=1
]

Add the edge BC.

Step 3: Select AC

[
AC=2
]

Add AC. This connects A to the existing network.

Step 4: Select DE

[
DE=2
]

Add DE. This connects D and E.

Step 5: Consider AB

[
AB=4
]

Do not add AB because A and B are already connected through C. Adding this edge would create a cycle.

Step 6: Select BD

[
BD=5
]

Add BD. This connects the two separate parts of the network.

All five vertices are now connected.

The minimum spanning tree contains:

[
BC,\ AC,\ DE,\ BD
]

The total weight is:

[
1+2+2+5=10
]

<badge color=”success”>Final answer</badge>

[
\boxed{\text{Minimum total weight}=10}
]

Important point about Kruskal’s algorithm

You do not need to select every edge.

You need exactly enough edges to connect all vertices without creating a cycle.

For a connected graph with (n) vertices, a spanning tree contains:

[
\boxed{n-1\text{ edges}}
]

For five vertices, the minimum spanning tree must contain four edges.

6. Prim’s algorithm explained

Prim’s algorithm also finds a minimum spanning tree, but it starts from one vertex and gradually expands the network.

At each stage:

  1. Choose a starting vertex.
  2. Find the cheapest edge connecting the existing tree to a vertex outside it.
  3. Add that edge and the new vertex.
  4. Repeat until all vertices are connected.

Using the previous example, start at A.

Worked Example 2: Using Prim’s algorithm

The available edges are the same as in the previous example.

Start at A.

Step 1: From A, the available edges are:

[
AB=4,\quad AC=2
]

Choose AC because it has the smaller weight.

Step 2: The current tree contains A and C.

The available edges connecting this tree to another vertex are:

[
CB=1,\quad CD=8,\quad AB=4
]

Choose CB.

Step 3: The current tree contains A, B and C.

The cheapest edge connecting it to an outside vertex is:

[
BD=5
]

Choose BD.

Step 4: The current tree contains A, B, C and D.

The cheapest edge connecting it to E is:

[
DE=2
]

Choose DE.

The minimum spanning tree has total weight:

[
2+1+5+2=10
]

[
\boxed{\text{Minimum total weight}=10}
]

Prim’s algorithm versus Kruskal’s algorithm

Prim’s algorithmKruskal’s algorithm
Starts at one vertexStarts by considering the cheapest edge
Expands one connected treeBuilds a forest of separate components
Chooses the cheapest edge leaving the current treeChooses the cheapest edge that does not create a cycle
Stops when all vertices are includedStops when all vertices are connected

Both methods can produce a minimum spanning tree.

The important skill is following the correct selection rule at each step.

7. Eulerian trails and circuits

Eulerian problems focus on travelling along edges.

An Eulerian trail is a route that travels along every edge exactly once.

An Eulerian circuit is an Eulerian trail that also finishes at its starting vertex.

The key property is the degree of each vertex.

For a connected undirected graph:

• An Eulerian circuit exists if every vertex has an even degree.

• An Eulerian trail that is not a circuit exists if exactly two vertices have odd degrees.

• If more than two vertices have odd degrees, an Eulerian trail does not exist.

These rules are important when deciding whether a route is possible.

Example: Checking for an Eulerian circuit

Consider a connected graph with four vertices.

Their degrees are:

VertexDegree
A2
B4
C2
D2

Every vertex has an even degree.

Therefore, the graph has an Eulerian circuit.

If exactly two vertices had odd degrees, an Eulerian trail would exist, but it would start and finish at different vertices.

Common mistake: Eulerian questions focus on edges. You need to use every edge, but you may visit a vertex more than once.

8. The Chinese postman problem

The Chinese postman problem asks for the shortest closed route that travels along every edge of a connected weighted graph at least once.

Imagine a postal worker who must deliver letters along every road in a neighbourhood and return to the starting point.

If the graph already has an Eulerian circuit, the worker can travel along every edge once.

If not, some edges must be repeated.

The goal is to minimise the extra distance.

Worked Example 3: Solving a Chinese postman problem

Consider a network with these weighted edges:

EdgeWeight
AB2
AC3
BC1
BD4
CD2

Step 1: Find the degree of each vertex

VertexDegree
A2
B3
C3
D2

Vertices B and C have odd degrees.

Therefore, the graph does not have an Eulerian circuit.

Step 2: Identify the shortest path between the odd vertices

The odd vertices are B and C.

The direct connection has weight:

[
BC=1
]

This is the shortest path between them.

Step 3: Repeat the shortest path

Repeat edge BC so that both B and C have even degrees.

The network now has an Eulerian circuit.

Step 4: Calculate the total route weight

The original total weight is:

[
2+3+1+4+2=12
]

The extra distance is:

[
1
]

Therefore:

[
\boxed{\text{Minimum route weight}=13}
]

One possible route is:

[
A\rightarrow B\rightarrow D\rightarrow C\rightarrow B\rightarrow C\rightarrow A
]

This route uses every original edge and repeats BC.

Exam tip: In a Chinese postman problem, first identify the odd vertices. Do not start repeating edges randomly. You need to find the shortest way to pair the odd vertices.

For graphs with up to four odd vertices, compare the possible pairings and choose the one with the smallest additional weight.

9. The travelling salesman problem

The travelling salesman problem is different from the Chinese postman problem.

Here, the goal is to find a minimum weight cycle that visits every vertex exactly once and returns to the starting vertex.

Imagine a salesperson who needs to visit several cities and return home.

You want the shortest possible complete journey.

Two algorithms are included in the current AI HL syllabus:

  • Nearest neighbour algorithm, which gives an upper bound.
  • Deleted vertex algorithm, which gives a lower bound.

Worked Example 4: Using the nearest neighbour algorithm

A salesperson must visit four cities, A, B, C and D, and return to A.

The distances are:

ConnectionDistance
AB4
AC6
AD7
BC5
BD8
CD3

Start at A.

Step 1: From A, choose the nearest unvisited city.

[
AB=4,\quad AC=6,\quad AD=7
]

Choose B.

Step 2: From B, the unvisited cities are C and D.

[
BC=5,\quad BD=8
]

Choose C.

Step 3: From C, the only unvisited city is D.

[
CD=3
]

Choose D.

Step 4: Return to A.

[
DA=7
]

The total distance is:

[
4+5+3+7=19
]

[
\boxed{\text{Upper bound}=19}
]

This gives a possible complete route, but it does not automatically prove that the route is optimal.

Understanding the deleted vertex algorithm

The deleted vertex algorithm gives a lower bound for the minimum travelling salesman route.

The general method is:

  1. Remove one vertex from the graph.
  2. Find a minimum spanning tree of the remaining vertices.
  3. Find the two smallest edges connecting the removed vertex to the remaining graph.
  4. Add these values to obtain a lower bound.

For the previous example, remove A.

The remaining vertices are B, C and D.

Their minimum spanning tree uses:

[
BC=5,\quad CD=3
]

The total is:

[
5+3=8
]

The two smallest edges from A are:

[
AB=4,\quad AC=6
]

Add them:

[
8+4+6=18
]

Therefore:

[
\boxed{\text{Lower bound}=18}
]

We now know that the shortest possible route must satisfy:

[
18\leq\text{Minimum route}\leq19
]

In this example, the route A to B to C to D and back to A has length 19. It achieves the upper bound, so it is optimal.

Important distinction: The nearest neighbour method gives a valid route and an upper bound. The deleted vertex method gives a lower bound. Neither method should be described as an exact solution in every graph.

10. How to identify the correct graph theory algorithm

Many graph theory questions become easier when you focus on what the question asks you to do.

Question requirementCorrect concept or method
Represent connectionsGraph or adjacency matrix
Count walks of a given lengthPowers of an adjacency matrix
Connect every vertex at minimum total weightMinimum spanning tree
Build a minimum spanning tree from the cheapest edgesKruskal’s algorithm
Expand a tree from a starting vertexPrim’s algorithm
Travel along every edge exactly onceEulerian trail
Return to the start after using every edgeEulerian circuit
Travel along every edge at least once with minimum total weightChinese postman problem
Visit every vertex once and return to the startTravelling salesman problem
Find an upper bound for a travelling salesman routeNearest neighbour algorithm
Find a lower bound for a travelling salesman routeDeleted vertex algorithm

Read the wording carefully. A question about visiting every road is not the same as a question about visiting every town.

11. Common mistakes in graph theory questions

1. Confusing vertices and edges

Vertices represent locations or objects. Edges represent connections.

Read the diagram before calculating degrees or route lengths.

2. Creating a cycle in a minimum spanning tree

A minimum spanning tree must connect all vertices without creating a cycle.

If an edge joins two vertices that are already connected, adding it creates a cycle and should be avoided.

3. Confusing Prim’s and Kruskal’s algorithms

Prim’s algorithm expands one existing tree.

Kruskal’s algorithm selects the cheapest available edges while avoiding cycles.

4. Confusing Eulerian and Hamiltonian routes

Eulerian routes focus on edges.

Hamiltonian routes focus on vertices.

This distinction is essential for the Chinese postman and travelling salesman problems.

5. Assuming the nearest neighbour route is optimal

The nearest neighbour algorithm gives an upper bound. It does not always find the shortest possible route.

6. Forgetting to return to the starting vertex

The Chinese postman problem and travelling salesman problem usually require a closed route.

Check whether the final connection back to the starting vertex has been included.

7. Ignoring units

If the edge weights represent kilometres, the final answer should be expressed in kilometres.

If they represent cost, use the correct currency.

12. How to revise graph theory for IB Maths AI HL

Use this 60 minute revision routine.

TimeRevision activity
10 minutesReview graph terminology and vertex degrees
10 minutesPractise adjacency matrices and matrix powers
15 minutesSolve minimum spanning tree questions
10 minutesPractise Eulerian and Chinese postman problems
10 minutesWork through travelling salesman questions
5 minutesReview mistakes and algorithm selection

When reviewing your answers, ask:

• Did I identify the vertices and edges correctly?

• Did I calculate each degree accurately?

• Did I avoid creating cycles in my minimum spanning tree?

• Did I distinguish between edges and vertices?

• Did I select the correct algorithm?

• Did I explain what the final route or weight represents?

For a wider overview of the course, read the IB Maths AI HL syllabus and topic guide.

How Mathzem can help you practise graph theory

Graph theory questions require you to understand the network, select an algorithm and show how each step leads to the final result.

Mathzem provides IB Mathematics practice questions and lets students upload handwritten working for AI Examiner feedback.

You can review your mathematical method, identify mistakes and see which parts of your reasoning need more practice.

You can also track your performance across topics, helping you decide where to focus your revision.

Start with IB Maths practice questions and handwritten working feedback and practise explaining each step of your solution.

Frequently asked questions about IB Maths AI HL Graph Theory

1. Is graph theory included in IB Maths AI HL?

Yes. Graph theory is part of the higher level extension in the current Mathematics: Applications and Interpretation syllabus.

2. What is the difference between Prim’s and Kruskal’s algorithms?

Prim’s algorithm starts from one vertex and expands a connected tree. Kruskal’s algorithm selects edges in ascending order of weight, avoiding cycles until all vertices are connected.

3. What is a minimum spanning tree?

A minimum spanning tree is a connected graph that includes every vertex, contains no cycles and has the smallest possible total edge weight.

4. What is the difference between the Chinese postman problem and the travelling salesman problem?

The Chinese postman problem requires every edge to be travelled at least once. The travelling salesman problem requires every vertex to be visited exactly once before returning to the starting vertex.

5. How many edges does a spanning tree have?

A spanning tree with (n) vertices has exactly:

[
n-1
]

edges.

6. What is the difference between an Eulerian and a Hamiltonian circuit?

An Eulerian circuit travels along every edge exactly once and returns to the starting vertex. A Hamiltonian cycle visits every vertex exactly once and returns to the starting vertex.

7. Does the nearest neighbour algorithm always find the shortest route?

No. It provides an upper bound for the travelling salesman problem. A different route may have a smaller total weight.

Final thoughts

Graph theory becomes more manageable when you identify what the question is asking before choosing an algorithm.

Use adjacency matrices to represent connections and count walks. Use Prim’s or Kruskal’s algorithm to find a minimum spanning tree. Use Eulerian ideas and the Chinese postman algorithm when the task involves travelling along every edge. Use the travelling salesman methods when the task involves visiting every vertex and returning to the start.

The most important exam skill is recognising the difference between these problems.

Practise each algorithm with different network diagrams, show your working clearly, and explain why your chosen method solves the problem.

Practise IB Maths with Mathzem, upload your working, and use feedback to improve the reasoning behind your answers.

Leave a Reply

Your email address will not be published. Required fields are marked *