0% found this document useful (0 votes)
11 views

DM&GT Unit 5 Text Book PDF

Discrete mathematics and graph theory unit 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
11 views

DM&GT Unit 5 Text Book PDF

Discrete mathematics and graph theory unit 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 36
Grapu THeory - Il Leannina Onjecrives + Planar graphs * Trees + Colouring and covering 10.1 PLANAR GRAPHS | Consider the utility problern. Suppone there are thres houses W, W, and Wy 0 netted Wo the ventres of thre companies, Ay, A, and A, which supply » tepheme vervicn, respectively, Ia yragh watiSying the yiven requirements is di runtplete Ky, yaph. For exatnple, W, in usmnersen with A,, Ay a8 Ay 1 the problern is the follwing: Can we draw this yaph in the serves exumph ah the vertivas! In this vexdion, we umsider such prot Lua us camsider the graph shown in Fig, 104. lane such that no two edges [Figure 10.1) Gragh shereirg intersection A edges We eae venta the ypaph in Pig, 10.1 as follerws (Fig, 102) Z) {Figure 10.2) Irnarvection of ages arty at the vertices © scanned with OKEN Scanner 442 Mathematical Foundation for Computer Science in Fil i at the vertices, which In the graph given in Fig. 10.2, no two edges intersect except MAY be the common end vertices of the edges. Definition 10.1 : ; A graph G is called a planar graph if it can be drawn in a plane such that no tWo edges intersect except at the vertices, which may be the common end vertices of the edges. Definition 10.2 ‘ A graph drawn in a plane is called a planar graph if no two edges meet at any point except the common vertex. é eee Thus, a graph is said to be a planar graph if and only if it has a pictorial representation in a plane which is a plane graph. This pictorial representation of a planar graph G as a plane graph is called a planar representation of G. Note 10.1 Ifa graph G is drawn with crossing edges then it is not necessary that Gis a non-planar graph. To declare that a graph G is non-planar, we have to consider all possible geometric representations of G. In all the cases, if the planarity condition fails then the graph is non-planar, Example 10.1] Consider the graph shown in F 10.3. Is it planar or non-planar? igure 10.3] Graph for Example 10.1 Solution This graph is apparently non-planar, However, this can be re-drawn as shown in Fig. 104. 1.4] Redrawn graph In Fig. 10.4, no two edges cross each other, Thus, Fig. 10.4 is a planar graph, Hence, Fig. 10.3 is a planar graph, though it Appears to be d non-planar graph. Example 10.2) Consider the graph in Fy » 10.5. 18 it planar or non-planar? © scanned with OKEN Scanner Graph Theory =H 443 [Figure 10.5] Graph for Example 10.2 Solution sect except at the vertices, which may be the common end vertices a Inthis graph, no two edges inte ofthe edges, Hence, the graph is planar Consider the planar representation of Let G denote the planar graph as shown in Fig. sions, called the faces of G. «a planar graph as shown in Fig. 10.7. 10.7. Graph G divides the pine into different re~ Planar representation of a planar graph tis nota vertex of G or a point on any edge of G. Then, a face fall points on the plane that ean be reached from *x” by a oss any edge of G or pass through any vertex of G 1, let vy be an adj and hence v; is different from v. If deg (v;) = 1, then we are done, Suppose, deg (,)> 1, let v2 be an adjacent vertex of v). As G has no cycles, vp is differeny from v and v), Ifdeg (v2) # 1, we find an adjacent vertex v3 of vz different from v, vy and vp. Because G has a finite number of vertices, it follows that G has a vertex w of depree |. We now delete this vertex and the only edge that is incident with the vertex. ‘Thus, new completed planar graph // with (le ~ 1) edges and (1 ~ 1) vertices. By the induction hypothesis, for this graph 17, we have n,n, + ny 2 Hence, (t~ 1) (k= 1) + y= = -ktny n+ ng= 2 holds in G. vertex of degree 1, nt vertex of v. As G has no eye! , Gis loop fren => Case (ii) : Suppose, G has a cycle C. Let ¢ be an edge in C, Now, construct a new graph Gy = G~ {e}. This G, is a planar graph, For this planar graph G,, we compute n,, 1, and mp Let ny= m. In the construction of Gy, we delete only the edge ¢ without deleting any vertices, Therefore, n,=f,n,= k= I Now, C= {e} isnot a cycle in G, Thus, the edges of C- (¢} will not form a boundary in G, Therefore, in G,, np= m= 1 Hence, Gis a connected planar graph with n, = ¢ vertices, n regions. By the induction hypothesis, we can write 1~(k=1) +(m-1)=2 Si-k+m=2 k~1 edges and ny=m-! nym, ny=2 Therefore, by the principle of mathe Hence the theorem, Note 10.2 The basic result about the connect also called Euler's polyhedron formula, Corollary 10.1 Ia plane graph has & eompone mal induction, the result is true for all values of "« ted planar graph is known as Zuler formula, This result * ‘nls, then, —n, + nek Proof Consider the plane raph (1, 1 other components, Let the /!" n.) such that the exterior face of compon nt be an (1, Me) wraph with ny fi ns al ch component cont es for cach © scanned with OKEN Scanner Graph Theory ll 447 py the theorem, diicusned above Myo Me, bing = 2 pence, 2am, Ee, Bang = 2k 7 But Yay, My Ze Me Engen kV) ‘The infinite face is counted & times in Ys My. . (10.1) becomes ; Hence, Neo Net Nyt k= 1 2k Sonya net mys kA Corollary 10.2 ‘The graph Ky, is not a planae graph, Proof The graph of Ky, y is shown in Fig, [0.11 Figure 10.11] AKyy graph Suppose, K;,; is « planar graph, ‘Then, it will have « planar representation, ‘This planar representa tion divides the plane into different regions, Note that an edye of the graph may appear al most in boundaries of two different regions, For any such planar representation, we have by Fuler’s theorem nyo My! ny 2 For Ky, my =6, 0,9 36-9b nyo 2 sys 5 3 does not contain any triangles, but it contains a cycle of length 4, Therefor fappearances of the edges in the boundaries of five faces ine 5% 4 = 20, On counting these appearances, an edge may be counted at most twice, Thus, the (otal number of appearances of the nine edges in boundaries iss 18, which iv a contradiction, Hence, K,., is not a planar graph. the total number Theorem 10.2 Let G be a comected nimple planar groph with n, & 3 verticen and n, exdyes Then, "S3n,~6 Proof Let G be w connected simple planar graph. ‘Thin implies that it has w planar representation ‘msider a planar representation of G. Suppose n, = 3, then 1, <3, since G in a simple conn On, S33~6 ed graph with the © vertices © scanned with OKEN Scanner 448 Mathematical Foundation for Computer Science = 1,8 3n,-6 Now, suppose that , > 3. If G does not contain any cycle, then we can show that n, = Now, 31, 6 = (n,~ 1) + (n,—2) + (n,-3)> (nl) = <3n,- suprose, ae cycle. Since G is simple, it may contain a cycle with three edges. Ths, the number of edges in the boundary of a face is > 3. Now, there are faces and every edge is a member of some boundary of the planar representation. Hence, the total number of appearances of the edges iy boundaries of nyfaces is > n,- 3. In counting these appearances, an edge may be counted at most twice, Thus, the total number of appearances of the ‘e” edges in boundaries is < 2n,. Hence, 3nyS 2n, By Euler’s theorem, n, —n, +n/=2 3n, + 3ny= 6 3n, + 3ny~6 = 3n,S3n, + 2n,- 6 =n, S3n,-6 =n, $3n,-6 Corollary 10.3 If G is a connected simp! le planar graph with n, (2 3) vertices and n, edges and no circuits of length 3, then n, < 2n,—4 Proof \f the graph is planar, then the degree of each region is at least 4. Hence, the total number of edges around all the regions is at least Any. Since every edge borders two regions, the total number of edges around all the regions is 2n,. Therefore, 2n, > 4ny = nySn, If we combine this with Euler’s formula, we obtain nn, + y= 2 = 2n,—2n, 2ny=4 = Iny= 4—2n, + In, Sn, =n, S2n,~4 Corollary 10.4 The graph K, is not a planar graph Proof The graph K, is shown in Fig. 10,12, z a Ye [Figure 10.12] AK; graph © scanned with OKEN Scanner Graph Theory - Il 449 isa connected simple graph with 10 edges and five verti . orem 10.4, We can write vertices. Suppose Xs is a planar graph, then n,S3n,~6 thus, for Ks, 10$3X5~6 1089 This is a contradiction, Hence, K's is not a planar graph. subdivision of a graph le G = (V, B) be a graph. Suppose that ¢ is an edge with v, and v, as end vertices. Construct a abgeaph G, = G~ {e). To construct G, we have deleted edge e without deleting any vertices from G. Wenow construct a new graph G3 =(V>, Ey), by taking V,= VU {u}, Ey =(EMe}) U (fi, /2} such that vé V ffx € Es vy, ware end vertices of f, and v2, u are end vertices of f;. The process of obtaining 6, from Gis called a one-step subdivision of an edge of G. Definition 10.3 A graph H is said to be a subdivision of a graph G if there exist graphs H, Hy, ..5 H,—1, H, such that ily= G, H, = H and H, is obtained from H,_ by a one-step subdivision of an edge of H_, for i= 1, 2 If a graph H is a subdivision of a graph G, then we say that HY is obtained from G by subdividing cdges of G. For example, consider the graphs shown in Fig. 10.13. “ Ms % 4 a : ae yw me @ ) Figure 10.13] Subdivision of a graph The graph H is obtained from G by a finite sequence of subdivisions of edges. That is, H is ob- kined from G by dividing edge e, once, €2 nee and e; twice. Definition 10.4 saa / Two graphs G and H are said to be hhomeomorphic graphs if there is an isomorphism trom a subdivi- sion of G to a subdivision of H. and H shown in Fig. 10.14, For example, consider the graphs G © scanned with OKEN Scanner 450 Mathematical Foundation for Computer Science % [Figure 10.14] Graphs G and H Sj i 5 i Je of length 4. Hence, these Inthe given graphs, G contains a cycle of length 5 and H contains a eycl 4, Hence, two graphs are not omorphic, However, we can find a subdivision G, of G and a subdivision H, of (shown in Fig. 10.15) such that G, and H, are isomorphic. Hence, G and H are homeomorphic graphs, Figure 10.15 Kuratowski’s theorem The concept of subdivision gives an important characterisation of planarity due to Kuratowski. Theorem 10.3 Kuratowski’s Theorem: A simple graph is planar if and only if it does not containa subgraph homeomorphic to Ks or Ky. The proof of the above theorem is not given here as it is beyond the scope of this book. Example 10.6] Using Kuratowski’stheorem, — not a planar graph. provethatthePetersen graph G, shown in Fig. 10.16,i8 ubgraph homeomorphic to A’ or Ky PM G contains no vertices of depree 4, Hence, @eannot co aa © scanned with OKEN Scanner Graph Theory-H 451 pp bomeamarphic to Ks, Let us find a subgraph of G homeomorphic to Kj. The graphs H. in Fig. 10.17(b), is a subgraph of G and H is a subdivision of graph K3 5. jown 4 Us % u % a ty vs Uy % (@) Ks (b) Graph H Figure 10.17] H is a subgraph of G and subdivision of K3, Hence, by Kuratowski’s theorem, we find that the Petersen graph G is not a planar graph. a EXERCISES 10.2 For the planar graph shown in Fig. 10.19, find 10.) Find the number of faces and list the edges of the number of faces and list the edges of the boundaries for the planar graphs shown in boundaries. SS % " (a) ©) 9] Planar graphs for Problemy 10.2 10.3 A connected plane graph has 10 vertices each of degree 3. Into how many regions. doce a » representation of ation of this pa plane? his planar graph split the graphs for Problem 10,1 Planar (Figure 10.18 © scanned with OKEN Scanner 452 Mathematical Foundation for Computer Science 10.4 Determine the number of vertices, the number of edges and the number of re- gion in the graph given in Fig, 10.20, Then, show that your answer satisfies Euler’s theorem for con- nected planar graphs. igure 10.20] Graph for Problem 10.4 2 COLOURING AND COVER' The concepts of colouring and covering have been discussed in detail in the following subsections 10.2.1 Colouring The colouring procedure may be defined as given below. Definition 10.5 Colouring An assignment of colours to the vertices of a graph so that no two adjacent vertices get the same colour is called colouring of the graph or simply vertex colouring. The n-colouring of G refers to the colouring of G using n-colours. If G possesses n colouring. then G is said to be n-colourable. Example 10.7 Consider the graph shown in Fig, 10.21. Show that it is 4-colourable. yy Vy Va Ys Figure 10.21] Graph for Example 10.7 Solution The graph given in Fig, 10. four vertices y ig. 10.21 has ices v, of 4 colours, where R denotes rei jotes : 'd, B denotes blue, 1525 ¥yand vy, Let C= {R, By Y, GEDA ¥ denotes yellow and G denotes green. Defive/ LO) = Ry fry) = G, fry) = Then, fdenotes a = BL2)™ G fy) = Vand f(v4) = B, Proper colouring with fo, ur colours, Is there a proper vertex colouring of G : ‘ : that uses less than four colours? Example 10.8] Con . sider th Fi — E } 7 ihe Braph shown in Fig, 10,22. Show that G is a proper vertes © ait uses less than four colours, © scanned with OKEN Scanner Graph Theory - Il 453 [Figure 10.22] Graph for Example 10.8 Solution The graph given in Fig, 10.22 has five vertices vy, vay Vs, Yq and v. Let C= {R, B, G} be 3 colours, where R denotes red, # denotes blue and G denotes green. Define f: V—> C by IV) * Rf 05) & Ri Sg) = fq) = B and f(v3) = G ‘Then, we observe that /is a proper colouring of this graph with three colours. Iv there proper vertex colouring, of this graph that uses less than three colours? 5 Definition 10.6 Chromatic number The chromatic number of a graph G is the minimum number of colours needed to colour the vertices ofthe graph G and is denoted by X(G). Thus, a graph G is n-colourable if X(G) $ 1. [Example 10.9] Determine the chromatic number of the bipartite graph shown in Fig. 10.23. Mee. Me [Figure 10. 3] Graph for Example 10.9 Solutlon Gin a bipartite graph with bipartition VO Vz, where Vj = {¥), v5 v5} and V2 = (v4, vs}. Let C= {R, B} be a set of two colours, Define a function f: V-» C by firy=Rifve Vy and fvy=Bifve Vy No two vertices in V, are adjacent and no (wo vertices in V are adjacent. + fin a proper vertex colouring, Since G contains only edges, A(G) "2 5 Theorem 104 Let G be a now-trivial simple graph, Then, X(G) = 2 if and only if G is a bipartite baph, Pranf Let Gi (V, B) be a bipartite graph. Then, the vertex set can be partitioned into Iwo non- Cmpty subsets Vy and V, nicl that each cede of G in incident with one vertex in Vy and one verter in 1 Let C (ry, 7} be two colours. Define a function f; ¥-» C such that foyer tee Vy and foyer ive Vy © scanned with OKEN Scanner 454 Mathematical Foundation for Computer Science Clearly, fis well-defined, since V, 7 V2 = 9. Also, no two vertices of V; are adjacent. Therefore, a vertices in V, can have the same colour. i In addition, no two vertices in V2 are adjacent. Therefore, all vertices in V2 can have the same colour. From the definition of f, we can state that two adjacent vertices of G have different colours, Therefore, X(G) < 2. Since G contains at least one edge, X(G) > 1. Hence, X(G) = 2. i Conversely, suppose that X(G) = 2. This implies that the graph contains atleast one edge. Also, there exists a function f: V > C= {r, r2} such that no two adjacent vertices have the same image. Let V, = {v € Vif(v) =r,} and V= {ve Vif(v) = 12} > ViAv=o and VU, =V Let e be an edge with end vertices v, and v3. Since v, and v, cannot have the same colour, ve J, if and only if v, € Vj. Hence, G is a bipartite graph. Definition 10.7 Let G be a graph with vertices v1, V2, ... Yq» Yq. The maximum of the integers deg (v,), i= 1, 2, ., nis denoted by A(G). That is, A(G) = max {deg(v)/i= 1, 2, ... n} Consider the graph G shown in Fig. 10.22. Find A(G). Solution In G, deg (v,) =3, deg (v2) = 3, deg (v3) = 4, deg (v4) = 3, deg (v5) =3 Hence, A(G) =4 From Example 10.8, we have X(G) =3 a Theorem 10.5 For any simple graph G, X(G) $ A(G) +1 Proof Let Gbe any simple graph. Let the number of vertices in G be n. We will prove the theorem by using induction on n. Basic step: Let n= 1. Then, G is a graph with only one vertex and G has no edge. Hence, X(G) = I and A(G) = 0 = X(G) < A(G) +1, forn=1 Inductive hypothesis: Suppose that kis at (k~1) vertices : X(G) $ A(G) +1 Inductive step: Let G be a sim n integer with k> 1 such that for any simple graph @ wit" ple graph with k vertices, Consider a vertex 1 of G and construct Ne graph G, = G— {u}. The graph G, is obtai ng all Be , 7 1 is obtained from G by deleting the vertex u and also deleting ealges incident with u. Clearly, A(G,) < A(G) This is a simple graph with (k ~ 1) vertices. Ths. induction hypothesis, we can write MG) SA(G\) +1 i So, We can say that G, can be properly coloure . ag has aus A(G) adjacent vertices. As A(G) pba ly coloured by at most A(G,) + 1 colours, ae aah these m * 1, not all the ACG) + 1 colours are 1 A(G) adjacent vertices. © scanned with OKEN Scanner aE omatic number of bipartite geph Kae aa arp VOTE Find he nen the chromatic number OF Hig MAD consider the graph Kay Solution Si every bipartite araph is 2, we can write For example, shown in Fig. 10.24. % “ 1 | | [Figure 10.24] AK, graph teary, #140)? Sempre 108 petermine the cl Bare Oe ifn is even, colour X(C,) = 3, if is odd. Solution eng can seratvey colour the ele If mis odd, we need the third are for the last i — gph of Co» Jhromatic number of C, for n = even and n = odd. C4, and C; are shown in Fig. 10.25, &) © scanned with OKEN Scanner 456 Mathematical Foundation for Gamputer Selence Dp @ wpm 2, wm ” Ot, vp a os "1 } o Ivy Vi Ms, “ O. iy yo Qantas ow WM Ooo ey 6 ms | Figure 10.25 | Graphs of C,, Cy and C, " [Example 10.14] Determine the chromatic number of w,, where w, in the wheel graph with w vertices Solution Xow, 3) i nix even and X(w,) = 4 i'n Is odd, For example, consider the graph I, an shown in Fig, 10, [Figure 10.26] W, graph deg, (v4) © 5 and ail the other vertices have degree 3, A(G) 5 2 MGS MG) 166 Again, since there is a triangle subgraph of G, we ean write MG)24 IEA(G) @ 5, when according to Rule 5 there equal to 4, However, this is not true, Hence, 3<.X(G) $4 00 would be at least 5 vertices of degree greater (he We start by choosing the triangle y, vy and v Het f eal? 1+ Yay Yq With colours 1, 2, 9, rexpeeti sis to be coloured 1, and then ¥4 i to be coloured 3 MG) 4, ely, Since, vy inate ' Now, v5 in to be coloured 8! Theorem 10.6 Five-colour theorem Every planar iraph is 5-coloural Proof Vc G be a planar praph with n-vertices, We shall prove the theorem by induction Basie step Ww trivially te, wines the Lets 5, then the th waph in S-colourable © scanned with OKEN Scanner Graph Thoory =I 463 pgintion 10.11 geaver ity ofa graph G@ (V, E)is ak. A covering K is called a minimum covering if G has no fhe number of vertices in a minimum covering of G is ealled the coy yoted by B- subset K of V sue set K of V such that every ed incident with a vertex overing L with |L[ = [K rings number of Gand is pufinition 10.12 jsubset of V is called the independent inlependent set 5 is said to be maximum The number of vertices in a maximum independent set is called the Win G. An et of G if no two vertices of S are adjace G has no independent set U with |W} |S |. independence munber 0G snd is denoted by 0. ibe the various sets of vertices in ‘ample 10.22} Consider the graph as shown in Fig. 10.95, Des the graph, Figure 10.35 | Graph for Example 10.22 | independent sel. rf js an indepen’ Salution (vo) in aaa ine ndent set, {vp M4 va var vs} 8A covering. (vps ¥21 97 ON gg minimum covering. Vip Yan ¥9 . Sr {v2 V6 soVvism independent set of G if and only if VS is a covering of G. ig independent ifand only if'no two vertices of $ are adjacent, that incident with atleast one point of 8, 8 Si «a covering of G. Then the sum of coy h with #7 vertic B ys number and the indepen- aii be a grap) et G bem : , j 10.14 Lee al to the number of vertices of G, ‘That ix | theorem (eof G in em i umber atpen © scanned with OKEN Scanner 464 Mathematical Foundation for Computer Science Proof Let Sbe a maximum independent set of G and k be a minimum covering of G. We can rig |S|=oand | k|=B Now, /- Sis a covering of Gand K is a minimum covering of G. Hence, |K|$|V/-S| =Bsn-o that is,a+BSn (10.2) Also, V— kis an independent set and S is a maximum independent set. Hence, |V— | <| S| =n-Bsa ie.a+BSn (103) From Eqs (10.2) and (10.3), we get a+B=n Definition 10.13 A line covering of G=(V, E) in a subset L of E such that every vertex is incident with a line of L, The number of lines in a minimum line covering of G is called the line covering number of G and is denoted by B’. Definition 10.14 A set of lines is called independent if no two of them are adjacent, The number of lines in a maxi- mum independent set of lines is called the edge independence number and is denoted by a’. Theorem 10.15 Let G be a graph with n vertices. Then, the sum of the line covering number and the edge independence number is equal to the number of vertices in G. That is Pee Proof Lets be a maximum independent set of lines of G such that | $| = a, Let H{ be a set of line one incident line for each of the n ~ 2a’ vertices of G not covered by any |i arly, SU His line covering of G. Therefore, |S U H|2B’. Thats, y any line of S, Clearly, SU o! +n—2a 2B = nza' +B i Now, let be a minimum line cover of G, =|Tl=p © scanned with OKEN Scanner Graph Theory - 11 465 Teannot have a line ‘e” both of whose ends are incident with lines of T other than i : ’ r _ Let GT] b coring subaraph of G induced by T. This implies that G[7] is the union of stars. eae * ach line of Tis incident with atleast one end point of G[7].Let 7 be ei psig of exactly one end point fr each line of 7 va ee Hence, | =| 71= B’ and each star has exactly one point not in IV. Therefore, m of stars in G{y a n= Bi + number of stars in G[T] =|W|+number (10.5) By choosing one line from each star of G[T}, we get a set of independent lines of G. Hence, a 2 number of stars in G[7]. Thus, Eq, (10.5) becomes nspitol From Eqs (10.4) and (10.6), we get of +Bi=n (10.6) Note 10.6 In general, the complement of an independent set of Hines is not a line covering. ich as trees and networks, which are essen- v theory. The concept of a tree was initially introduced 10 study som by Cayley in the year 1857. Trees form one of the most widely used and i. Many of the applications in graph theory directly or indirectly any structure which involves a hierarchy. In Computer trees play a vital role in Inthis section, we important concepts, Su tial for complete unt the chemical composi ied subclass of erp oye. Trees are useful in describing u ee Trees are useful in organizing ‘and storing data in a database. Hence, graph theory- ‘Trees and their 10.3.1 ‘Trees and related concepts may be defined as given below. ree! Definition 10.15 : pera that contains TO cycles is called an acyclic graph, and connected acyclic graph is fn other words: & ‘connected graph with no cycle is known as a tree. Its edges are called tee sare calle ches bravay graph without cycles may also be called a forest. Hence, tress are components of @ forest gure 1036 shows examples of trees with atmost five vertices © scanned with OKEN Scanner 466 Mathematical Foundation for Computer Science V4 M oe Ys 5 v2 2 Ye V2 “ Ms IY oA M2 (2) One vertex (b) Two vertices (c) Three vertices (d) Fourvertices (2) Four vertices Ms Ms Ys Vs Ms ya V2 Ye 4 v ly ()Fivevertices —(g) Five vertices _(h) Five vertices Figure 10.36] Example of trees A tree with only one vertex tree [Fig. 10.36(b—h)]. Example 10,23] [Fig. 10.36(a)] is called a trivial tree, otherwise Tis called a non-trivial a Consider the graphs shown in Fig. 10.37 and determine whether they are trees. Ye w vs vr Ma Me M% We ve 4 Ys % . Ye (a) i} Figure 10.37 Graphs for Example 10.23 Solution The gra Phs given in Fig, 10,37 are conne cled as the: ¢ no cycles, Hence, both the graphs shown are trees, led as they have no cycles, Hence : (Ex Consider the graphs shown in Fig, 10.38 and determi je whether they are tees © scanned with OKEN Scanner Graph Theory - Il 467 Vs ‘ Me % Ma Ve vy Vp vs Ve Ye (@) 0) Figure 10.38] Graphs for Example 10.24 Gution Bach of the graphs given in Fig. 10.38 are connected. However, both of them have a cycle. ence, none of the graphs is a tree. : charecteristics (or) properties Property (1) (Theorem 10.10) There is only one path between every pair of vertices in a tree 7. Proof Letu andy be any two vertices of tree 7. 1F¥= then the result is trivial. Suppose that u # v. Gace Tis a connected graph, there is atleast one path from #10 ¥ Suppose there exists two distinct pas fromm 1 £0 $835 Py = (th ty Ma >to) dad P, = (Yn Yn vs Yn ¥) Since Py and Ps are distinct, we have the following two cases: Case (): Py P= ly tyy Hay ooe5 Mp Y) (es Yap Vv oo Van Y= Then the path P; followed by the path Pa that is (45 tas Mayo a Yow uto v, which is a contradiction. Hence, P| AP, = 9- Case (ii) : Py A Pa # 59 (Uy Uys May ots Hw YO (at, Vas Var oe Vane WFO ted j, Let w, be the first common vertex other than wand von paths P, and P,, Then, we follow path Py J rwe come to the fist Vertex, SAY Ws which is again on both P, and P,. This verex w, is different from Yr. ‘Wo must get such a vertex 1, because P, and P, meet again at y Let Q be the portion of the path of P; from stow, and R be the portion of the path of P, from w, to w,. Then the path Q. followed by the path R, forms a cycle from w, to w, in a graph 7. This is @ contradiction to our assumption that T is a tree. Hence, T does not contain two distinct paths between any (WO distinct vertices wand ¥. Property (2) (Theorem ou1l) Mf in a graph G there is one and only one path between e vertices then G isa tree. | vp 1), form a cycle from Hence, u,= vj, for some ia ry pair of Proof VetG bes graph since there is one and only one path between every pair of veitices, zycle in a graph _— there is atleast one pair of vertices wand v such that there etween w and v. Since G has one and only one p. : ch that Ibe eae one and only one path between every pair of Property (3) (Phearem 10.12) Aree with vertices aw m1 edges. © scanned with OKEN Scanner 78 Mathematical Foundation for Computer Science Definition 10.26 Spanning tree A subgraph Tofa G, that is, WUD = aph G is said to be a spanning tree if Tis a tree and if T includes every veney op "(G). Example 10.31 Discuss a spanning tree with an example. Solution Suppose seven universities in one city are involved in a joint research project funded ty » major corporation. The research centers at each university frequently send a large amount of dats 5 the other universities, To finish the project on time and to expedite the transmission of data ang protect it, he company wants to connect the seven universities using fiber-optics lines. To minimize the cost of construction, the company wants to lay as few lines as possible. Also, itis not possible to lay a direct fiber-optics line between some of the universities. In fact, it is not neces. sary to bave a direct line between any two universities. The engineers look at the areas surround the universities to determine the possible lines that can be laid to connect the universities. A graphi representation of the situation is given in Fig. 10.47. ve Figure 10.47 | Graphical representation for Example 10.31 To lay the fiber-optics lines so that the universities connected, the engineers find a tree T that is a One possible solution is shown by the tree T ‘an be connected, but not necessarily dir subgraph of G such that T contains all the vertices of in Fig. 10.48, 4 (rh) (Figure 10.48] subgraph of G yo we Clearly, Tis a spanning tree of G. Ifwe find a s Associate the cost factor of laying the fiber-optics 8" B04 sPanning ee that has the minimum cost nt ACHE OF laying the fiber : © scanned with OKEN Scanner Graph Theory = 479 [F tion ‘The graph G has four vertices and henee each spanning tr ‘ya each tree can be obtained by deleting two of the five edges of G jgeeiwo of the ways lead to disconnected geaphs, there are eight possible spa a X tee 7 . | VA NY NT ON [Figure | 0.50] Spanning tree of G i. 1 10.49 | Graph for Example 10.32 must have 4 ~ 1 = 3 vertices. rhis can be done in 10 ways. ing trees as shown in ‘and only if G is connected. ‘orem 10.21 A simple graph G has a spanning tre ing tree 7; Then, 7’ contains every vertex of G. Let so vertices of [and Tis a tree. Therefore, there is Iso serves as a path between wand v in G. Hence, oof Suppose that a simple graph G has a spanni ‘indvbe any wo vertices of G. Then wand v are al Mh P between w and vy. Since Tis a subgraph, P a ‘Sa connected graph, Conver Gy "cle ‘To prove that G has a spanning tree, then G must contain a simple circuit, Let Cy be sely, suppose that G is a connected graph. has no eyeles, then G is a true, If G is not a tree, in Gand e, be an edge in C)- »NOw construct the raph GE (ey), which is obtained by deleting ¢, from G but not removing Netex from G. Cleary, Gi iva subgraph of Gand it contain all vertices of G. Ny ey isan elge of et then G iva tree, IG, contains a eyele Cy, then we "ele, G ‘ted subgeaph G that contains all the vertices. LEG, tn ier, 2118 a connected graph. If Gi, is aeyclics "edge e, from C, and construct a conn J, then we continue this process, Since G has a faite of cycles “elie, then G24. cl “hey et Ga is a tree, If Gi, contains & eye! edges, it contains only a finite number © scanned with OKEN Scanner 480 Mathematical Foundation for Computer Science Hence, continuing the process of deleting an edge from a cycle, we obtain a connected subgraph, G, that contains all the vertices of G and is also acyclic. Thus, G; is a spanning tree of G. Hence the theorem. [Example 10.33] Consider the graph as shown in Fig. 10.47. Find a spanning tree of the graph, Solution In the graph given in Fig. 10.47, v, €, V3 €4 V4 7 ¥2 € Yj i8 a cycle. By removing e, from this cycle we obtain the graph G, = G — {e,}. This is a connected subgraph and it contains all the vertices of G, as shown in Fig. 10.51. “ee oi ey % yy — | 2 & ee . a Figure 10.51] Subgraph G, MA Now, in the graph G,, v; €, v3 €3 Vs ey V4 €4 V2 e; vis a cycle. By removing eg from this cycle, we obtain a subgraph G, = G— {e4, eg} as shown in Fig. 10.52. “ee M ey a V2 “ & & My 4M 8 ws Figure 10.52] subgraph G, This subgraph Gi is a connected subgraph and contains all the vertices of G. In Gy, v, €)¥5¢5¥4€ % €6 ¥2 €; v; is a cycle. Fie pemoving the edge es from this cycle, we obtain a subgraph G,= G— {ey eg es) as shown it ‘ig. 10.53. % ’ Oy % Ma - eo ep Ye Vy e Vo Figure 10.53] Subgraph G, Now, Gs is a subgraph of G and it does not contain any cycle. Hence, G; is a spanning tree of G, r © scanned with OKEN Scanner Graph Theory - ll 481 34] Find all sp in simple circuits. ng trees for the graph G given in Fig. 10.54, by removing the edges % % % % 4 6% [Figure 10.54] Graph G for Example 10.34 Solution This graph G has only one cycle v2 v3 Vs V2. Removal of any edge of the cycle gives a tree. Thus, there are three trees which contains all the vertices of G and hence are spanning trees of G. % Ys % % % % Me Ys Ms Ys Me % OM % % % 4 % (@T (b) Te (©) Ts Figure 10.55] Spanning tree of G The trees 7;, 7) and 75 shown in Fig. 10.55 are spanning trees of G. o /Algorithms for constructing spanning trees Theorem 10.22 This theorem states that “every connected graph has a spanning tree.” Moreover, the roof of this theorem gives the steps for constructing a spanning tree. However, the process of finding a cycle and eliminating an edge may not be efficient. Hence, instead of constructing a spanning trees by removing edges, spanning tree can be built by successively adding edges. ‘Two algorithms based on this principle for finding a spanning tree are breadth-fist search algo- rithm (BFSA) and depth-first search algorithm (DFSA). Breadth-first search algorithm or BFS algorithm In this algorithm, a rooted tree is constructed and the underlying undirected graph of this rooted tree forms the spanning tree. The idea of BFS is to visit all vertices on a given level before going to the next level, Procedure Step (1) : Choose a vertex arbitrarily and designate it as the root, Step (2) : Add all the edges incident to this vertex such that the addition of edges does not produce any cycle. The new vertices added at this stage become the vertices at level 1 in the spanning tree, Order them in an arbitrary manner. or each vertex at level I, visited in order, add euch edge incident to this vertex to the tree as long as it does not produce any cycle, Step (4) : Arbitrarily order the children of each vertex at level 1, This produces the vertices at evel 2 in the tree. Step (3): © scanned with OKEN Scanner 482 Mathematical Foundation for Computer Science Step (5) : Continue with the same procedure until all the vertices in the tree have been added, ‘The procedure ends, since there are only a finite number of edges in the graph. Since we have produced a tree without cycle containing every vertex of the graph, the produced tree is a spanning tree. Example 10.35] Finda spanning tree of a graph G, given in Fig. 10.56, by using BFSA. % Ye vy Y% A % Figure 10.56] Graph for Example 10.35 Solution Step (1) : Choose the vertex ‘v,’ to be the root. Step (2) : Add all the edges incident to the vertex v, such that the addition of edges does not produce any cycle. Hence, the edges {v,, v2}, {v), V3} are added. The two vertices v, and v, arc in level 1 in the tree. Add edges from these vertices at level I to adjacent vertices which are not already in the tree. Hence, the edge {vs, v4} is added. The vertex v, is in level 2. Add edge from v, in level 2 to adjacent vertices not already in the tree. Hence, the edge {vq, vs} and {v4, v7} are added. The vertices v, and v, are in level 3. Step (3) = Step (4) : Step (5) : Add edge from v, at level 3 to adjacent vertices not already in the tree. Hence, {05, ¥g} is added. ‘The steps of breadth-first procedure are shown in Fig. 10.57. % % a . @ i” © "8 : we % % & Me Bee (o) [Figuee 10.57 BFSA for Example 10.35 Hence, Fig. 10.57(¢) is the required spanning tree. © scanned with OKEN Scanner Graph Theory - I! 483 pepthefirst search algorithm or DFSA > this algorithm gives the procedure to successive levels in a tree at the carlic: ible opportunity, APSA ie also known as back tracking. levels in a tree at the carliest possible opportunity. Procedure Step (1): oa ly choose a vertex from the vertices of the graph and designate it as the Step (2) : Form a path starting at this vertex by successively adding edges as long as possible ae cach new edge is incident with the last vertex in the path without producing any cycle, Step (3) + If the path goes through all vertices of the graph, then the tree consisting of this path is a spanning tree, Otherwise, go to the next step. Step (4) : Move back to the next vertex in the path. If possible, form a new path starting at this vertex passing through vertices that were not already visited. Step (5) : If this cannot be done, move back another vertex in the path, i.e., two vertices back in the path, and repeat the process described in step (2). Step (6) : Repeat this procedure, beginning at the last vertex visited, moving back up the path cone vertex at a time, and form a new path until no more edges can be added. This process ends since the graph has a finite number of edges and is connected. Hence, a spanning tree is produced. Find a spanning tree of the graph, given in Fig. 10.56, using DFS A. Example 10.36 Solution ‘The spanning tree of the graph given in Fig. 10.56 can be obtained by the following proce- dure: Step (1) : Choose the vertex v; to be a root. cessively adding edges incident with vertices which are not al- Step (2) : Form a path by suc ( e ready in the path as long as possible. This procedure produces the path (¥), V5, Vy. Ys. Vn sani ae 5 Step (3): Aa ee to vg. There is no path beginning at v, containing vertices not already visited. : Step (4) : Similarly, on backtracking to vs, we observe that there is no path. Step (5) : Backtrack to v, and form the path (V4, ¥2)- This produces the required spanning tree which is shown in Fig. 10.58. % Ys Ms Ys % a 0.56] Spanning tro obtained by DFS © scanned with OKEN Scanner 484 Mathematical Foundation for Computer Science ct n-? dil ing trees, Theorem 10.23 (Cayley’s Theorem) The complete graph K, has n”~? different spanning trees. 2 a= 16 di ; Consider n = 4. The complete graph in this case would have 4* 7 = fe 5 16 different spanning trees, Alll the spanning trees of a K,, graph (Fig. 10.59) are shown in Fig. 10.60. My V2 vs M4 Figure 10.59] AK, graph M4 ve Up, Up % Ye Vigo “ ws ve ws ve a Sie (a) (b) ©) Ms Ve A vp vs Ye Vu ve % Me vs M4 vs Me vo M4 © 0 @ - ey i Ms M2 Ms Me “ Ye Me ve ws Ms vs M% vy Ms vse Vs “ Cy Figure I Spanning trees of a K, graph 0} Minimal spanning trees Let Gbea weighted weight. The weight certain pairs of cit Sraph. A minimal spanning tree of G is defined as a spanning tree of G with minimum ted graph G (Fig. 10.61) shows six cities and the costs of laying railway links between fies. We want to set up railway links between the cities at minimum costs. [Figure 10.61] A weighted graph © scanned with OKEN Scanner Graph Theory - 11 485 ince it ‘The solution can be represented by a subgraph. This subgraph must be @ spanning tree. coversall the vertices and it must be connected, Also, it must have a unique simple path between each pair of verti Thus, what we require is a minimal spanning tree. 7 Aorithms for minimal spanning trees Many methods are available for finding a minimal spanning tree in a given graph. Two methods, samely, Kruskal's algorithm and Prim's algorithm of finding a minimal spanning tree for @ connected weighted graph with no weight is negative are explained below, These two algorithms are examples of greedy algorithms. ° (i) Kruskal’s algorithm in this algorithm, we first select an edge of G which has the lowest'weight among the edges in G which are not loops. Then, for each successive step select another edge of smallest weight that does not make any cycle with the previously selected edges. Continue this process until (n ~ 1) edges have been selected and these edges form an acyclic subgraph T of G which is a minimal spanning tree of G. The algorithm involves the following steps. Input : A connected weighted graph G. Output: A minimal spanning tree. ; Step (1) : Choose an edge of minimal weight. If there is more than one edge of minimal weight then choose arbitrarily one of these edges. ; Step (2) : At each stage, choose (from the edges.not yet chosen) th whose inclusion will not create a cycle. Step (3) : If G has n vertices then stop after (n — 1) edges have been chosen. Otherwise repeat © edge of lowest weight step (2). 2 Example 10.37] Find the minimal spanning tree of the graph given in Fig. 10.62 by using Kruskal’s algorithm. “Wy 9 ow Figure 10.62] Graph for Example 10.37 ‘olution We collect the edges with their weights into Table 10.1, © scanned with OKEN Scanner 1 486 Mathematical Foundation for Computer Science Table 10.1 Wolghts of edges Edgo | (Wi Va) | (Wa Ya) | os Yo) (Ws Ve) | (Var a) | (Yar Ve) Wolght | _1 2 3 4 5 6 Edge] Wa Ma) | Win Yad | (Wir¥e) | Was ¥2) | (Ya ¥2) Woight 7 8 a 10 14 The minimal spanning trees are calculated as follows: Step (1) : Choose the edge (v4, v3) which has the minimal weight [Fig. 10.63(a)). Yy ue uss Figure 10.63 (a)| Step | Step (2) : Add the next edge (vs, v4) [(Fig. 10.63(b)] uy fom Va Figure 10.63 (b)] Step 2 Step (3) : Add the next edge (v, v2) [Fig. 10.63(c)] aa vs V4 Figure 10.63 (©)] Step 3 Step (4) : Add the next edge (v, vs) (Fig, 10.63(d)] ZL. § (d)] Step 4 © scanned with OKEN Scanner ry 487 Step (5) : Add the edge (1, v4) [Fig. 10.63(e)] Step (6) : Add the edge (v,, v,) [Fig. 10.63(f)] % ve % * Figure 10.63 () Minimum spanning tree Since the graph G has 7 vertices, it is enough to choose only 6 edges. Therefore, we stop the slgorithyp-and the minimal spanning tree is shown in Fig. 10.63(f). = Prim’s dlgorithm The algorithm starts at a designated vertex and chooses an edge with minimum weight. Consider this edge and associated vertices as part of the desired tree. Then an edge with minimum weight which bas tot yet been selected is searched in which one of its nodes is in the tree while the other node is not. The process terminates when (7 — 1) edges have been selected from a graph of n nodes to form 2 nninimal spanning tree. The algorithm consists of the following steps: Input : A connected weighted graph G Output : A minimal spanning tree . : Step (1) : Select any vertex and choose the edge and minimum weight from G. Step (2) : At each stage, choose the edge of smallest weight joining a vertex already included to vertex not yet included. Step (3) : Continue until all vertices are included. pa hted graph given in Fig. 10.64 by usin ete ; Example 10.38] Find the minimal spanning tree ofthe w Prim’s algorithm. s © scanned with OKEN Scanner 488 Mathematical Foundation for Computer Science Figure 10.64] Graph for Example 10.38 " Solution The following steps need to be carried out to determine the minimum spanning tree of the given weighted graph: Step (1) : Step (2) : Step (3): Choose the vertex ‘a’, Now, edge with minimum weight incident on ‘a’ is (a, c), (a, d), (a, e). Let us choose the edge (a, c) (Fig. 10.65(a)]. a Figure 10.65 (a)| Step | Now, w(a, b) = 4, w(a, d) = 3, w(a, c)=3, w(c, b) = 2 and w(c, d) = 3. Choose the edge with minimum weight. The edge (c, 5) has a minimal weight [Fig. 10.65(b)] a b Figure 10.65 (b)| Step 2 Again, w(a, c) = 3, w(b, d) = 1 and w(c, d) = the minimum weight [Fig. 10.65(c)]. . Choose the edge (b, «/), which bas a b ¢ Figure 10.65 (c)| Step 3 © scanned with OKEN Scanner Graph Theory -\|_ 489 Step (4) : Choose the edge (d, c) (Fig. 10.65 (d). Hence, all the vertices are covered. Thus, the minimal spanning tree is shown in [Fig. 10.65 (d)}. 7 b Figure 10.65 (d)] Spanning tree 103.5 Deci Rooted trees in which a series can be used to model problems in 1 ; Search tree can be used to locate items based on a series of ae Where a 4s whether we have located the item or whether we should go right or le! s ; 0; each time Beula Consider the following guessing game: “Amutha thinks of a ae n a aa ae — Bives an incorrect response, Amutha says whether Beula’s guess !8 ess than Y ing atmost 10 guesses, Beula can find the number ””. : Seeret Suppose Amah a s 687. We can apply the binary search algorithm (0 find n, Be 1a chooses 7 = . a Ruess is | Sx1e00 _ 2 = 500. in Trees of decision leads to a solution. A binary ch comparison tells + panyeen $00 and 1000, Beuta com Since 500 " YY <> ) % Using vertex ordering ¥s. Yes Ves Yor Vor Yor Ma ¥ ©) Figure 10.76] Graph for Problem 10.12 Figure 10.73] Graphs for Problem 10.9 10.13 Use Prim’s algorithm to find a minimum span- 10.10 Draw all the spanning trees of the graph given in Fig. 19.74. ning tree for the weighted graphs given in Fig. 10.77. u y a 5 > L°I\ a ; Figure 10.74] Graph for Problem 10.10 f 2 g 10.11 Obtain a spanning tree for the graphs shown in (a) Fig, 10.75 by using a depth-first search ap: A proach. y : 5 : V7 6 : * Vw" ee ® ) vn vere Devens Figure 10.77 : Graphs for Problem 10.13 10.14 Use Kruskal’s algorithm to find a minimum i : spanning tree for the weighted graphs vs (») shown in Fig, 10,78, With vortex ordering Vie Yar Vas Ma Von Vas Ve [Figure 10.75] Graphs for Problem 10.11 © scanned with OKEN Scanner Sa Cory OF en ’ y e Figure (72 ware tr Hoe GA © scanned with OKEN Scanner

You might also like