APPLICATION HL Oxford CH 15
APPLICATION HL Oxford CH 15
APPLICATION HL Oxford CH 15
networks: graph theory ot viewpotts are given inthe ble below The
entrance to the park is at A.
\ problems
4 4 Before you start
7 = = Click here for help
You should know how to: Skills check with this skills check
How can the driver 1 -1 0%
ofa snowplough 1 Raise a matrix to an integer power. 1 IfA=|2 1 1 find
ensure that they eg if A= 2 -17 find A‘. -1 0 2 )
clear every roadina 1 0, a Az b At.
town after a blizzard . a {5 -4
as efficiently as Using a GDC: A* = 43
possible? . 0.8 0.3 4 a
2 Find the steady state vector for a 2 Let P= 02 07 be a transition matrix in
transition matrix. ~
eg Find the steady state vector for the which the probability of moving from state
01 06) ito statej is P..
How cana
postman deliver transition matrix P = 09 04! a By forming a system of linear equations
J find the steady state vector.
letterstoevery | — b Verif . a
4 _ O.1x+0.6y =x erify your answer is correct by
—_—— = 3 house on their Form equations _ calculating large powers of P.
How could an. electrical engineer
Ss model j a: hole | f route while
inimizing th 0.9x +along
Solve either of these 0.4y with
= y x + y= 1: ¢ What is; the long-term probability
‘li of
the connections on a circuit board? minimizing the being in state j?
distance they x= 0.4, y= 0.6
travel?
690 691
) AL te er mia 15.1
15.1 Constructing graphs B The third row shows that you need to add
For the opening problem you may have drawn a diagram A 4 B A the edge CD.
like this. This is a graph.
D The final row includes no extra edges. Use it
to check your graph is drawn correctly.
Agraph is defined as set of vertices and a set of edges.
c
Avertex represents an object. An edge joins two vertices. c
b eg ABCD, ACD or ABACD There are infinitely many answers to part b as
you can pass through each vertex and along
In the graph of the national park the viewpoints are the vertices
each edge as many times as you like.
of the graph. The trails are the edges. FO o35 4G
In mathematical graph theory, graphs do not have to be drawn to scale
and the positions of the vertices do not need to relate to their positions TOK
in the real world. A graph will always show which vertices are directly Example 2
connected. Have you heard of the
The table shows costs in dollars of travelling ATER RCH ROR IEE
Seven Bridges of
The graph above also shows the distances between vertices. A graph that by bus between towns. A 4(?7/6
Kénigsberg problem?
shows values like these (called weights) is called a weighted graph. Show this information on a graph. B 5
KGnigsberg is now
The “weight” can be any quantity, such as cost, time or distance. Kaliningrad in Russia. ic 5 3/6
The map of the London Underground is a famous example of an Do all mathematical D 2
unweighted graph. It gives no information regarding the distances problems have a &8Qo
LNT E NN
E 2
between the stations, only the connections between them. solution? 3
aEa
A 4 B Because the costs are given in the table you must I
»J
LPPEL
Awalk is any sequence of vertices passed through when moving also show them on the graph. a
along the edges of the graph.
6 5 Note that there are many different ways to draw
the graph, eg:
In the graph of the national park ABC and ABDBC are both walks
from A to C. Dé Bog Bo 5 c¢
3 c c
The information in an unweighted graph can also be contained in 4 4 6
2
an adjacency table. In an adjacency table the entries indicate the 6
6
number of direct connections between two vertices.
A s E
E
E 6 2
Example 4 6
The table shows the connections between stations on a D 2 D
small mountain railway. An empty cell indicates no direct
connection between the stations. 7
A c
a Show this information on a graph. 3
4 7 ° 5
b Write down two possible walks from A to D.
D 2 E
692 693
15 AL te er mia 15.1
5 Draw unweighted graphs to represent the b A! B c D
Exercise 15A
tables below. A 1 in the intersection of row
i and column j indicates that there is a a 1 1 1
1 State which of the graphs represent the 2 Draw a table to represent the number of
connection from i to j. B 1
information given in the table. direct connections between the vertices in
AB c D E
the graphs below. a alp{cilo c 1 1
1 1
a B b Ss A 1 1 D 1
B 4
ic 1 4
D 4
6 A salesman needs to travel from Sheffield to Manchester to Nottingham and then back
to Sheffield. A route finder algorithm has been programmed with the data in the table
3 Draw the weighted graphs represented by
below, showing distances in miles between the major cities in England. Unfortunately the
aa B the tables.
information on the distance from Manchester to Nottingham has not been included.
E a A Bic oD/E a Write down the distances from Sheffield to Manchester and from Nottingham to Sheffield.
F A 15 | 12 10 In trying to give an estimate for the shortest distance the algorithm will find the shortest
D c B | 15 13 9 distance from Manchester to Nottingham via one other town. To do this efficiently it needs to
reduce the table as much as possible. &8Qo
c | 12 12
LNT E NN
b B b Explain why all those towns further than 77 miles from Manchester can be excluded from 3
D/ 10 13 | 16 aEa
the search.
E 9 | 12 16 €
c F ¢ Draw a graph showing all remaining routes from Manchester to Nottingham which go via e»a
LPPEL
one other town.
b aAleilclole d Hence state an estimate for the shortest distance the salesman must travel to visit the two
A 6 | 10 towns and return to Sheffield.
D E B 6 ? — | o
c B c 10? |
5 _ 5 fe 5 € 2
D 5| 3 $ & 2 2 3 5
2 3 >| 5 o gs 2
A c E 5 e/e/2)/s|e)/e)/2E/e)s)e\e)e) 2/5) 8
o oO a a a a a = z z z So a “wn n
(3 4 Draw weighted graphs represented by the York 129 217 88 292 25 97 194 65 82 | 181 80 174 | 252 53 | 239
tables below. Each table is read from row to Southampton | 128 74)| 164) 107 229 217 77 | 208 319) 190 160 65 1? | 195
column so the weight of the edge from A to
D F Sheffield 76 164 32 | 240 34 72, 160 38 128 | 146 39 130 | 208
B is 10. You will need to decide how to show
Portsmouth 141 94 175 124) 242 231 71 | 222 332 | 184 173 78
dF B the fact that A to B is not necessarily the
same as B to A. Oxford 63 70 90 1414 163 153 56 | 144 254 | 141 95
LNT E NN
The graphs from Exercise 15A question 4 are directed graphs. A 10 8B a Show this information in a graph with each edge representing a
3
handshake between two people. aEa
The graph drawn in question 4a is a connected, directed graph; I
b From the graph write down the total number of handshakes that take »J
sometimes this is referred to as weakly connected. T By AB
LPPEL
place before the meeting. a
It is possible to go from A to D, for example, but not from D to A. 2 If possible, draw a graph consisting only of vertices with the degrees
The graph drawn in question 4b is strongly connected. It is ° 12 C listed. If itis not possible, explain why not.
possible to go in both directions between any two vertices. 10 fae eee 22,2 CRC He nS eS) d 2,2,2,4
A B
The context often makes it clear whether a directed or undirected a 3 From your graphs in questions 4 and 2, can you find a link between the
graph is required. For example, a bus may go from town A to degrees of the vertices in a graph and the number of edges? If necessary
6
town B but not make the reverse journey. = draw more graphs and record the degrees of the vertices and the number
of edges.
gars When is it appropriate to use directed or undirected D 8 c 4 Using your result from question 3, explain why itis not possible to construct
graphs? a graph with a degree sequence of 3, 2, 4, 1, 5, 2, 3, 3.
The degree (or order) ofa vertex in a graph is the number of edges with that
vertex as an end point.
ercise 15B
A vertex whose degree is an even number is called an 1 A group of people share several attributes An edge represents:
even vertex or is said to have even degree. ‘A which can be shown in a graph, with a_ lives in the same block as
the five people as the vertices. The edges b
The degree of each vertex in the graph shown is: is the sister of
represent the connections between them.
A2,B3,C2,D4,E
3, F2.
For the following connections discuss ¢ isa friend of
whether it would be best to draw a directed d_ isa follower on Twitter of.
or an undirected graph.
696 697
A bs) AL te er mia 1 5 . 2
2 a Draw a table to show the information 5 The table shows part of the time-table for
Fees conte
contained in each of the following
a : :
the ferries on Lake Starnberg in Germany.
: Developing
i
inquiry
i i
skills
1
i top (village) In the opening problem, you drew a graph to represent the
Starnberg 9.35 | 12.00 | 14.30 information in the table. Check that your graph is a weighted
Possenhofen 10.07 14.44 graph that contains all of the information in the table.
Tutzing 10.34 15.06 Is the graph connected?
“Ammerland | 12.44 | 15.22 State the degree of each vertex.
Bernried 10.49
Ambach 13.01 15.39
b State whether each of the graphs is ‘Seeshaupt 11.08 13.23 | 15.58 1 5.2 Graph theory for unweighted graphs
connected, strongly connected or not
Ambach 11.32
connected. - Often, we are interested only in the connections between vertices and not
3 a i Drawan unweighted directed graph Bernried 13.48 16.23 in the weights of the edges.
information given in Ammerland 114.51 | | . . . .
the followingthe table
containing - Examples of such situations might be a map of a metro system, connections
8 . Tutzing 12.08 14.08 | 16.43 on an electronic circuit board or in a large file-storage system, or a network
A\/Bic/D Possenhofen 1434 17.09 of friends on social media.
A 1 1 Starnberg 12.28 1450 17.25 aay
B | 1 |2
cli[1 1 Et
Dot 1 mw
“2
ii For each vertex state the in-degree
and the out-degree.
b i Drawa weighted directed graph
containing the information
represented by the following table.
698 699
A bs) AL te er mia 1 5 . 2
Wi D Y.
c c
Investigation 2
a AB D I directed ha | is sh
AfoO 120 \
. n an um me ee Bray a oop 1s . Own @s 1 Forthis graph find the number of walks of the given length between the
a 2 in an adjacency matrix (as going both . . ,
es . two given vertices. Write down each of the walks. B
Bll 01.0 ways along it is possible).
bl o 1 a length 2 between A and C a
b length 2 between C and C
D\o 0 1 2,
c length 3 between
A and C
d_ length 3 betweenD andD D
b ABCD In this graph the loop is shown as a 1 in the . . . c
A(o 11 0) adjacency matrix as the edge is directed. 2 a Find the adjacency matrix
M for the graph shown.
700 701
) AL te er mia 15.2
3 Use the adjacency matrices M to answer the
6; Draw a directed graph of your own and verify that the conjecture in following questions. 3 =
question 2c still holds. a ABCD 5 z 3
a go
4 cur How do you find the number of walks of length 7 between two A(o 110» x 0 2 s gy E
vertices in a graph? Bll 010 & a 8 $ Ze 3
5 Explain how the matrices M, M? and M? can be combined to give a matrix cli 101
which shows the number of walks of length 3 or less between the vertices pioo 10 \
of the graph. ft Castlebay ; ° ; ; ; 4 ;
Ei
6 cary What can be calculated from the powers of an adjacency b A BBCODE Lochb aa lel 000001
in? ochboisdale
Mes A(O 1 0 0 0° .
, A . Mallaig 0000100
? cay How can you use the powers of an adjacency matrix to find the B}l 0 1 00 R 0101000
minimum length of path between two vertices? clo 10311 wm
Tiree 1000001
8 QIronry How does the adjacency matrix allow you to analyse the DJO 0 10 1 Tobermory |1 0 100 1 0
paths between two points on a graph? Elo 0 1 10 Y 7
a Find the number of routes you can travel
i Find M? and M?. to get from Lochboisdale to Castlebay in
ii Write down the number of walks of three ferry trips.
&8Qo
LNT E NN
Let M be the adjacency matrix ofa graph. The number of walks of length 77
| J. 5 : i length 2 between C and A. b By considering the powers of the adjacency 3
from vertex 7 to vertexj is the entry in the 7th row and the jth column of M”.
iii Find the number of walks of length 3 or matrix find which ports it is possible to get
aEa
The numbers of walks of length r or less between any two vertices are given less between C and A. to from Tiree using the ferry system. I
»J
LPPEL
by the matrix
S, where S. =M+M?+...+.M" An extra ferry route is now added between a
The diameter of a graph is the length of the
Mallaig and Lochboisdale.
maximum shortest walk between any two
vertices (so all the vertices can be reached ¢ Write down the new adjacency matrix
Exercise 15D from any other vertex in a walk of length and hence state the two ports that are
less than or equal to the diameter of the furthest apart.
1 The adjacency matrices for the graphs in d ABCODEFE graph). a Use the directed graph you drew for
Exercise 15C question 1 are shown A(o1l001 0) iv Use the powers of the adjacency matrix Pxerese 15B seston 5 a Wie down
below. Bloo 1000) to find the diameters of each graph. an adjacency ee a s Soy)
| Justify your answer. connections on Lake Starnberg.
0 ABCD b ABCD cjo 0 1 1 0 0) . . . b By taking a suitable power of the
Afo 101 A(o 10 0° DjO 10 000 4 The lollowing adjacency matrix shows the adjacency matrix find all the pairs of
1011 Blo 001 Ell00101 connections between some ports in the towns that are not connected directly or
B | Shetland Islands off the coast of Scotland. with at most one stop, stating clearly the
cjo 101 cjo 100 F(O 0 0 0 0 0) The ferries go in both directions between direction of the connecuaa
DI 1 1 0 DU 0 1 0, each pair of ports.
Use these matrices to find the number of
walks of length 3 between:
c ABCODE i AandA ii CandD.
A(O 10 0 1° In each case use the graphs in Exercise 15C
BJl 0 1 1 1 question 1 to verify your result by listing all
clo 1010 the possible walks.
Dio 1101 2 By considering an appropriate power of a
Ell 1010 matrix, verify your answer to Exercise 15C
question 4 part ci.
702 703
a 5 AL te er mia
coy How might you work out the maximum number of steps Example 5
necessary to move between any two vertices on a graph? Matrices are used in In this graph vertices A to F represent web pages and the edges
How can we use powers of the adjacency matrix to determine whether or computer graphics for three- indicate links between the pages.
nota graph is connected? dimensional modelling. For example, page A has links from both C and F and contains
How can this be used in real- links to B, D and F.
life situations in other areas
a Construct the transition matrix for a random walk around
of knowledge?
Transition matrix this graph.
A random walk on a graph is a walk in which the vertex moved to is b Find the steady state probabilities for the network.
chosen randomly from those available. Hence rank the vertices in order of importance.
In a graph with a finite number of vertices a random walk is a finite
Markov chain. a The transition matrix is For example, A has three edges connecting
HINT \ it to vertices B, D and F, and so each of these
A transition matrix can be constructed for both directed and undirected 1 1
graphs. See Chapter 9 for a) F 0 0 3 has a probability of 4 which is shown in the
an introduction to t 0 : : 00 first column of the matrix.
The probability of moving from one vertex to any of the adjacent vertices
Markov chains.
is defined to be the reciprocal of the degree of the vertex in an undirected ‘ Because the question does not specify which
graph and the reciprocal of the out-degree in a directed graph. 000-00 method to use, you can just look at high
&8Qo
LNT E NN
As discussed in earlier chapters, the probability of moving from vertex 1 5 powers of the transition matrix using your
3
i to vertexj will be the entry in the ith column and jth row of the 3 10010 GDC. aEa
matrix. I
ooo002 You need to consider powers large enough »J
LPPEL
2 to ensure there is no change in the third a
The direction of movement in a transition matrix is opposite to that in an EXAM HINT 1 significant figure. An alternative would be
adjacency matrix. 3 90 3 00 g to solve a system of six linear equations or
Within the IB
diagonalize the matrix.
syllabus questions
will only be set in b The steady state probabilities are given
The steady state probabilities indicate the proportion of time that
which the graph is by the vector
would be spent at each vertex if a random walk was undertaken for a
long period. The transition time between the vertices is ignored. connected. In the
A} 0.130
case ofa directed
The Google PageRank algorithm was developed by Larry Page and graph, it will be 0.207
Segei Brin in 1996 while working at Stanford University. They wanted
mmoaw
strongly connected. 0.109
to be able to rank web pages in an Internet search so that the ones
0.326
most likely to be useful come towards the top of the list.
0.076
The algorithm they developed considered links from web pages as the EXAM HINT
0.152
edges in a directed graph. The steady state probabilities calculated from
Ifa walk around a
the transition matrix indicate which site would be visited most often
graph is equally c¢ The ranking would be D, B, FA, C, E. | The vertex with the highest probability is
if someone were randomly clicking on links in web pages. This site
likely to take any of placed at the top of the list.
would come top of the list in a search.
the edges leading
The justification for this ranking is that the sites most likely to be from a vertex, it is
visited will either have lots of links to them, or be linked to by sites called a random
with lots of links going to them. In either case this is likely to reflect | Reflect | How do you construct a transition matrix fora given graph?
walk.
their relative importance. $a
—$
Why might a random walk indicate the most important sites on a graph?
How can the steady state probabilities be used to rank lists?
704 705
) AL te er mia 15.2
following way: having chosen a starting 5 Explain why the long-term probabilities
1a eh]
page he will then move to another page by for this graph will not be independent of
choosing randomly from the list of possible the starting position.
1 For each of the two graphs below find the 3 The following diagram shows four
links on his current page.
transition matrix, P, and hence the steady websites. The arrows indicate a link from c
state probabilities by: one of the pages to another; for example, a Show the information from the table in
i considering high powers of P there is a link from website D to website C. a directed graph. B
A E
—
A B
ii solving a system of linear equations. b From the graph explain why it is not
7 nl b ‘A
——.@ possible for George to visit each of the
friends’ pages in the first six pages he '
5 3 | a | | looks at if he begins on Antoine’s page.
© @ ¢ Determine whether it is possible to visit Write down the probability that a a
D each of the friends’ pages in the first six random walk would end at vertex A if it
c D visits if he begins on another page. If so, began at vertex B.
a Write down the transition matrix to give a possible order; if not, say why not. If X is the number of steps it would take
c c represent a random walk around this for the walk to reach A from B find E(X).
graph. d Construct a transition matrix for your
In an experiment on artificial intelligence graph. Find the transition matrix for the graph.
a robot is put in a maze which has six b Show that it is not possible to link from B
George begins by visiting Antoine’s page. By evaluating high powers of the
rooms labelled A to F. Each of the rooms to C using exactly three links, and write
transition matrix find the long-term
has gaps in the wall connecting it to down two other connections that are also e Find the probability he is back on &8Qo
LNT E NN
not possible using exactly three links. probability of being at vertex E if you
adjacent rooms. Antoine’s page after visiting five further 3
began at vertex C. aEa
pages.
| I ¢ By solving four linear equations find:
—
I
E A i the steady state probabilities f Determine the probability he visited »J
LPPEL
a
ii the proportion of time that a person the pages in the order Antoine, Belle,
D following random links will be on Charles, Dawn, Emil, Antoine.
| ___| 8
c site B. g George continues moving through the
1
d Based on this information write down the web pages in the same way for a long
a Draw the maze as a graph, with the order in which the sites might be listed by time. Find which page he is likely to
vertices representing the different rooms a search engine, giving the one with the visit:
and the edges representing the gaps largest steady state probability first. i the most ii the least.
between rooms.
Within a large social network links can
The robot moves randomly and once in a
be created from one person’s page to
room is equally likely to leave through any
another. A small group of people share links
of the gaps.
according to the table below. For example,
b Write down a
maze.
transition matrix for the from Antoine’s page it is possible to link Developing inquiry skills
directly to the pages of Belle, Charles and
In the opening problem, whatis the minimum
¢ Ifthe robot begins in room A, what is Emil.
the probability it is again thin room > A after
ae ough f Antoine Belle Charles Dawn Emil _—Frances. any
Roe the viewpoints?
two ofee ae ee ee ticeD
passing through four of thehichgaps? Belle SSAntoine Antoine Emil Antoine Dawn .
Reaierect nett per cand rest ancterit
at oe
likely by che
visited by
iy toto bebe visited robot,
the robot. Charles
Emil Charles Belle
Dawn Frances Dawn travellin g Aftera long period of
along trails.
. | time a rescuer went out to try and find him.
ii Pe mine the eens or ne George is also part of the network and Given that the rescuer decidesto wait at one
thatthe robot will be in each of these 5 ps a
friends with all those listed. He decides of the viewpoints,which ene should they
pOOTS. to visit the pages of each of them in the choose if they want to maximize the chance
that the walker will pass through that
viewpoint first.
706 707
) AL te er mia 15.3
15.3 Graph theory for weighted You need to learn two algorithms to find the minimum spanning tree,
Kruskal’s and Prim’s algorithms.
Example 6 a. 1 ne @
Use Kruskal’s algorithm to find the minimum cost of 5 3
connecting all the houses on the estate. The costs of A 3 8) 94 3 E
~ connecting each pair of houses is shown on the
Atree is a connected graph which has no cycles, such as TOK weighted graph. The weights are the costs in €1000 of
the one shown on the right. a connecting the houses.
Is imagination more
&8Qo
LNT E NN
Aspanning tree for a graph is a subgraph which is a tree and important than
1 Find the edge of least weight anywhere 3
contains all the vertices in the graph. knowledge? aEa
in the graph. If there are multiple edges I
with the same weight any may be chosen. »J
LPPEL
a
In this example any of the edges of weight
The two trees below are both spanning trees for the given graph. 3 can be selected.
Bo4 C 4 OD Bo4 C 4 OD 2 Add the edge of least weight that has not
5 3 5 3 already been selected and does not form
A 3 45 i ) 3 E A E | a cycle with the previously selected edge.
3 Add another of the edges of weight 3.
4 4 4
H 6 G 7 F H 6 G 7 F
H
Let the graph represent new houses built on an extensive estate and B D 3 Repeat the second stage until all the
the weighted edges the costs (in €1000s) of connecting them to mains vertices are connected.
electricity. : The next edge added will be the third of the
7 ii q e edges with weight 3. The fourth one cannot
If connected using the first tree the total cost would be €33 000, and
4 be EF as this would create a cycle and so
with the second it would be €38 000. H F AH, BC or CD is added.
The problem that needs to be solved is finding the spanning tree
of least weight, which is normally referred to as the minimum
All the edges of weight 4 are added next.
spanning tree.
Neither of the edges of weight 5 can be
The minimum cost solution cannot contain any cycles. If there were a added as they both form cycles, so GH of
cycle the edge with greatest weight could be removed and the houses weight 6 is added. All the vertices are now
would still be connected. connected.
Cory What would be the least-weight way to connectall the vertices in a The minimum cost for connecting all the
graph? houses to electricity will be
44+3+4+4+3+3+6=27, ie €27000
708 709
A bs) AL te er mia 1 5 . 3
anm\oal\o>
be in a spanning tree containing v vertices 20 | 0 9} 16 24 ) 15 | 10 find the weight of the new minimum
EXAM HINT Justify your answer through a consideration 12| 9 | 0 | 22 | 16 | 10 | 12 | spanning tree if:
of the application of Prim’s algorithm.
Itis likely an exam question 23 | 16 22 O. 19 | 13 | 18 the weight of the edge connecting I
4 The following graph shows the offices of a ] to A is 9 and to B is 10
will require this as evidence 11 | 21 | 16/19 O 16 | 12
you have performed the finance company. The management wants } ii the weight of the edge connecting I
to connect all the offices with extremely 20 [F215 4.10} 13 0.16 f}_0_Mes to
A is 5 and to
B is 6.
algorithm correctly.
fast internet cables. The costs of doing so (in 15/10 12) 18 12 | 25/0 |
$1000s) are indicated on the graph below.
Ts
a
fi
F
LNT E NN
necessary condition.
Ts) 3
aEa
3 Isit possible to draw this graph without taking your pen off A Peer ae €
the paper? If so, find at least two ways this can be done, e»a
LPPEL
starting from at least two different vertices.
Cees
4 a Whatdo you notice about the starting and finishing
vertices and the degrees of the vertices in the graph? ent
tre
bi Crone Conjecture necessary conditions for > c é aa
being able to draw a graph without taking your pen
off the paper, ending at a different vertex from the
one at which you began. The maintenance department needs to begin and end their clearing at the
ii Draw some graphs to verify your conjecture. estate office.
iii Justify your conjecture. 1 What would be the minimum time to clear all the paths if none of the paths
needed to be repeated?
The results from Investigation 3 can therefore be summarized as follows: 4 Inwhich order
! would you recommend the maintenance
main’ department clear
the pathsif they are to take the least possible time?
e Fora graph to have an Eulerian circuit all the vertices must have
even degree. 5 Given that there is an easy alternative to taking the path from the estate
office to the gym (go via the theatre instead), it is decided that the direct path
e Fora graph to have an Eulerian trail there must be exactly two odd does not need to be cleared. How much time would be saved by not clearing
vertices, and the trail must begin at one of these vertices and end at
this path?
the other.
It can also be proved that every graph whose vertices are all even will
have an Eulerian circuit and every graph with exactly two odd vertices
will have an Eulerian trail.
A bs) AL te er mia 1 5 4
One way to think about this is to add a second edge between the 3 The following graph represents bus routes
vertices on the repeated route. This creates a graph with just even b 7k A between towns,
” and the
" weights are the
i" aay
vertices, and hence there is an Eulerian circuit. Fo 35 8B 5 4 eaeihe oy ee ce ee
20 F B 2
a5 i c t all the routes and return to A as cheaply as Ee
Example 9 rn
(@)
4
50 30
7] < |e possible. a
raf
Solve the Chinese postman problem (find a route of least weight) 4 — 45 D a ad A 6 B 7 C
for this graph, beginning and ending at A, and find the total 5, B 4 5
weight for this route. : | P D 5 4/ \5 6
2 a Explain why the following graph has 3. b.-€ 3.
8 c an Eulerian trail but not an Eulerian 4 oy °
Z| 4 circuit. F
The total weight is 48 + 11 =59 The weight of this route will be the weight
of all the edges in the original graph plus
the weights of the repeated edges.
716 71?
A bs) AL te er mia 1 5 4
Investigation 5
1 The graph on the right has four odd vertices. List these vertices. 56
To solve the Chinese postman problem for this graph you will need to connect the
odd vertices in pairs and find the route of least weight between them. You should
then select the lowest of these as your solution.
2. List the three pairings of the four vertices and state the weight of the least-
weight route connecting the vertices in each of the pairs. 61
3
3 Show, ona copy of the graph, the routes connecting the pairs which have the a Find a possible route he could take in
least total weight. Hence solve the Chinese postman problem, beginning and order to minimize the distance he has to
ending at vertex A. a Finda route which minimizes the length walk and state the length of this route.
of his walk and state its length. Fully justify your answer.
4 Find the total weight of the route of least weight that will traverse all the edges in b A friend offers to drop him off at one b A friend offers to pick him up from
Ebeletaphlat||east ances of the vertices and to pick him up at vertex H at the end of his round and
The requirement to start and finish at the same vertex is now removed. another. State which two vertices should take him back to A. Explain why this
be chosen to minimize the distance the would not decrease the length he would
5 Use the weights listed in question 2 to find where you should now choose to start and finish. security guard has to walk. have to walk.
6 gary How many extra possible routes do we need to consider when the graph has four vertices of 3. The graph below shows the roads that ¢ State where would you advise the 9iy
odd degree? need to be taken by a postman when postman to be collected in order to = FI
a By
2 (ECO ITSD How does an understanding of an Eulerian trail help determine how the algorithm should delivering letters. The weights on the edges minimize the length he needs to walk, Ei
be adapted if the trail does not have to begin and end at the same vertex? are the lengths of the roads in metres, and and find the total length of the repeated a =
What does the solution to the Chinese postman problem represent? the postman needs to start and finish his roads in this case.
deliveries at vertex A.
itt et |
718 719
) AL te er mia 15.5
15.5 Graph theory for weighted The diagram on the right shows a complete graph with five vertices.
Construct a table of least distances to show the shortest journey times c 2 (EPTED write down a formula for the number of Hamiltonian cycles in a
between each pair of towns. Assume that there is no need to change buses complete graph with 7 vertices.
&8Qo
LNT E NN
on any of the journeys. 3 There are about 10®° atoms in the universe. How many vertices would 3
D there need to be in a complete graph for the number of Hamiltonian cycles aEa
I
to exceed the number of atoms in the universe? »J
A B Cc D From the graph we can see that the shortest
LPPEL
routes from A to B and to C are just the Before doing the calculation guess what you think the answer might be,
a
y o sO eS AOS, direct connections, but from A to D the and then compare this guess with the calculated value.
B | 50 shortest route will be via C.
c 45 Because the graph is undirected both the first
D | 105 row and the first column can be completed. Investigation 7
Normally a direct route will be quicker than
A B c D «
a route that passes through other vertices,
A 0 50 | 45 | 105 but it is important to check. In this example
B 50 0 95 70 it is shorter to go from B to C via A, which
c!45/95!0 60 takes 95 minutes.
D | 105 | 70 | 60 0 In the context it might be that the direct
route is over poor roads or has more stops
on the way.
A path is a walk which does not pass through any vertex more than once. A TOK
cycle is a walk that begins and ends at the same vertex, but otherwise does Hamiltonian paths and
not pass through any vertex more than once. cycles are named after In the diagram the vertices represent towns and the edges represent the costs
A Hamiltonian path or cycle is a path or cycle which passes through all the the 19th-century Irish of flying between those towns. A salesman wishes to visit all the towns and
vertices in a graph. mathematician William return to his starting point at A.
Acomplete graph is one in which every vertex is directly connected to every Rowan Hamilton. 1 Whatis the minimum number of flights he would need to take?
other vertex. 2 Explain why the total cost of visiting all the towns would be greater than
$640.
720 721
a 5 AL te er mia 15.5
6; Find the weight of any Hamiltonian cycle beginning and ending at A. The best upper bound is the upper bound with the smallest value. )
4 Use your answers to questions 2 and 3 to give a lower and an upper bound
for the cost of visiting all the cities. A method that is likely to give a better upper bound is the nearest
5 Inorder to try and find a cheaper route the salesman decides that he will neighbour algorithm.
take the cheapest ongoing flight from each airport that takes him to a town
The algorithm has two stages:
he has not already been to and then back to A. Find the cost of the route if
he follows this method beginning the algorithm at A. 1 Ifthe graph is not complete, create a table of least distances
6 Investigate the cost of visiting all the towns if he begins the algorithm ata (weights) showing the shortest route between each pair of vertices.
different town. 2 Using your table (or the equivalent graph) choose a starting vertex
? Which of the routes you found would you recommend he take, beginning and move around the graph, always going to the nearest vertex that
at town A? has not already been included in the cycle. Once all the vertices
have been visited, the shortest route back to the starting point is
8 Can you find a cheaper route? How likely do you think it is to be the
taken.
cheapest? Justify your answer.
EXAM HINT
Completing a table of least distances converts a practical TSP into a classical In exams if there is
The classical travelling salesman problem (TSP) is to find the TSP because it ensures that the graph is complete and so a Hamiltonian cycle
Hamiltonian cycle of least weight in a complete weighted graph. more than one route
exists.
between vertices the
The practical TSP is to find the walk of least weight that passes
pue fiuyawioag
PEDO EN
route of least weight
through each vertex of a graph, starting and finishing at the same
The algorithm should only be used on a complete graph that satisfies between them is
vertex. In this case the graph need not be complete.
the triangle inequality (which means the direct route between two found by inspection.
One context for the practical TSP would be a salesman needing to adjacent vertices is always the shortest route). This will always be If there is a direct
visit a number of towns and return to his starting point in the shortest the case when working with a graph or table that shows the least route between two
possible time. distances.
vertices this is often
From the investigation you will have realized that finding the weight the shortest route, but
of each cycle individually to see which is shortest would take a it does not have to be.
considerable length of time.
Unfortunately, it has been shown that there is no other simple way to
guarantee that a route you have found is indeed the shortest.
Example 11
Instead you need to find upper and lower bounds for the solution
which will give a range of values in which the solution must lie. This graph shows the connections between seven cities. A driver
needs to make deliveries to all of these cities, beginning and
One procedure for doing so is illustrated below. ending at city A. The weights are the driving times between the
cities, measured in hours.
Finding an upper bound oa 8 a The table of least distances is given below. Find the values of a,
The graph shows the connections between seven cities. NC ae
bandc.
A driver needs to make deliveries to all of these cities, ay 9
beginning and ending at city A. The weights are the driving [> ~e | A|B|C|D|E 6 :
times between the cities, measured in hours. " o]a/af23}41{s5 | 10 21
7
aiaim|o\o\o|>
Any route that passes through all the vertices and returns a 11 9 | 16] p | 10 | 15
to the starting point would be an upper bound for the a 0 16 | 12 | 10
solution to the TSP as the shortest route cannot have a
greater weight than this route. 23|16| 7 |o | c¢ | 18 | 43
11 | b 16 c 0 11 | 6
For example, by inspection ABFCDGEA is a cycle so its length would
be an upper bound, namely 11 + 10+ 12+7+13+6+11=70 hours.
It is unlikely though that this is the best possible upper bound. 10 | 15 | 10 | 13 6 5
LNT E NN
5
cl a| 9 | 0 | 7 | 16 | 42/10 3
aEa
D | 23) 16 | 7 c | je| 13 I
»J
E|ir| > |16| c | 0 | sr] 6
LPPEL
a
F | #| 10 | 12] 18] 11 |e KS)
6 | se] 15 | 10/13] 6 | s| 0
The final solution is: So beginning at A the shortest distance is to F.
These two columns are crossed out as shown
AFGECDBA with weight
and the F row is used to find the next edge of
5+5+6+16+7+16+11=66
least weight, which is [FG].
Hence an upper bound for the length of After reaching the final vertex you must Finding a lower bound
time the driver would take is 66 hours. return from this vertex to A. For a graph with v vertices a solution to the TSP will need to traverse
at least v edges, so one lower bound would clearly be v multiplied by
c The actual route would be Though no vertices are repeated in the table, the weight of the edge with least weight or the sum of the v lowest
AFGEGCDCBA and so towns G and C some of the shortest routes between towns weights. In most cases this is not likely to be a good lower bound.
would be passed through twice. pass through other towns. These need to be
included if the driver’s route has to be given. An alternative is to use the deleted vertex algorithm.
The procedure is as follows. HINT
1 Choose a vertex and remove it and all the edges incident to it from This algorithm should
the graph. also be used only
on a complete graph
Cory What algorithms can you use to find an upper bound for the TSP fora TOK 2 Find the minimum spanning tree for the remaining subgraph. that satisfies the
particular graph?
How long would it takea 3 A lower bound is the weight of the minimum spanning tree plus the triangle inequality.
computer to test all of the combined weight of the two edges of least weight removed in step 1. This will always
Hamiltonian cycles ina be the case when
complete weighted graph 4 The process can then be repeated by removing a different initial vertex.
The best lower bound (the one with the largest weight) is then taken. working with a graph
with just 30 vertices?
or table showing least
The example below includes an explanation of why this algorithm
gives a lower bound. distances.
724 725
) AL te er mia 15.5
Example 12
Find a lower bound by deleting vertex A from the graph. Could we ever reach a point where everything important in a mathematical sense is
known?
What does it mean to say that the travelling salesman problem is “NP hard”.
Is there any limit to our mathematical knowledge?
With vertex A deleted, the minimum Explanation of why this will give a lower bound:
spanning tree is The actual solution to the TSP is
1 For each of the tables of least weights ERECH/ MON REN EENIEC
produced for the graphs given in Exercise
151, question 1:
a [11 |17] 23 | 11/5 | 40
ainim\|olo\|o|>
i find a lower bound using the deleted 11| 0 | 9 | 16 | 21 | 10 | 45
vertex algorithm and deleting 17/9 [a]? | 16| 12 | 10
vertex A 23/16| 7/0 | 19| 18) 13
ii find a higher lower bound by deleting a 11/21 /16/ 19/0 | 11 6
different vertex
This has weight 25.
iii use the upper bound calculated in Exercise
s | 10/12/18 /a1]/a]s
151 plus your answer to part ii to give 10 15 |10) 13 | 6 5 0 &8Qo
LNT E NN
When A is deleted the remaining part of the
bounds for the solution of the TSP. 4 The complete graph below shows the times
3
aEa
solution to the TSP will clearly be a tree, and so
the weight of this part will be greater than or Answer the following questions which in minutes to walk between five shops in a I
»J
LPPEL
equal to the weight of the minimum spanning relate to the graph below. city.
a
tree. In this example it is 28. A 40 B
The two deleted edges of least weight A is reconnected using the two edges of least 10
have weights 5 and 4. weight. The combined weight of the two edges 15
incident to A in the solution of the TSP will be 25 30
greater than or equal to the combined weight of 10
20
these two edges. In this example they add to 11.
D 40 c
a By deleting vertex E on the graph, use
A E
the deleted vertex algorithm to find a
lower bound for the TSP. a Use the nearest neighbour algorithm to
b Complete a table of least distances for find an upper bound for the length of
Lower bound is 25 +5 +4=34 The total weight of edges produced using the time to walk to all of the shops, starting
this graph.
algorithm will therefore be less than or equal to and ending at A.
the weight of the solution of the TSP, which in ¢ Use the nearest neighbour algorithm to
the example is 28 + 11 = 37. find an upper bound for the TSP. b Use the deleted vertex algorithm to
d State what you notice and explain the verify that 21 minutes is a lower bound
reason for this. for the time to walk to all the shops.
c By consideration of the edges adjacent
In Example 10 an upper bound was found
HINT to C and to E explain why it is not
for the time it would take for a driver to
possible to find a cycle with length 22
If the weights are given ina travel between seven cities. The table of
I Reflect | How do the algorithms used in the travelling salesman problem help or less.
table then Prim’s algorithm least distances is shown. Use the table and
address the fact that it is often not possible to test all the possible routes? d_ The shopper decides they still need to start
can be used to find the Prim’s algorithm to find a lower bound
How can you make sure that the nearest neighbour algorithm and the for the above problem, by first deleting and finish at shop A but their last visit
minimum spanning tree,
deleted vertex algorithm will give the upper and lower bounds for a vertex A. before returning to A has to be to shop B.
practical TSP? having removed the rows State how the nearest neighbour algorithm
and columns of the deleted might be adapted to allow for this.
vertex.
726 72?
) AL te er mia 15
Chapter review here for a mixed (EY
Chapter summary
e
/ .
Agraph is a set of vertices connected by edges.
@ - Explain why the graph shown has a
Eulerian trail.
b
review exercise
LNT E NN
Eulerian circuit around the graph formed. State the weight of the minimum 3
e The classical travelling salesman problem is to find the Hamiltonian cycle of least weight in a spanning tree. aEa
weighted complete graph. 3 Solve the Chinese postman problem for the
»J
I
B © D E F G
LPPEL
weighted graph shown, beginning at vertex A.
e The practical travelling salesman problem is to find the route of least weight around a graph which a
State which edges need to be repeated and A 0 20 | 10 30 | 15 | 11 | 15
visits all the vertices at least once and returns to the starting vertex.
e Apractical travelling salesman problem should be converted to the classical problem by completion the total weight of the route. B20 0 8 22 | 27 | 13 9
of a table of least distances where necessary. B 30 c Cc | 10 8 0 24 | 16 | 10 | 12
e The nearest neighbour algorithm is used to find an upper bound for the travelling salesman a 15 D | 30 22 | 24 0 29 | tats)
problem. A 3) 35 E| 15 | 27 | 16 29 0 16) e14:
© The deleted vertex algorithm is used to find a lower bound for the travelling salesman problem. 50 p 47 Fj 11 | 13 | 10 13 16 0 25
40 25 30
G45 9 12 18 | 14) 25 0
m\|o/a|o/>
drawing the graph G.
16 0 8 22 Wed
a State whether G is:
10 8 0 24° 16
i directed ii simple 25 22 24 0 19
iii complete iv a tree. 415 2¢e_f..16_$.19) 0
Justify your answers.
728 729
) AL te er mia 15
i State whether or not the graph
represented by the table is
8 Consider the weighted graph below.
Exam-style questions 13 P41: Consider the network.
=
= A B
complete. 10 P41: Consider the graph below.
.
ii Draw the graph represented by the
A
table.
iii Use the nearest neighbour
algorithm, beginning at vertex A,
E F
to find an upper bound for the
travelling salesman problem. a Write down a Hamiltonian cycle,
a Write down the four vertices of odd starting at the point F. (2 marks)
i Use Kruskal’s algorithm to find the degree.
minimum spanning tree for the b Explain why it is not possible to
b Find a walk starting and ending at construct a Eulerian circuit from this
subgraph obtained by removing
A, of minimum total weight, which F graph. (2 marks)
vertex A from the graph and state includes every edge at least once, and
the weight of this tree. a State how you know a Eulerian ¢ Suggest which edge could be
state the weight of this walk.
ii Hence find a lower bound for the circuit exists in the above graph. removed in order that it be
Fully justify your answer. impossible construct a Hamiltonian
travelling salesman problem. (1 mark)
c Find the minimum weight of a walk cycle from any point. Justify your
b Write down one such Eulerian
? Th e graph G is shown below. that includes every edge at least once answer. (2 marks)
circuit. (2 marks)
if it is no longer necessary to start and 14 P1: From the graph, write down all the odd
finish at the same vertex. 11 P41: Use Prim’s algorithm (starting at A) to &8Qo
LNT E NN
5 determine a minimum spanning tree for = vertices. (1 mark) 3
State a possible starting and finishing aEa
the graph. State clearly in which order
vertex for this walk. I
you are adding the edges. (3 marks) »J
LPPEL
Let G be the weighted graph below. a
Cc
>
ii Conjecture a necessary condition Use the nearest neighbour algorithm.
24 0 34 26 20
for a directed graph to have an to find a Hamiltonian cycle on the B 11 D
ow
complete graph represented by the 1? 31 0 19 13
Eulerian circuit.
table of least distances which begins 18 26 19 0 25
iii Does G have an Eulerian trail? If so
mio
and ends at vertex A. 21 20 13 25 0
write down a possible trail.
e If this cycle was taken around G, state
iv Conjecture a necessary condition a Draw a weighted graph representing
the number of times the cycle passes
for a directed graph to have an the network. (3 marks)
through vertex C.
Eulerian trail.
a_ By using Kruskal’s algorithm, find b Using Kruskal’s algorithm, find a
Construct a transition matrix for G. minimum spanning tree for the graph.
the minimum spanning tree for the
Find the steady state probabilities and graph, stating the order in which you State clearly the order in which you
comment on your results. added the arcs. (2 marks) add the edges. (2 marks)
b Draw the minimum spanning tree c Hence find the weight of the
and hence find the least cost for minimum spanning tree. (2 marks)
connecting the computers. (4 marks)
730 731
) AL te er mia 15
16 P2: The following directed graph represents 18 P2: The graph shows seven schools, denoted a Construct the adjacency matrix M for 22 P2: Consider the following graph.
. four islands served by a particular by letters A, B, C, D, E, F G. this network. (2 marks) =
= B
shipping company. b i By evaluating the matrix M’, show
B that there is only one journey in
A this network that can be done in
exactly seven moves.
Cc D
ii Describe the journey, listing (in order)
the vertices visited. (6 marks)
a Construct the adjacency matrix M
21 P2: The diagram shows a network of cycle
for the shipping routes. (2 marks) A school inspector starts from school A, pathways joining seven points in a
b i Find the matrix M>. and is required to visit each of the park, with the weights indicating the
ii Hence determine the number of schools, returning to his starting point. time of each journey (in minutes).
ways it is possible to travel from The weights of each edge denote the Nasson aims to cycle along every a By using the nearest neighbour
A~ Cin exactly three journeys. travelling times for the inspector. pathway at least once in the shortest algorithm, and starting at vertex A,
(3 marks) a Construct a table of least distances. possible time. He starts from, and determine an upper bound for the
3 (3 marks) returns to, point A. travelling salesman problem.
¢ i Find the matrix S,, where S, = > M'.
b By using the nearest neighbour State clearly the order in which
i 10
algorithm, determine a best upper you are taking the vertices. (3 marks)
ii Hence find the number of ways it
is possible to travel from B > C in bound for the length of the journey. b By deleting vertex A and using the &8Qo
LNT E NN
fewer than four journeys. (3 marks) deleted vertex algorithm, obtain
3
¢ State the actual route taken by the a lower bound for the travelling aEa
iii List all such possible ways.
inspector. (2 marks) salesman problem. (4 marks) I
(8 marks) »J
LPPEL
19 P2: Consider the graph below, where c¢ Show that by deleting vertex B, the a
1? P2: The shipping company from question 8 .
2 vertices A to E form a network of same lower bound will be found.
decides to introduce an express route
directed routes as shown. (4 marks)
from A > D and vice versa.
d Hence write down an inequality for
the minimum length (/) of a tour.
ae
F (2 marks)
‘TON D
a State which pathways Nasson
need to cycle along twice, and
the total time that his journey
will
find
will
e Write down a tour satisfying this
inequality. (1 mark)
732 733
15
i i Approaches to learning: Communication,
Ch Oo os I n g th e rl ght Research, Reflection, Creative thinking
You might also:
Exploration criteria: Presentation (A),
path Mathematical communication (B), Personal e reflect on the accuracy and reliability of the values you have found and any
engagement (C], Reflection (D) , assumptions or simplifications it has been necessary to make in order to
collect them and finally answer the question
IB topic: Graph theory
yu Minimum spanning trees e consider what extensions you could solve based on what you have found =
out so far. =
z3 , Fl 7
How many different spanning trees can you find for ss os
5 erp? Your task ca
Ss What is the minimum length spanning tree? S
By A Pa s Choose one of these problems and think of a situation that is relevant to you that you 5
a could use this process to solve. Ps
cH
3 30 Based on this, try to give a brief answer to each of these questions: g
= a c ¢ What real-life issue are you going to try to address? a
a © Whatis the aim of this exploration? cy
iS 7 A F
fe - e What personal reason do you have for wanting to do this exploration? ~
cy c—9
= a 60 F © What data will you need to collect or find? ce
b= © What research will you need to do for this exploration?
rai
; ,
Hamiltonian paths and cycles (the
What sources of information will you use?
travelling salesman)
© What definitions will you need to give?
peo ooibi num ene thiamittonlanicucieonkii> © What possible representations will you need to include?
graph: ¢ Howwill you draw these?
© What technology will you require?
© What assumptions or simplifications have you needed to make in this exploration?
© What possible extensions could there be to your exploration?
© Are there any further information/comments that may be relevant with regards
to your exploration?
e
examples on vertex colouring and domination. Find the domination number (the size of a
smallest dominating set which is a set of vertices
6 5 4) /5 What real-life situations could you use these to solve? of the graph such that all vertices not in the set
are adjacent to a vertex in the set) of this graph:
3 Vertex colouring:
Find the chromatic number (the smallest number of colours
needed to colour the vertices so that no two adjacent
What real-life situations could you use these to solve? ° :
vertices are the same color) of this graph:
In order to solve a real-life problem, you must:
e clearly define what it is that you want to find
e consider the method or algorithm you will follow to make this possible
e identify what the vertices and edges of the graph represent and find, record
or collect the information required to put on this graph
e be able to draw a representation of the graph, perhaps using technology.
734 735