Post on 09-May-2018
MEI 2011
Further Mathematics Support Programme
the Further Mathematics Support Programme
www.furthermaths.org.uk
Nov 2009 - Feb 2010
Modelling and problem solving with
Networks
Sharon Tripconey
Let Maths take you FurtherLet Maths take you FurtherLet Maths take you FurtherLet Maths take you Further…………
MEI 2011
Topic AQA Edexcel MEI OCR A
Graphs Graphs D1 D1 D1 D1
Networks Prim D1 D1 D1 D1
Kruskal D1 D1 D1 D1
Dijkstra D1 D1 D1 D1
Floyd’s algorithm D2
TSP D1 D2 D2 D1
Route inspection D1 D1 D2 D1
Network Flows D2 D2 D2
Critical Path Analysis Activity networks D2 node D1 arc D1 arc D2 arc
Optimisation Matchings D1 D1 D2
Decision analysis D2
Network problems and algorithms
MEI 2011
Graph theory
� 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
Leads to network analysis
� Graph theory forms the basis of all the network algorithms
MEI 2011
Some graph theory(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 connectedif 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.
Some other terms used with graphs
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
Some other terms used with graphs
MEI 2011
Teaching tips
� 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
Networks
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 problem
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?
MEI 2011
Real life Problem
Solve the mathematical problem
Interpret the solution in terms of the original problem
Make simplifying assumptions
Define variables and decide on the mathematical techniques to be used
Compare the solution with reality – is it realistic?
Yes
Accept solution
No Review
The Modelling Cycle
MEI 2011
A problem
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 problem
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
Minimum connector algorithms
MEI 2011
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?
Avonford Fingley
Brinleigh Cornwell
Donster
Edan
2
7
45
8 64
5
3
8
MEI 2011
We model the situation as a network, then the problem is to find the minimum connector for the network
A F
B C
D
E
2
7
45
8 64
5
3
8
MEI 2011
Kruskal’s
ED 2AB 3CD 4 AE 4EF 5
Total weight of tree: 18
Minimum spanning tree
A F
B C
D
E
2
7
45
8 6 4
5
3
8
Prim’s
AB 3AE 4ED 2CD 4 EF 5
A B C D E F
A - 3 - - 4 7
B 3 - 5 - - 8
C - 5 - 4 - 6
D - - 4 - 2 8
E 4 - - 2 - 5
F 7 8 6 8 5 -
1 2 345Prim’s can also be done
on a table6
Avenford
Brinleigh
3
Edan
4
Donster
2
Cornwell
4Fingley
5 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.
Some points to note
MEI 2011
Teaching tips: Minimum connector
� 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.
Teaching tips: Minimum connector
MEI 2011
Networks
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
Dijkstra’s Algorithm
D
4
3
7
1
4
2 4
7
25
3 2
A
C
BF
E
G
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 thesequestions
MEI 2011
Dijkstra’s
Algorithm
Order in which vertices are labelled.
Distance from A to vertex
Working
A
C
D
BF
E
G
4
3
7
1
4
2 4
7
25
3 2
1 0
Label vertex A
1 as it is the first
vertex labelled
MEI 2011
Teaching tips- shortest path
� 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
Traversable graphs
Which of these graphs can be drawn without taking
your pen off the paper or repeating any edges?
MEI 2011
Traversable graphs
Yes –start and
finish in different
places
� What is significant about the results?
� Can you explain why?
Yes- start and
finish in the
same place
No
Semi-Eulerian Eulerian
MEI 2011
� An Eulerian Trail is a route that
travels along every edge once only and returns to the starting vertex
� A Hamiltonian Cycle is a closed
path which visits every vertex (once
and only once excluding the start / finish vertex!).
Touring: The underlying Graph Theory
MEI 2011
Touring algorithms
� 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
Route inspection problems
1. Identify the odd vertices in the network
2. Consider all the routes joining pairs of odd vertices and
select the one with the least weight.
3. Find the sum of the weights on all the edges
4. Shortest distance is the sum of the weights plus the
extra that must be travelled
5. Find a tour which repeats the edges found in step 2.
MEI 2011
Teaching tips: Route inspection
� 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
Teaching tips: Route Inspection
� 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.
Flight plan
MEI 2011
Terminology
� 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
MEI 2011
Solution to the TSP problem
There is no known algorithm that solves this problem �
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.
MEI 2011
Solution to the TSP problem
ower bound < optimal solution Upper boundL ≤
We just need to find a ‘largest’
lower bound that we canWe just need to find the ‘smallest’
upper bound that we can
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
Two types of problem:Classical and practical
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 problemare the same.
All complete graphs do have Hamiltonian cycles
MEI 2011
Nearest neighbour algorithmfor upper bounds
1. Choose any vertex as the starting point.
2. From the vertices not already selected find the
nearest vertex to the last one.
3. Repeat step 2 until all vertices have been selected.
4. Join the last vertex to the first vertex.
5. Repeat for different starting vertices.
6. Choose the least upper bound.
MEI 2011
An algorithm for lower bounds
1. Choose a vertex and delete it and all its edges from the network.
2. Find a minimum connector for the remaining network using
Kruskal’s or Prim’s.
3. Add in the weights of the two least weight deleted edges.
4. Repeat deleting a different vertex.
5. Choose the greatest lower bound.
MEI 2011
Teaching tips: Travelling salesperson
� 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
Network Problems Activity
MEI 2011
Exam advice
� 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
Ambulance travelling to an emergency
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
Sainsburys HomeDelivery
Cable TV companylinking townsusing as littlecable as possible
Pedestrian precinct being created to connect places of interest in a town centre
Snowploughclearing allthe roadsin a town
Council re − painting the lines in the middle of the roads
Water pipelinesbeing laid to connectpumping stations aseconomicallyas possible
A courier with one urgent delivery to make
Roadbuilder joininga few villages aseconomically as possible
A person planning the route to their holiday house
A milk tankerfrom a dairycollecting milkfrom farms
Courier with several deliveries to make
A parking officialpatrolling 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