You are on page 1of 20
26 3 Graph Theory 3.1 Language and Notation tn this section, we look at the language and notation of graphs and how it can be used to model problems and help us to solve them. Example 1 “The following is e simplified map of the Hong Kong MRT in 2002, with some stations omitted. Describe this map using mathematical language TSUEN WAN! KOWLOON BAY KING ‘PRINCE EDWARD: (ORTH POINT, AIRPORT CENTRAL CHAT WAN Solution ‘The map consists of a number of vertices (nodes},connected together by eadges (arcs). We can analyse the verties by counting the nomber of edges incident at each one, which we call the order (valency) of the vertex. or example there is a vertex of order 4 at Lai King, and a vertex of order 4 at Chai Wan. ‘inca it is possible to find a route from any vertex to any other, we say that the graph is connected. Sinco there are no duplicate edges (Le. two edges between the same pai of vertices) and no loops (an edge with both tends at the same vertex) we sey that the graph is simple ‘There are two cycles, one of which is Nozth Point-Kewloon Bay-Prince Edward-Ceniral-North Point. Example 2 Represent the Hong Kong map from example 1 in a table and discuss phical representations alternative gr ‘There are a number of different words used in grapb theory — we will generally se vertex, 2 and order but the other words are equivalent gentsensoonene 3 Graph Theory Solution The following adjacency matrix represents the graph, In this case & 1 indicates the existence of a direct route between the locations. Wels saz | leleigialelalel alt|2/3 zie lai sl2)ile]é Airport =fo [atle fo fe fo fo | ‘Tsuen Wan, ol[—[1 fo fo folfo lo Tai King 1{1}—la la feo lo lo Contral o —|a fo fa fo Prince Edward | 0 1f[— [1 [o fo Kowloon Bay | 0 o {1 [— [2 [o North Point 0 tjo fi f- fa Chai Wan 0 | ojo lo ‘The following graphs correspond to the same information, but are clearly different from each other, and the original map. avail a | Since the connectivity has not changed and the underlying data is therefore the same, these graphs are said to be isomorphic to each other: With an appropriate choice of vertex lebelling, they could be represented by the same adjacency matrix. For two graphs to be isomorphic, it is necessary that they have the same number of vertices of each order. However, these vertices must also be connected together in the same manner, Example 3 Here is @ map of the ro: an adjaconcy matrix. in the town centre in Barsett. Represent this as A dash is used where the vertex is repeated (and no connection is therefore needed). somorphic fs derived fom the Greek words ‘20s meaning equal and rmorphe meaning fon, 27 28 Complete Advanced Level Mathematics: Discrete & Decision BARSETT TOWN CENTRE Solution We first label the five junctions clockwise from the junction of New Road and North Street, A toE, To c Al It is standard practice to uso ‘From’ and ‘To’ as [a here, and this will be 7 7 assumed in future g examples end exercises. ifepht pb | 1 | fe a = “ ‘The adjacency matrix shows the number of connections between each pair of vartices. We therofore nesd to-use a 2 for D.to D because there is & Joop which can be used in either direction, whilst B to B is 0 because B to E is 2 one-way street. Exercise Technique From the eight graphs below, pick out the four pairs which are isomorphic io each other 3 Graph Theory : a[plelo] ° alsleclo aAl—[afilo a[—[2 [1 fo ' Byif—}aifa] Bit 2 i c [20 } G4 1 D | 1[-] pio 7 ‘ Alele|[o| @ a|ole|p al—fala | fal=[a fa fo pBlifl—|oj{1i/ Blol—j1]o e{ifijl—|a e[ofol—[a piolil: pfi[1j{o|— 29 30 Complete Advanced Level Mathomatics: Discrote & Decision 3.2 Modelling Networks with Graphs Graphs can be used to represont different aspects of the problem which is being modelled. We define a network as boing a graph carrying information such as lengths, costs or times as weights on the edges. Example Construct a distance matrix for Barsett town centre (the approximate road lengths have been added to the map). BARSETT TOWN CENTRE Fee a Seale 100m ii Solution Using the same labelling for the road junctions, we ean complete the table Biclple A 200 400 D — | 300 250 c) 300 | — | 450 D /450 [1200 | 400 & | 400 400 | — ‘The matrix shows the length of the road wherever a direct connection exists, D to D therefore shows the length of the road around the Priors Way Trading Estate, whilst E to B is null because it is a one-way street the other way. ‘Chapter § develops algorithms for finding shortest distances whiel journeys. 3. Graph Theary 3.2 Modelling Networks with Graphs Exercise Contextual For each of the networks below, construct the associated distance matrix. 2 j i | 3.3 Eulerian, Bipartite and Complete Graphs Four people meet at a party and decide to shake hands, but each one ‘wants to shake e different number of hands to all the others. Since the first person can only shake three others, that leaves at most two for the second, one for the third and therefore none for the fourth, This cannot happen because the first person must shake the fourth person's hand. Investigate for different sized groups of people. What do you notice about the total of all the numbers of hands shaken (valency of the vertices)? How does it relate to the number of handshakes (edges) that took place? at ‘Complete Advanced Level Mathematics: Discrete & Decision Example 1 - Eulerian May of you will have seen the following diogrem: Z_\, ‘the problem here is to draw the diagram without taking the pencil off the paper, and without drawing any Line twice, Solution Itcan be achieved by starting at one of the lower vertioas, and there are @ ‘number of possible solutions, including 8 6 1 r START FINISH ‘The graph is traverseble because all the vertices except the two at the bottom are of even order. Ifa vertex is of even order, then every time that the vertex is reached along a previously unused edgo, there will be another edge available on which tho route can continue. If itis possible to traverse a graph and finish at the start vertex, itis called Eulerian. The above example where the start and finish are different is known as semi- Eulerian, Therefore an Eulerian graph will have all vertices of even ‘order, whilst a semi-Eulerian will have two odd-order vertices, with the remainder even-ordored. This concept will be used in Chaptor 7. Example 2 - Bipartite ‘There are four wholesale warehouses which can supply goods to each of six stores according to the following table: A B ci D Represent this information as a graph. Solution By arranging the vertices in two groups. itis possible to draw the graph go that every edge has one end in each group. conhard Euler was an 18 century Pi ‘Swiss mathematician whose many ys contributions inchade some graph theory. 8. Graph Theory This is called a Bipartite (two part) graph. Such graphs can be used to represent matching, allocation and transportation problems (see Chapters 11 and 12) Example 3 - Complete Graphs Draw a simple connected graph with four vertices of order three, and a bipartite graph with a set of three and a set of two vertices, of order two and three respectively. Solution ‘These graphs are callod complete graphs. 5 . In this oxaniple, we have used circles and squares to distinguish between the two sets of vertices in our The first, because there is a single edgo between each and every pair of vertices. The first is often denoted K,, the complete graph for four vertices. ‘The second because there is a single edge connecting each of the possible pairings between the two sets of vertices, and no connections belween bipartite graph. vertices in the same set, This is denoted K,, the complete bipartite graph for sets of three and two vertices. an, Bipartite and ele Graphs Exercise Technique [1] state whether the following graphs ae Buovan, semi-Bulesian cr neither 33 Complete Advanced Level Mathomatios: Discrete & Decision kt Dx | om C [2 | Represent the information ia eack of the following tables using a bipestite graph. a (Player Role HEE | Klusene! Bateman, Bowler Bick | Batsman, Slip Fielder, Bowler [Russell | wicket-keeper, Batsman Stewart | Wicket-keoper, Batsman | ‘Atherton Batsman, Slip Fielder b Country Sea coast on UK North Sea, Atlantic Océan Norway ‘Ailantio, North Sea, Baltic Russia Baltic, Arctic Ooeen, Pacitic Osean, Black Sea Spain ‘Allantic Ocean, Mediterranean | Turkey Mediterranean, Black Sea 3 | Draw the following graphs: ak, DK, 34 3. Graph Theory 3.4 Planarity ‘Try to draw the graphs K,, K, and K, , without any edges crossing. A graph in which there are no crossing edges is called e planar graph. It is planar if it can be drawn without crossing edges, even though there may currently be some. You should have found that K, is planar (though the common drawing is a square with two diegonals which cross over), but thet K, and K,,, aro not, Kuratowski’s theorem uses this to show that a graph is planer only if it does not contain K, or K,, within it, Putting this the other way round, if sub-graph (some of the vertices and their associated edges) can be found which is either K, or K,, itis not possible to avoid crossing edges, and the graph is not planar. Example 1 Show that this graph is not planer. Bee A D P fs é Solution Deleting the vertices C and G, and all the edges associated with them leaves the following graph: 8 PF B This is K, which is not planar, therefore the original graph is not planar. Planarity is important in applications stich as the design of electronic circuits. 38 Complete Advanced Level Mathematics: Discrete & Decision Example 2 Show that this graph is not planar. B A c F E 2 Solution Delete edges BC, BI and GE (shown here as dotted lines} 2 A _C | APS | DN F E 7 Note that vertices B, G and E are now of order 2. Their labels have been retained, but they are no longer marked as vertices. This means that there is now a direct connection between each of A and G, A and F, and Fand D. Similarly, Lis no longer treated as a vertex. The edges Al and ID are {reatod as a single edge AD. We do the same with odges Cl and IF. ‘There are now direct connections between each and every pair of vortices from the set A, C, D, F and H, forming Ks. Since the graph contains K, as a sub graph, itis not planar. Example 3 ‘At this point we need to define a Hamiltonian cycle, This is a cycle which visits every vertex in a graph, without repetition. ‘Use the following algorithm to check whether or not the accompanying graph is planer 3 Graph Theory Planarity Algorithm 1 Find a Hamiltonian cycle (every vertex joined to form @ continuous chain) and redraw the graph so that this forms a polygon with ail other edges inside it. 2 Select an edge to remain inside the polygon, and move outside the polygon any edges which cross it, without them crossing each other. If this cannot be done — stop, graph is not planar. 3 For any crossings remaining inside the polygon, try to move one of the edges involved to the outside of the polygon, without it creating any new crossings. 4 Repeat step 3 until ell possible edge moves and all crossings have been considered. If there is still at least one crossing it is not planar, otherwise you have succeeded. mA Solution ‘There is 4 Hamiltonian cycle A-B-C-D-E-A so this sequence of edges is drawn to form the perimeter of the polygon, and all the other edges are placed inside, TEEPE ee ee eee enn ree eee ere eee Complete Advanced Levet Mathematics: Disorote & Decision {We choose (arbitrarily) to Keep tho edge BE inside the polygon. and therefore move AD to the outside, 4 B D ‘oss we nnust consider each of titese. Choosing to anwot thea put CE outside without it maar graph ‘As BD and CE still er \oep BD inside is not useful a5 we ¢ rossing AD. However, if we keep CE inside and move BD @ pl can be achieved. Exercise Technique [A] ecsaw the following gaps in planar form, bK © 38 8 Graph Thoory [2] by ehowing thet they contain cither K, oF K, yas 8 subgraph show that the follovring graphs are non-planar. Consolidation Exercise A [1] rhe caller ata barn dance asks 4 males and 4 females to arrange themsolvas so that the females are each holding hands with two other people, whilst the males are each holding hands with just one other person, Draw graphs using [O} to represent a female and [x] to represent a male, to show all possible different arrangements in which this can be achieved. : You are not required to consider the number of ways in which arrangements may be formed. In other words you should regard the males as being indistinguishable from each other, and likewise for the females, (AEB) [2] @ Asimple comnected graph has 7 vertices, all having the same degree d. Give the possible values of d, end for each value of d give the ‘number of edges of the graph. b Another simple connected graph has 8 vertices, all having the same degree d. Draw such a graph with d= 3, and give the other possible valuos of d, (AEB) 39 Complete Advanced Level Mathematics: Discrete & Decision [3] eis no graph itlusteetd with 6 vertices and 5 edges 1 | | 4 What is the smallest number of edges which must be a onder to make a connected graph. Illustrate one such graph. What is the smellest number of edges which must be adde .dded to Gin xd to G to make a Hamiltonian graph? Uustrate one such graph, clearly pointing out a Hamiltonian cycle. What is the smallest number of ed \ges which must be added to G in order to make an Eulerian graph. Illustrate one such graph, ‘Show how the addition of 4 edges to G cam create a graph which is not planer. Explain briefly how you know this graph is not planar. fAQA) {4 | Draw a bipartite graph to represent information in the following table. [5] For the graph below 4 E B D c 40 ‘a. stale whether it is Eulerian, semi-Eulerian or neither 1b show that the graph can be redrawn in planar form. 3. Graph Theory Exercise B Lj a Prove that the graph G is non-planer, } 4 B : z D b i. Show thet the following graph, G, contains a subdivision of K,,, as a sub-graph: 1 ji What does the fact that G has a sub-graph which is @ subdivision of K, tell you about G? (AQA} B bE M N A c | 2 Q R | F D Figt Fig Use the planarity algorithm for graphs to determine which, if either, of i the graphs shown in Fig 1 and Fig 2 fs planar (SDEXCEL) i @ A,B, Cand Dare the vertices of the complete graph K,. List all the paths from A to B (i.e. routes passing through particular verticos only once). at Completa Advanced Level Mathematics: Discrate & Decision b How many paths are there from A to 8 in the complete graph on the vertices (A, B, C, D. B}? ¢ Which of the graphs in parts a and b are Eulerian, and why? (AQA} a Write down the orders of the nodes in the above graph, and deduce that the graph is semf-Eulerian. b A semi-Eulerian trail is a path that traverses every arc once end only once, Explain why, for any semi-Eulerian trail on the graph in part (a), two of the ares AC, BC, DC and EC must be traversed moving towards Cand two traversed moving away from C. c Redraw the graph in part (a) to show that itis planar. Show thal it is impossible to add a vertex, P, joined to each of A, B, C, Dand E, in such a way thet the resulting graph is still planer. (ocr) 5 | @ State whethor the graph below is Eulerian, semi-Fulerian or neither 4 D b By finding a subdivision of K,,,, show thet the graph fs non-planar. 42 3. Graph Theory Applicctionrind Extensions ‘The colouring problem Ifyou look at a map of the world, you will notice thet it has been coloured so that no country is the same colour as eny of the countries it borders (although it may be the saine as a country which it only touches ata comer). This makes it much easier to tell the countries apart. It is possible to use a graph to help colour in a map in this way. The vertices represent the countries, Edges indicate that countries share a common border 5 In the example below, vertex A was coloured “grey” first. This meant thet 20.) Band C could not be “grey”. D can be'grey”, meaning that E cannot. The ‘ next stage was to colour B black. C and F cannot be black, so a third colour is needed, C was coloured white; can also be white, and the map is finished. € B Investigate the minimum number of colours needed to colour any map. M ng jugs In the film Die Herd IIT, Bruce Willis and Samuel L. Jackson are challenged to measure out exactly 4 litres of water into a Jarge container, using only a 6 litre and a 3 litre jug. It is possible to use graph theory to keep track of the possible choices, In the graph below, the vertices represent the contents of each jug and the container: edges shaw how to move from one possible vertex to another. 43 Complete Advanced Leva! Matfiematios: Diserete & Decision 0,0 = all containers empty | 5.0, 0 = 6) [ug full: 31 and large i container emply Rls rial | 2.0.3 = 2 in 51 jug: 0 in 31 jug ug, jug ! 31 in lauge container | Fat ig ill loxgo Fill 5Liug from container from 3] from 31 31jug 2.3,0 i By continuing the graph, find a possible solution. ‘This technique cam also be applied to the river crossing problems you may find in other books, Summary [A graph consists of vertices (nodes, points) and edges (ares, Ines), “The order of valency of a vertex is the number of ends of edges at that si vertex. é “The total order of all the vertices in a graph will always be an even number, equal to twice the number of edges. ‘4 loop is an edge with both ends connected to the same vertex Ina simple graph there is no more than one edge betwoen any vertices, and there are no loops. In-a connected graph it is possible to find a route between every pait of vertives. ‘A soquence of edges, starting and finis repeating an edge is a cycle. ‘A Hamiltonian cycle is one which visits every vertex exactly once ‘A grap can be represented by an adjacency matrix which shows how inany edges exist between each pair of vertices A potwork is a graph with weighted edges (representing distance, cost ttc.) These can also be shown in a matrix, often called a distance matrix 8 Graph Theory ‘Two graphs are said to be isomorphic if they could be represented (possibly by re-labelling vertices) by the same adjacenoy matrix. ‘An Bulerian graph will have at most two odd vertices. It is possible to iwaverse every edge exactly once in a continuous sequence. In a Bipartite graph, it is possible to split the vertices into two groups 80 that every edge is a link between the two groups, ‘A complete graph is a simple graph with every possible connection included. ‘A planar graph can be drawn on a flat surface without any edges crossing. 45

You might also like