MEI 2011
the Further Mathematics Support Programme www.furthermaths.org.uk
Let Maths take you Further …
Nov 2009 - Feb 2010
MEI 2011
Topic
Graphs
Networks
Graphs
Prim
Kruskal
Dijkstra
Floyd’s algorithm
TSP
Route inspection
Network Flows
Critical Path Analysis Activity networks
Optimisation Matchings
Decision analysis
AQA
D1
D1
D1
D1
D1
D1
D2
D2 node
D1
Edexcel
D1
D1
D1
D1
D2
D1
D2
D1 arc
D1
MEI
D1
D1
D1
D1
D2
D2
D2
D1 arc
D2
OCR A
D1
D1
D1
D1
D1
D1
D2
D2 arc
D2
MEI 2011
Graph theory was until recently considered to be just recreational but is now regarded as a subject in its own right. It has widespread applications in all areas of mathematics and science.
Many problems can be modelled as graphs (circuit diagrams, molecules in chemistry) or weighted graphs, called networks (distances networks, cost networks, decision trees)
Graph theory is also widely used in sociology as a way, for example, to measure an individual’s prestige or through the use of social network analysis software.
MEI 2011
Graph theory forms the basis of all the network algorithms
MEI 2011
(maths as a foreign language)
A walk moves along an edge from one vertex to another and can visit a vertex or an edge more than once.
A trail moves along an edge from one vertex to another and can visit a vertex more than once but cannot traverse an edge more than once.
A path moves along an edge from one vertex to another but cannot visit a vertex more than once.
MEI 2011
Some other terms used with graphs
A graph is connected if there is a path between every pair of vertices
A simple graph is one with no loops and no multiple edges between any two vertices
MEI 2011
A tree is a simple connected graph with no cycles or loops
A digraph (directed graph) is one in which at least one edge has a direction associated with it.
MEI 2011
A complete graph is a simple graph in which every pair of vertices is connected
A planar graph is a which can be drawn without any edges crossing
MEI 2011
Give students a vocabulary list to learn
Students often seem to think that the graph theory is merely background to the network algorithms and is not a topic in its own right, however there is always a graph theory question on the D1 paper.
But do make sure that students realise that many of the network algorithms use graph theory (e.g. Eulerian Trails in Route Inspection, Hamiltonian cycles in TSP).
The exam questions can be on any aspect of the topic and are difficult to predict so make sure that students do a wide variety of questions and are prepared for the unexpected.
MEI 2011
Be able to model and solve problems using networks
Key Points:
Understand notation and terminology.
Minimum spanning trees – Kruskal’s and Prim’s algorithms
Shortest path – Dijkstra’s algorithm
Touring – Route Inspection and Travelling Salesperson
MEI 2011
A cable TV company based in Plymouth wants to link all the towns on the map. To keep costs to a minimum they want to use as little cable as possible.
What strategy should they use to solve the problem?
Accept solution
Real life Problem
Yes
No
Review
Make simplifying assumptions
Compare the solution with reality – is it realistic?
Define variables and decide on the mathematical techniques to be used
MEI 2011
Interpret the solution in terms of the original problem
Solve the mathematical problem
MEI 2011
A cable TV company based in Plymouth wants to link all the towns on the map. To keep costs to a minimum they want to use as little cable as possible.
What strategy should they use to solve the problem?
Model the map as a network
MEI 2011
A cable TV company based in Plymouth wants to link all the towns on the map. To keep costs to a minimum they want to use as little cable as possible.
What strategy should they use to solve the problem?
Spanning tree of minimum length
Minimum connector
MEI 2011
Kruskal’s algorithm
1. Select the shortest edge in a network
2. Select the next shortest edge which does not create a cycle
3. Repeat step 2 until all vertices have been connected
Prim’s algorithm
1. Select any vertex
2. Select the shortest edge connected to that vertex
3. Select the shortest edge connected to any vertex already connected
4. Repeat step 3 until all vertices have been connected
A cable company want to connect five villages to their network which currently extends to the market town of
Avonford. What is the minimum length of cable needed?
MEI 2011
Avonford
Brinleigh
3
8
5
4
7
5
6
Fingley
8
2
Cornwell
4
Donster
Edan
MEI 2011
We model the situation as a network, then the problem is to find the minimum connector for the network
A
3
4
B
7
8
5
C
5
F
6
8
2
4
D
E
MEI 2011
A
3
4
B
7
8
5
5
F
Minimum spanning tree
C
Kruskal’s Prim’s
4
6
8
D
ED 2
AB 3
CD 4
AE 4
EF 5
AB 3
AE 4
ED 2
CD 4
EF 5
2
E
Total weight of tree: 18
Avenford
Brinleigh
3
4
Edan
Fingley
4
5
Cornwell
2
C
D
A
B
E
F
-
-
-
3
4
7
A
1 2
B
-
4
-
5
-
6
5
-
3
-
-
8
5 4 3
C D E
6
8
7
8
5
-
6
F
-
2
4
-
-
5
4
-
-
-
2
8
Donster
The spanning tree is shown in the diagram
Length
3 + 4 + 4 + 2 + 5 = 18Km
MEI 2011
Both algorithms will always give solutions with the same total weight.
They will usually select edges in a different order
Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network.
MEI 2011
Before you have introduced any algorithms define the problem, and ask students to come up with their own algorithm (usually about 50/50 Prim/Kruskal)
For Kruskal , it may be helpful to list all the edges in order of length before starting, depending on the size of the network.
Make sure that students LIST the order in which they add the edges to the solution
MEI 2011
Prim’s (matrix form): Introduce this with a simple example, using both network and matrix methods simultaneously to show what is going on.
The textbook approach of physically deleting rows can’t be replicated by students, there isn’t time.
Suggest they use coloured highlighter for deleting rows and for adding columns to the solution while first learning this. However, they must be able to do solutions confidently in pencil in the exams.
Draw the solution as you go along – this can help prevent putting in cycles by mistake. This can also prompt students to look in all relevant columns, not just the one they just added.
Be able to model and solve problems using networks
Shortest Path – Dijkstra’s algorithm
Googlemaps and
Google Earth are brilliant tools for networks
MEI 2011
MEI 2011
This algorithm finds the shortest path from the start vertex to every other vertex in the network.
Showing working correctly is vital to getting the marks in these questions
B
4
F
4
1
D
2
4
7
A
7
3
3 2
2
C 5 E
G
Order in which vertices are labelled.
B
Working
4
4
1 0
A
7
1
D
2
Distance from A to vertex
F
7
3 2
Label vertex A
1 as it is the first vertex labelled
3
C 5 E
2
4
G
MEI 2011
MEI 2011
Explain that permanent labels are unbeatable.
This includes making the 0 at the starting vertex permanent, since 0 is the shortest possible distance from the start to itself.
Stress the importance of working values, examiners will be looking for the correct values in here.
When updating temporary values, if there is already a temporary value at a vertex, don’t write a bigger one there.
MEI 2011
Which of these graphs can be drawn without taking your pen off the paper or repeating any edges?
MEI 2011
Yes –start and finish in different places
Semi-Eulerian
Yes- start and finish in the same place
Eulerian
No
An Eulerian Trail is a route that travels along every edge once only and returns to the starting vertex
MEI 2011
A Hamiltonian Cycle is a closed path which visits every vertex (once and only once excluding the start / finish vertex!).
MEI 2011
Route Inspection – often called Chinese postman after the Chinese mathematician, Mei Ko Kwan, who developed the algorithm in 1962
This algorithm is about trying to find an Eulerian trail in a network. Of course, you usually can’t!
Travelling salesperson – this algorithm is about trying to find a Hamiltonian cycle in a network.
MEI 2011
1.
2.
3.
4.
5.
Identify the odd vertices in the network
Consider all the routes joining pairs of odd vertices and select the one with the least weight.
Find the sum of the weights on all the edges
Shortest distance is the sum of the weights plus the extra that must be travelled
Find a tour which repeats the edges found in step 2.
MEI 2011
Make sure that students consider all possible pairings and are systematic where looking for pairs of odd vertices in RI.
Modelling skills are very important when tackling all types of network problems. Students must be able to interpret the solution in the context of the original problem.
Students may need to work from networks, tables or combinations of both, so make sure they are prepared for any eventuality.
MEI 2011
Make sure that students consider all possible pairings and are systematic where looking for pairs of odd vertices in RI.
Modelling skills are very important when tackling all types of network problem. Students must be able to interpret the solution in the context of the original problem.
Students may need to work from networks, tables or combinations of both, so make sure they are prepared for any eventuality.
MEI 2011
Find the route that visits every city (at least once) and uses the least air miles.
MEI 2011
A walk in a network is a finite sequence of edges such that the end vertex of one edge is the start vertex of the next.
A tour is a walk that visits every vertex in the network, returning to the starting vertex.
The travelling salesman problem is trying to find a walk that gives a minimum tour i.e. find a tour of minimum weight
There is no known algorithm that solves this problem
MEI 2011
So instead of doing an exhaustive search we can make use of heuristic algorithms where we can have a good answer but probably not the optimal solution.
L
≤
We just need to find a ‘ largest’ lower bound that we can
We just need to find the ‘smallest’ upper bound that we can
MEI 2011
MEI 2011
In each network, find a cycle of minimum length, starting and finishing at A. Is it possible to find a cycle that visits each vertex once, and only once?
A cycle that that visits each vertex once, and only once including all vertices of a network is a Hamiltonian cycle
MEI 2011
In the classical problem you must visit each vertex only once before returning to the start
In the practical problem you must visit each vertex at least once before returning to the start
Key idea: If you convert a network into a complete network of least distances, the classical problem and the practical problem are the same.
All complete graphs do have Hamiltonian cycles
MEI 2011
5.
6.
3.
4.
1.
2.
Choose any vertex as the starting point.
From the vertices not already selected find the nearest vertex to the last one.
Repeat step 2 until all vertices have been selected.
Join the last vertex to the first vertex.
Repeat for different starting vertices.
Choose the least upper bound.
MEI 2011
3.
4.
5.
1.
2.
Choose a vertex and delete it and all its edges from the network.
Find a minimum connector for the remaining network using
Kruskal’s or Prim’s.
Add in the weights of the two least weight deleted edges.
Repeat deleting a different vertex.
Choose the greatest lower bound.
MEI 2011
TSP uses the MST algorithms so make sure the students are secure in this first.
It is important to distinguish between TSP and RI and which to use for what type of problem.
When teaching TSP, make sure students understand the distinction between the classical problem, which uses a complete network, and the practical problem, which almost certainly doesn’t.
When finding a lower bound for TSP, we use the method where a vertex is deleted. The resulting lower bound
DOES NOT give a tour, except in exceptional circumstances.
Students don’t understand why it is the GREATEST lower bound and LEAST upper bound.
MEI 2011
MEI 2011
Most marks (70%+) are for clearly demonstrating use of the algorithms, very few of the marks in the exam go on answers.
Examiners are trying to give as many marks as possible
Students often show signs of running out of time
There are ‘extension’ marks on every paper – usually at the end of long questions
Poor setting out and illegible handwriting makes it very hard to give marks; clear working is absolutely essential.
A satellite navigation system
Sainsburys
Home
Delivery
Snowplough clearing all the roads in a town
A courier with one urgent delivery to make
A milk tanker from a dairy collecting milk from farms
Ambulance travelling to an emergency
Cable TV company linking towns using as little cable as possible
Council re
− painting the lines in the middle of the roads
Road builder joining a few villages as economically as possible
Courier with several deliveries to make
Highways
Authority inspecting roads for fallen trees after a storm
A family on a shopping trip with several shops to visit before they can return to their car
Pedestrian precinct being created to connect places of interest in a town centre
Water pipelines being laid to connect pumping stations as economically as possible
A person planning the route to their holiday house
A parking official patrolling all the streets in an area
Classification Activity
This activity is for students who have learnt the topics of Minimum Spanning
Trees, Route Inspection Problem, Travelling Salesperson Problem and
Dijkstra’s Algorithm, to practise matching problems to techniques.
Resources needed: sugar paper, scissors, glue, set of cards
This is an activity for students working in small groups. Each group is given a set of cards to cut up and a piece of sugar paper which they divide into four as shown
Minimum Spanning Trees Dijkstra’s Algorithm
Route Inspection Travelling Salesperson
Students then discuss in their groups and stick the cards in the most appropriate section. They are then to think up one example of their own for each topic which they write on the blank cards and stick in the appropriate section.
Groups can then be paired up to compare and discuss their results, or can feedback to the whole class.
Posters can be displayed in the classroom