LEARNING Osjectives
Panay graphs * Trees
‘Colouring and covering
uider the utility problem. Suppose there are three houses W;, W, and W;, each of which is to be
ected to the centres of three companies, A,, 4, and A, which supply water, electric service and
phone service, respectively. If a graph satisfying the given requirements is drawn, then the graph is
mplete K;,, graph. For example, W, is connected with 4), 4) and Ay,
Now the problem is the following: Can we draw this graph in the plane such that no two edges
tsect except at the vertices? In this section, we consider such problems.
Letus consider the graph shown in Fig. 10.1.
Graph showing intersection of edges
Necan redraw the graph in Fig. 10.1 as follows (Fig. 10.2)
Mace Si on eS ce ea442 Mathematical Foundation for Computer Science
In the graph given in Fi
ig. 10.2, no tw
common end vertices of the edges. ?
Gis called a planar graph it it be drawn in such that no ty
$ tthe vertices, which may be the common end veces ofthe eles a
erlges intersect except at the vertices, which
es :
eo rene n
Thus, a graph is said to be a \lanar graph if and only if it has a pictorial r
‘which isa plane graph, This pictorial representation of planar graph G as a pla
representation of G.
Note 10.1 If a graph G is drawn with crossing edges then it is not necessary that G is a non
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, 4
[Example 10.1
Consider the graph shown in Fig. 10.3. Is it planar or non-planar?
Figure 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.
[gr 14] near graph
In Fig. 10.4, no two edges cross each other,
Thus, Fig. 10.4 is a planar graph, Ase
Hence, Fig. 10.3 is a planar graph, though it appears to be a non-planar graph.
[Example 10.2) Consider the graph in Fig. 10.5. Is it planar or non-planar?
nn Se
oriGraph Theory -Il 443
Graph for Example 10.2
‘can be redrawn as shown in Fig 10.6.
ee ia
[Figure 10.6) Redrawn graph
no two edges intersect except at the vertices, wi
‘the graph is planar.
planar representation of a planar graph as shown in Fis
the planar graph as shown in Fig. 10.7. Graph G divi
hhich may be the common end vertices
s
10.7.
the plane into different re-444 Mathematical Foundation for Computer Science
[Example 10.3) Consider the graph as shown in Fig. 10.8 and discuss the cl
graph in detail.
Figure 10.8) Graph for Example 10.3
Solution This planar graph divides the plane into the following three regions:
Region 1 (R,) : This region is bounded by the cycle v; &; ¥; &> V5 & ;- The boundary of R, consist
of the edges ¢,, ¢) and ¢
Region 2 (R,) : The region Ry is bounded by the cycle vy e4 Vs es ¥y €s V4. The boundary of R
consists of the edges 3, e, and es.
The regions R, and R, are the interior regions of the graph.
Region 3 (R,) : The region R, represents the part of the plane outside the given planar graph, Thy
boundary of the region consists of the edges €), eg, és, €, €; and ey.
Hence, the given planar graph has three faces Ry, Ry and R;, For this planar graph, we can airs
* number of edges, n
© number of vertices, n,
number of faces, ny=3
ey
Therefore, n,n, + 1y=5-6+3=2 , "
Consider the graph shown in Fig. 10.9 and discuss its characteristics in detail
wy
es,
ge
ete maya Inept asGah Theory -0 4s
planar graph has two faces # and # Few thes pimnae graph we iota
a3
m,=5
- ”
[RTOS ence x erage 105
This is 2 planar graph. This planar gragh dovides the plane imto two regoms.
am interion region of the graph. The tencudary comets of the ebges €5,€>, £3
1 ty forme exericn region ch the gph. The boundary consists of the ges les
mod ey446 Mathematical Foundation for Computer Science
Thus, ny 1
‘We now show that G contains a vertex of degree |
Choose a vertex vin G.
If deg (v) = 1, then we are done.
Suppose, deg (v) > 1, let v, be an adjacent vertex of v. As G has no cycles, G is logy
and hence v, is different from v.
If deg (v,) = 1, then we are done.
Suppose, deg (v,) > 1, let v, be an adjacent vertex of v;. AS G has no cycles, v, is. 3
from vand v,. | , 21 tia
If deg (v,) # 1, we find an adjacent vertex vs of v2 different from v, v; and vs
Because G has a finite number of vertices, it follows that G has a vertex w of degree 1. We
now delete this vertex and the only edge that is incident with the vertex. Thus, we form
new completed planar graph H with (k ~ 1) edges and (1 ~ 1) vertices,
By the induction hypothesis, for this graph H7, we have ”,
Henee, (¢— 1) —(k=1) +n/=2
Sa i-ktny
=n, —n, + y= 2 holds in G.
=n, + n= 2
Case (ii) : Suppose, G has a cycle C.
Let be an edge in C. Now, construct a new graph G, = G— {e}. This G, is a planar graph
For this planar graph G,, we compute n,, 7, and ny
Let n= m. In the construction of G,, we delete only the edge ¢ without deleting ay
vertices.
Therefore, n, =, ne = k-1
Now, C- {e} isnot a cycle in G. Thus, the edges of C— {e} will not form a boundary in
Therefore, in G,,n,=m-1
Hence, G; is « connected planar graph with n, = vertices, n, = k~ 1 edges andn/=™-!
regions. unaial
By the induction hypothesis, we can write
1-(k-1) + (m-1)=2
=t-ktm=2
Sn-n,+ny=2
‘Therefore, by the principle of mathematical induction, the result is true
Hence the theorem. ‘448 Mathematical Foundation for Computer Science
3, $3n,-6
Now, suppose that , > 3.
IEG does not contain any cycle, then we can show that", = My = 1
Now, 3m, = 6 = (m, = 1) + (nm, = 2) + (n, = 3) > = De
=n, <3n-6
Suppose, G contains a cycle. Since G is simple, it may contain a cycle with three edges,
number of edges in the boundary of a face is 2 3. Now, there are n, faces and every edge is,
of some boundary of the planar representation. Hence, the total number of appearances of
boundaries of n, faces is > n,- 3. In counting these appearances, an edge may be counted at
Thus, the total number of appearances of the ‘e’ edges in boundaries is S 21,
Hence, 3ny 2n,
By Buler’s theorem, n, —n, + ny" 2
= 3n,—3n, + 3ny=6
=> 3n, = 3n, + 3ny-6
=3 3m, S3n, + 2n,- 6
=, S3n,-6
=n, S3n,-6
Corollary 10.3 \f G is a connected simple planar graph with n, (2 3) vertices and n, edges and,
circuits of length 3, then n, < 2n, -4
Proof \f the graph is planar, then the degree of each region is at least 4. Henee, the total
edges around all the regions is at least 4p Since every edge borders two regions, the total number of
edges around all the regions is 2,
Therefore, 2”, 2 4n,
= In/Sn,
If we combine this with Euler's formula, we obtain
=n-n,tnj=2
= 2n,-2n, Inj=4
=) ny= 4-2, + In, Sn,
=n, $2n,-4
Corollary 10.4 The graph K, is not a planar graph
Proof The graph K; is shown in Fig. 10.12.Graph Theory-ll 449
(Y, £) be » graph. Suppose that ¢ is an edge with v, and v, as end vertices Construct a
| = Ge}. To construct G, we have deleted edge without deleting any vertices from @
construct anew graph G, = 4) by taking V,= VU (u), £=(EMe))Y Unda) such that
E:v,, ware end vertices of f,, and v;, w are end vertices of f;. The process of obtaining
Gis called a one-step subdivision of an edge of G
o »
| (IR smoveonctngres
from G by a finite % of subdivisions of edge. Thats Hi
pas a bi@) (o)
(ir 114) ror ana
In the given graphs, G contains a cycle of length 5 and H contains a cycle of length 4. Hence, these
two graphs are not isomorphic. However, we can find a subdivision G, of G and a subdivision H, of H
(shown in Fig. 10.15) such that G, and H, are isomorphic. Hence, G and H are homeomorphic graphs,
o> C4
(6) )
Figure Subdivisions of G and H
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 contain a
subgraph homeomorphic to K‘, or K,,,
The proof of the above theorem is not given here as it is beyond the scope of this book.
[Example 1016) Using Kuratowski'stheorem, prove thatthe Petersen graph G, shown in Fig, 10.16,is
‘not a planar graph.
Itis to show that G contains a
4, but G contains no vertices ofaE
9 st Ky Let ws find» subgraph of homeomorie 10 Kay The Bhs Hi
10 17(b) 188 suberaph of G and H is a subdivision of graph K3 5.
u% y %
}
Ys! Va
CT
“ts ty %
(a) Kyo (b) Graph H
His a subgraph of G and subdivision of Ks
Kuratowski’s theorem, we find that the Petersen graph G is not planar graph. .
EXERCISES —_—_——a a eT
1 Fade number of faces and list the edges of 10.2 For the planar graph shown in Fig. 10.19, find
the number of faces and list the edges of
Tye boundaries forthe planar graphs shown in
“Fig. 10.18. boundaries.452 Mathematical Foundation for Computer Science
104 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.
The concepts of colouring and covering have been discussed in detail in the following
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
‘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 Gj
then G is said to be n-colourable. ee
[Exempt TO Consider the graph shown in Fig. 10.21. Show that it is 4-colourable.
/
\
|
:
vi %
‘
[Figure 10.21] Graph for Example 10.7 *
Solution The graph given in Fig. 10.21 has four vertices v,, v>, v;and vy. Let C= {R, B, ¥.G}
of 4 colours, where R denotes red, B denotes blue, Y denotes yellow and G denotes green.
— C such that
$0) = Re flv) = G, flvs) = Vand flv,) = B.
Then, f denotes a proper colouring with four colours.
Is there a proper vertex colouring of G that uses less than fourGraph Theory - il 453
Graph for Example 10.8
igrven in Fig. 10.22 has five vertices v;, v, vy, vyand vy. Let C= (R, B,G) be 3
Re dences red, B denotes blue and G denotes green. Define f: V > C by
Mhv;) = Rls) = R flv) = flv:) = Band fv) = G
n Lf ts a proper colouring of this graph with three colours.
s yproper vertex colouring of thes graph that uses less than three colours?
Graph for Example 109
poate geaph with bipattion VV, where Y= (v1, ¥p,¥5) and Fa= {Vn ¥ah
S0)=Rifve V,
Ie) =Bitve V;
in V, are adjacent and no two vertices in V; are adjacent.
.
simple graph. Then, X(G) = 2 if and only if G is a bipartite
ad emssion Agerg 2A ke)/484 Mathematical Foundation for Computer Solence
Clearly, fis well-defined, since Fo), ©. Also, no wo vertioes OF V) are adjaeont,
Vettices in V) can have the same colour. s
In addition, no two vertices in V, are adjacent, Therefore, all vertices in Vy
solour, From the definition of f, we ean state that two adjacent vertices of G ha
Therefore, X(G) $2. Since G contains at least one edge, XG) ® 1
Henee, X(G) = 2
Conversely, suppose that \(G) = 2. This implies that the graph contains atleast one
Also, there exists a function /) > C= (r),r,} such that no two adjacent
image. Let V, = (ve Visi) =r) and Vy = (ve Vif) © Fy)
= VO Vy = @and YU Vy =F
Let e be an edge with end vertices v, and vy. Since v, and v) cannot have the
and only if v; € Vs. Hence, @ is a bipartite graph
Definition 10.7
Let G be a graph with vertices ¥,, v, so Vy ty Yy The maximum:
mis denoted by A(G). That is,
A(G) = max (deg(v)/i = 1, 2, ..., mp , ie
[rampie 10.10] Consider the graph G shown in Fig, 10.22. Find A(G),
Solution In G, deg (v,) = 3, dex (v,
Hence, A(G) = 4
From Example 10.8, we have X(G) = 3
3, deg (vy) = 4, deg (v4) ® 3, deg (vg) "3
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 bem. We will prove the theorem by
using induction on n.
Basic step: Let n=. Then, G is a graph with only one vertex and G has no edge.
Hence, X(G) = 1 and A(G) = 0
= XG) < A(G) + 1, forn=1
Inductive hypothesis: Suppose that k is an integer with k> 1 such that for
(k—1) vertices : X(G) < A(G) +1
Inductive step: Let G be a simple graph with k vertices, Consider a vertex
graph G, = G—{u). The graph G, is obtained from G by
ergs incident with v. Clearly, A(G,) $ (G) Thisisa simple graph with (k
induction hypothesis, we can write, vo ieee a
MG) <(6,) +1
‘So, We can say that G, can be properly coloured by at
adjacent vertices As A(G) © 0G) +1, otal he
Cie Gy Sins Sager St ei
iGraph Theory ll 485
of only isolated vertices is monochromatic (or I-chromatic),
| Vis the number of vertices in G.
requires m colours, then A(G) $ m.
x Gis d, then almost d colours are required to colour vertices adjacent
tic graph, has at least k vertices v such that deg (v) 2k ~ 1
the chromatic number of the complete graph k,, with n vertices,
‘two vertices are adjacent in a complete graph, no two vertices have the same
ot be coloured with fewer than n colours,
er the graph k, as shown in Fig. 10.12
Find the chromatic number of bipartite graph K,y,,
the chromatic number of every bipartite graph is 2, we can write
X (Kegs n) = 2
ple, consider the graph K,,, as shown in Fig. 10.24.
a, a uy Ue
a % %
(eT) A.
chromatic number of Cy for n= even and n = odd, _
colour X(C,) = 3, if'n is odd.
0 yycle. If n ‘aw need the third ae fo the st
p.m be tmgsciera odo wi 5 ag ig486 Mathematical Foundation for Computer Science
C @
— 4,
% |
or al *
0 fa
Oo
(Pir 185) cu Cae,
fcamplaTO4) Determine the chromatic number of w, where w, is the wheel
Solution X(w, = 3) if nis even and X(w,) = 4 ifn is odd.
For example, consider the graph W, as shown in Fig. 10.26.
gD
v
Sac Be a
[Figure 10:26) W,sraph
deg (v4) = 5 and all the other vertices have degree 3.
A(G)=5
$A(G)+1=6
a triangle subgraph of G, we can write
MG) 23
secording to Rule 5 there would be at least 5 vertices
| ig not true. -Graph Theory -
457
aie: . ,
the S-colouring of G’ be c, 2+ 3+ 4s Cs. If some color
to u, then by assigning the colour ¢ to w the Stun: aa
Of G. Hence, we have to consider the case ;
colouring the vertices of G adjacent tow. Lety
By induction hypoth
esis, the pl
15 not used in colouring y
uring of G —u = G’ can be extende
in which deg w= 5 and all the five
v4 and v, be the vertices adjacent to
Os Cds C3» C4 ANA Cs, respectively. Let 1 3 denote the subgraph of G — w induced by
ieoloured ¢) of 5. If v, and v, belong to different components of H,;, then a 5-colour
pbe obtained by interchanging the colours of vertices in the component of H,, contain
ipo Yertices of this component is adjacent to a vertex with colour c orc
inthis S-colouring, no vertex adjacent to u is co oured c, and hence by coloring u with
fing of G is obtained. If v, and v, are in the same component H,,, then in G there exists a
poth all Of whose vertices are coloured with either c, or c;. Hence, there is no ¥2 — v4 path al
Vertices are coloured with c,, c, (Fig. 10.27)
denotes then v, and ¥,
_ y induced by the points coloured c, or C4, tec
eet = if we interchange the colours of the enn
5% S-colouring G— uw results and inthis, no vertex adjacent
othe colour ¢, to m, we get a S-colouring of
io is true for all values of K.
of H, containing v2, anew
with cy. Therefore, by assign
‘of mathematical induction,458 Mathematical Foundation for Computer Science
[Beanie TONS) Let G = (v, £) with | V|~n and B= @. Find the chromatic
Solution Given G =(V, E) with | V| = nand E = 6. Then, G consists of m isolated y
Hence, by the product rule, Pg(A) = 2". o
Given G = k,. Then, show that at least n-colours must be
properly.
Solution By the product rule, we can write
Pol A) = MA= 1) (A= 2) ont WD)
For A
0, when
For example, if G = K,, then we start colouring from vertex v, and this can be done
are left with (A ~ 1) choices. Then, v, being adjacent to v, can be coloured in (A. ~ 1)
Since v, is adjacent to both v, and v,, the colour used for v, and v, cannot be used for
can be coloured in (A ~ 2) ways. Again, v, being adajcent to v,, v, and v, can be €o
ways.
Hence, by the product rule, we can conclude
P(A) =4(A~ 1) (A 2) (A 3) and the chromatic number is 4 since P¢{A) > 0 for the
when A= 4
Note 10.3 If Gis a path of n vertices, then Pg(A) = A(A—1)""!
pie 10117] Find the chromatic polynomial and chromatic number for the graph Ks giv
Fig. 10.28.
[Figure 10.28 | K; 5 graph for Example 10.17
Solution Chromatic polynomila for K,; is (2 — 1). Thus, the chromatic
Since MA—1)'>0 first when = 2.” »
Here, only two distinct colours are required to colour K, .
Find the chromatic polynomial
eeap Traery
%
”
a i
Gragh tor Exava 1008.
‘Since G is made up of components G,, G, 20d G,, where G, =
7 verte. Now, G, can be coloured im 113.1) (0. 2) ways, Gy
vn 1. ways. Therefore, by the product rule, G can be coloured in Ui. ~ 0)(h~ 2)UR
= 1 (2. - 2) ways. is
10.8 Decomposition theorem: \f G~ (VE) a 2 commexten graphs mae ~ 95%) € Em
D)= PIG. 2) + PUH,, 2), where G, denotes the subgragh of G chnames by deleting « Soom G
removing the vertices v, and v,, that is, G, Gc and H, i the seconds salogragls of G
ifrom G, by coalescing the vertices v, and 7,
Lae= {%,¥2)
lof ways to properly colour the vertices in G, = G— ¢ with 3. cohouns i FUG,- 2)
where end points v, and v, of ¢ have different coloues are proper colonia of C
He of G, that are not proper colourings of G occer when 7, ad +; awe i seme
,cach of these colourings correspond to a proper colouring fox Hl, This partisam of
proper colourings of G, into two disjoint subset resales
PG, 2) = PG, 4) + PH.)
ting decomposition theorem find the chromatic potyaoesial and neace te Se
matic number for the graph given in Fig 10.30.460 Mathematical Foundation for Computer Science
Then, the chromatic polynomial of ¢
PUL MMA
Hence, by decomposition theorem, the chromatic poly
is given by
nomial of G is written as
PIG A= A= DS AA = 1) (A= 2)
AA ILA= bP == 2)]
= AQA- 1) 2-304 3)
= (4-1) 02-3043)
A308 4 32-08 bP 3K
Ata + 6A? 32,
Theorem 10.9
(i) For each graph G, the constant term in PCG, Aj is 0.
(ii) Let G = (VE) with | E| > 0. Then, the sum of the coefficient in P(G,A)=0.
Proof
(For each graph G,A(G)> 0 since 1”= @. If P(G, A) has constant term ‘c*, then P(G,0)=¢#0
This implies that there are a number of ways to colour G properly with 0 colours, which isa
contradiction.
Hence, P(G, A) =0
(ii) Since | E|2 1, A(G) > 2, we cannot colour G properly with only one colour.
Therefore, P(G, 1) he sum of the coefficients in P(G, 2)
Example 10,20] Explain why each of the following polynomials cannot be a chromatic polynomial
() B+ ON - 32+ 8=0
(ii) At + 403-323
Solution (j) Since the constant term is 8(¢ 0), the given polynomial cannot be a chromatic polynom
(ii) Since the sum of the coefficients is 2(¢ 0), the polynomial is not a chromatic polyno-
Edge colouring
Definition 10.9
Edge colouring of a graph G refers tothe assignment of colours to the edges of G so that no two
edges with the same vertices receive the same colour.
i h.
[Example 10.21] Consider the graph shown in Fig. 10.31. Find the proper edge colouring of the grap!Graph Theory - 11 461
Graph for Example 10,21
jon LLC™ (R, B, ¥, G), where R denotes red, B denotes blue, ¥ de
notes yellow and G denotes
vefne f: E> Cin the following manner:
Ke) = RF) = G. fle) = B.fles=y,
S(e2) = Band fle.) = R
Thus, fis a proper edge colouring of the graph of Fig. 10.31 with four colours,
ition 10.10
‘minimum number of colours rei
quired in an edge colouring of G is called the chromatic index of
and is denoted by X"(G).
Forexample, the chromatic index of the graph G shown in Fig. 10.32 is 4. That is, x(Q@=4,
ie.
2
Figure 10.32] A graph G with colouring index 4
‘e104 Thus, 10 edge colour, a graph is partitioned into subsets such that no two edges in the same
“Sethave a vertex in common. All edges in any part of the partition are known as disjoint,
‘tof disjoint edges in a graph is called a matching.
vem 10.10 X°(K,) = nif n is odd (n #1) and
X(K,) = n—1 ifn is even
Mr ttn the result is trivially true. We assume that 2 3. If is odd, any matching in K, has
. xh
Ug, o~1) (n-1) n(a-1)
2 edge. So, at most
1 edges can be given any colour. But, there are "=" edges
So, atleast n colours are needed, We can colour the edges of K, in the following way.
ee ee la462 Mathematical Foundation for Computer Science
Represent A’, as « regular graph with all diagonals drawn, Colour the edges around th
with a different colour for each edge, and then colouring each remaining edge paralel wit
an edge colouring using ” colours. This giy
For example, n = 5 is illustrated in Fig. 10.33
Figure 10.33] AK, graph
If mis even, we can colour K,_ ;, using (1 ~ 1) colours as described above,
First, we obtain KX, by joining the complete graph K,_ , to a single vertex, then there is one color
missing at each vertex, and these missing colours are all different. So, we ean use these (m~ 1) colou
to colour the added edges. This gives an edge colouring of K,, using (#1 ~ 1) colours, This has bec
illustrated in Fig. 10.24.
Edge colouring of Ks
Note 10.5 If Ais the largest vertex degree of G, then X’(G) 2 A.
Theorem 10.11 Vizing Theorem
If G isa simple graph with maximum vertex degree A, then A S.X"(G)SA+1
Theorem 10.12 X"(G) =A for all bipartite graphs G.
10.2.2 Covering
The concept of covering may be defined as described below.Graph Theory - |)
mn 10.1
ing of a Braph C= (V, E)isa subset K op
ea covering K is called & minima covering ent eve
she aumber of vertices in a minimum covering of Gis ea
by B.
463
*Y edge of G is incident with a vertex
Overing L with | L|<| K |,
Hled the covering number of G and is
jon 10.12
f is called the independe, i i
‘zabset So} roa Pe ‘ent set of G if no two vertices of S are adjacent in G. An
i. indent set S is said to be maximum, ifG has no independent set U with IU|>|Ss|.
? ‘The number of vertices in a maximum independent set is called the independence number of G
is denoted by cx.
i:
Geanple 10.22] Consider the graph as shown in Fig 10.35, Describe the various sets of vertices in
the graph.
vy
Figure 10.35 | Graph for Example 10.22
Solution {vg} is an independent set.
(v2) in a maximal independent set.
£4, Vp, V5, V4y V5} is a covering.
. is a mini ering,
{¥2, V6, Vgy V5} is a minimum co’ ; uh
Theorem 10, fr i tS Vis an independent set of G if and only if V Sis a covering 0
M13 Ase
hoop
only
f and only if no two vertices of S are adjacent, that is, if
y the definition, $ is independent i tof VS.
if every edge of S is incident with atleast one point
| >ifand onty if Y— Sis a covering of G. a
rem 1 +s with m vertices. Then the sum of covering number and the indep
nimber va i . That is
“Se number praia aie number of vertices of G. Tha
a+B=n464 Mathematical Foundation for Computer Science
Proof Let S be a maximum independent set of G and & be a minimum covering of G. We can write
[S|=aand|«|=B
Now, /-Sis a covering of G and K is a minimum covering of G.
Hence, | K| S| S|
=BSn-a
that is, a+ Bsn
Also, V~ kis an independent set and $ is a maximum independent set.
(10.2)
Hence, |V- Al $| S|
=n-Bsa
ieatBsn
From Eqs (10.2) and (10.3), we get
a+B=n
(10.3)
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
a +P=n
Proof Let S be a maximum independent set of lines of G such that | S| = a’. Let H be a set of lines,
one incident line for each of the n - 20 vertices of G not covered by any line of S. Clearly, SU Hisa
line covering of G. Therefore, |S UH | 2 B’. That is,
a’ +n—-20’2 8’
=> n2a'+p’ (10.4)
Now, let 7'be a minimum line cover of G.
=ITI=Bot pave a line ‘e" both of whose ends are Graph Theory «1
“tl 46s
Mingaph of G induced by 7 Thi ie incident with lines
si o
es that GIT} is the Tother thane Let Gt Tbe the
tine of TS incident with atleast one nin
of exactly one end point for Serie point of GIT). Let w " f stars,
, of be a set of end;
jwyet Tl =’ and cach points of GIT]
pce, | FI ach star has exac
gsi GUT) exactly one point not in W. Theref
refore, n= | W| + number
ee pt number of stars in G[7]
(10.8)
poesia one line from each star of G[7], we get a set of
sense, 2 number of stars in G7]. Thus, Eq. (10 eee ao G
5) becomes
nsPta’
pom Eqs (10.4) and (10.6), we get (106)
a +P=n
106 In general, the complement of an independent set of lines is not a line covering.
as trees and networks, which are essen-
ffa tree was initially introduced to study
of the most widely used and
1t concepts, such
‘ory. The concept o
chemical composition by Cayley in the year 1857. Trees form one
yy of the applications in graph theory directly or indirectly
4s section, we will discuss some importan'
for complete understanding of graph the
Man:
hierarchy. In Computer
trees play a vital role in
ively studied subclass of graphs.
trees. Trees are useful in descr
trees are usefull in organizing an
theory.
| Trees and their Properties
and related concepts may be defined as given
re which involves @
bing any structu
base. Hence,
d storing data in a datal
below.
connected acyclic graph is called §
conneetmree_ Its edges ave called
graph, and
fe is known as
tress are components of 8 FFE
called an acyclic
graph with no eye!
called a forest. Hence,
ost five vertices:
- that contains no cycles is
. eet words, a connected
Any graph without cycles may also be
4
tae 10.36 shows examples of ees Wi aime466 Mathematical Foundation for Computer Science
Me
Ms M3 iy
Me Me V2 Avs
”“
Ms Ms “4
M2
(2) One vertex (b) Two vertices (c) Three vertices (4) Four vortices (e) Four vertices
Ms Vs Va
Va Ys
Vy
M3
ae [ow
V2
v2 }
Mt
(0 Five vertices (g) Five vertices _(h) Five vertices
Figure 10.36] Example of trees
Atree with only one vertex [Fig. 10.36(a)] is called a trivial tree, otherwise Tis called a non-trivial
"
tree [Fig. 10.36(b-h)]-
Example 10.23) Consider the graphs shown in Fig, 10.37 and determine wheth
Ms
vy os v
ve i
s
Ms Me
vs
“i Ys
Ye Ye
(@)
(b)
ier they are trees.
[Figure 10.37] Graphs for Example 10.23
both the
a
Solution The graphs given in Fig. 10.37 are connected as they have no cycles. Hence,
graphs shown are trees.
[Example 10.24] Consider the graphs shown in Fig. 10.38 and deter
mine whether they are "ees:Grats Trey - 8 467
(a)
[Figure 10:38) Graphs for Example 10.74
a Each of the graphs given in Fig. 10.3% nected. ¥ b
seth ae gepheis bee are connected. However, tosh of 9
.
(or) properties
(1) (Theorem 10.10) There is only one path between es
Let wand v be any two vertices ofa tree 7. If
Tisa connected graph, there is atleast one path fr
from w to ¥, Say, Py = (4, Wy, Uy, «.., U, v) and P. = (u, v
we have the following two cases: .
:P,OP,;=@
is. tgs V) OV (ty Vp0 Vay nee Yan Y= @
tte path P, followed by the path P>, that is, (1, ts, tyr te ¥> Yar -o-s Ye Mh form 2 Eche fom
7, which is a contradiction.
P.O P,=9.
(9): P,P, 49
yyy ony Me V) A (te V9 ¥2
4, v,, for some i and j. Let #;
Tren, we follow path P, until we come to the
an EQ
be the first common vertex other than u and v on paths P, and
first vertex. say w,, which is again on both P, and P
vertex w, is different from w,. We must get such a vertex w,, because P, and P; meet again at ¥
Le.0 be the portion of the path of P, from 1 to w, and R be the portion of the path of P; from w,
Thea the path Q, followed by the path R, forms a cycle from w to w, in graph Tr.
isa contradiction to our assumption that 7 is a tree. Hence, T does not contain two distinct
between any two distinct vertices u and ¥.
ly one path between every pair of
Let G be a graph. Since there is one and only one path between every pair of vertices, Gis
~Acycle in impli there is atleast one pair of v t
: a graph implies that t ne aisesone path berwcen every par of468 Mathematical Foundation for Computer Science
Proof Let Tbe a tree with n-vertices, We shall prove the theorem by using induct
is the number of vertices of T. ction On n, where
Basic Step: When n= 1, then T has only
one vertex. Since Thas no eyeles, T'can n
ycles, thave any
That is, on
e=0=n-1
Therefore, when 1 = 1, the result is true.
Induction hypothesi: Suppose the theorem is true for n= k
tree with k vertices has (k ~ 1) edges.
2, where kis some positive integer. 4
Induction step: We prove the theorem for n= k +1. Let Tbe a tree with (£ + 1) vertices and let we
an edge of T. If we remove the edge wv from 7, then we obtain the graph T— 1a Then, the graph
disconnected, since T— uv contains no u— vy path. If 7-1 contains a u—y path, say u,v, then
when we add back the edge nv there would be a cycle u, ,,¥3, ....¥5 in T. Hence, get a contradic.
tion, since Tis a tree. Thus, T— uv is disconnected. The removal of an edge disconnect the graph into
atmost two components. So, T— uv has two components, say, T; and T>, Since, there were no ‘cycles in
T, both the components are connected and without cycles. Thus, T, and T, are trees and each hes fewer
than n vertices. Therefore, by the induction hypothesis, we can write
number of edges of 7, = (number of vertices of 7) - 1
and number of edges of T, = number of vertices of Ty - 1
that is, e(7) = v(7,)-1
and e(T3) = v(T3)- 1
But, 7; and 7; are constructed by the removal of a single edge from T. Therefore,
(1) = e(T,) + e(T,) +1
and v(1) = v(T,) + (73).
Hence, e(7) = v(7,) - 1 + v(T)-1+1
(7) + v(Ty) -1
(T)-1
=k+t-1
=k
= Thas k edges.
Hence, by the principle of mathematical induction the result is true for all values of k
Property (4) (Theorem 10.13) For any positive integer n, if G is a connected graph with n vertices m4
(n— 1) edges, then G is a tree.
Proof _Letn be any positive integer and G be a connected graph with n vertices and (n—1) edges: By
the definition, tree is a connected graph with no cycles. By the previous property, we have a tree wit
nn vertices has (n—1) edges. We have to prove the converse that if G has no cycles and (n-1) edge
then G is connected. We decompose G into K components ¢,, &3, ..., €,. Each component is conne
and it has no cycles. Since G has no cycles. Hence, each e, is a tree. Now,Grae tony My
eyeny 3 ond £, Fly N)
ity
Jor G has only one component Merve, 4 Wy 9 ise
al*
‘phe converse uf the prperiy (2) is hel Wye bay wrannighe sonwider he wen
107
shoves in Pig,
ODD, rag wiih toe marten ant ee aetgee
The graph given in Fig, 10.99 nus tow versions sud tise sbiges, Usrasner, i is aot siitee Because It
aoycle and the graph is not womens
1016 Set T be » graph with » vortises. Shion, tie toliowinny camditionss are equivalent
() Tis a tree
(ii) Every two vertions of 7 ase joined toy # weisiue garth
(il) Tis a connected graph and Ther (7 J) siges
(iv) Thas no eycles and has 1 J edges
) = (ii) (from property O))
(iil):
Foon our assumption, 7's # connexes graph aud sine ie uv epstios Hence, 7 is 4 mex: TAus, By
fp (3), Ths tn 3) es.
= (ivy; ’ )
Suppose, T conteins atlesst one vysle, Let C, be a opel io 7. We canter a aew graph 7, Sy
sean che #, from Cy ‘Dhie sew graphs T) = 2 ~ (o,)) ssmtaine all varices of 7 and alse
i, 888 OF T enceph the ofigs 2) Sinn # is aw ohige of a ayslie, 7 semaine 4 connected graph
cong Metis. Suppose, 7; oomiaine x oye Late, be ww etige of C,, Prsezeding a divcassed
weak conse the graph T, = (YB — te 5) a fd dh 72 6 3 connected raph With
We, +0, contains 8 vycle then we sepent the groness. Since 7 canta a Snute amber of
sa sat iio onnecind graph Ty ~ VB ey ty of). witel tas my eyote, Menez, Ty is
lie tbive vortices, By property (2), 31 kallows Ghat 7, iv 8 Seve wits C5) exis However. ftom
feting y anmeuction we find that the aumiver of oiges iv 7, is a-# Sinez 7, in ohnaned fom 75y
cont” ee, it Sollows that T hus (nv - 1% Ayediges Mow, £7 fase ~ i +e a1. Taeiee
Maen { our assumption thet 7 hws (wi - 1) edger
Nw syclos, Als, Thane (in ~ J) oes470 Mathematical Foundation for Computer Science
(iv) =):
Suppose T has no cycles and has (n - 1) edges. To prove that Tis a connected graph. Suppose 7.
T, are the components of T. Since T has no cycles, we find that each of the connected subgraph
. T, has no cycles. Hence, each of T;, T, is a tree. Suppose each T, has v, vertices, fal
qT,
by property (3), we find that each T, has n,— I edges. Then, the total number of edges is
in, = 1) + (my) + + (me Ds (Hg te Hm)
=n-k
Thus, n-1l=n-k
=k=l
= Thas only one component.
Thus, T is a connected graph and also T has no cycles. Hence, Tis a tree. Thus, all the four condi-
tions are equivalent.
Theorem 10.17 Ina tree with more than one vertex, there are atleast two vertices of degree one.
Proof Let Tbe a tree with more than one vertex. As Tis connected graph with atleast two vertices
there is a path with atleast two distinct vertices. Since the number of vertices and the number of edges
is finite, the number of paths in T is also finite. Thus, we can find a path P of maximal length. Suppose
path P is from vertex u to vertex v. We show that deg (u) = deg (v) = 1. Suppose deg (v) # 1. Let P be
the path (11, ¢y5 V3. €35 Vy «4 Yet» Ck 1» ¥)- Since deg (v) # 1, there exists an edge e, with vas an end
vertex such that e, 2 ¢,_;. Since G has no loops, the other end vertex cannot be v. Suppose the other
end vertex is vy. Let vy = v, for some i such that 1 $i $A 1. Then, (¥5 €4, Mp Cr+ ty Yas teers Mets Ce
1») isa cycle from vto v, which is a contradiction to the fact that Tis. tree. Ifv,#v, 1 SiS k= I then
we get a path (Vj, 1, Vay Cs V5, ---+ Men Ys Cty Ye) Whose length is greater than that of P. This
contradicts the fact that path P is of maximal length in 7. Thus, deg (v) = 1. Similarly, we can prove
that deg (u) = 1.
Note 10.8 The converse of the above theorem is not true. For example, consider the graph given in
Fig. 10.40.
Figure 10.40] A connected graph
Figure 10.40 shows a connected graph and it has atleast two vertices of degree 1. But it contains a
cycle. Hence, it is not a tree.Graph Theory -
432 lsomorphism of Trees aomenee
03.
pefition 10.16
1, (Vv, Ei) and Ta = (Va. Es) be two trees, The
a Tis isomorphic to T; ifand only ifthere existence
= (My, Ei) and T; = (V>, E,) are simple
Hawand vare adjacent in 7,
e-L0-one correspondence f: V; -» V5 such
are adjacent in 7,
10.25] Consider the trees 1) and T, given in Fig. 10.41, Show that they are isomorphic.
Vs Ws
We
K Wa i Wy
“ow ms
(@)T or
Figure 10.41 | Graph for Example 10.25
t exists a on
ifand only if f(u) and f(v)
Solution Let us define f: {v4, v3, Vy. vg. ¥5} > bo,
103) = Wy f (v4) = wa and f(v5) = ws
Clearly, fis one-one. Consider the adjacent matrices of T, and T,
fan be represented in the following manner:
Miva Ms M4 vs
e Wa Wa, Way Ws} by LH) = wy £03) = Wy
4y, and Ap, , respectively, which
yfooo1l
v]0 0011
~y/0 00 1 1
vl 1 1 0 1
v0 001 0
WW Wy 4 Ws
wfooo1)
7 wJ0 0011
™ wlo 00 1 1
wjl 1104
wlo 00 1 0
Notice that A>, = Ay, From the adjacency matrices Ay, and 4;,, it is clear that v, and v, are adjacent
"7 ifand only if, and w, are adjacent in T. Hence, 7; and 73 are isomorphic. "
ve rs .
""" 10.18 There are three non-isomorphic trees with five vettices.
—_472 Mathematical Foundation for Computer Science
Proof Consider the trees 7), T, and Ty as given in Fig. 10.42.
Ys
on |, on
Figure 10.42] Trees with five vertices
Trees Ty, Ty and T; have five vertices. We show that any tree T with five vertices is isomorphic to
one of these trees. Note that each vertex of 7; is of degree | or 2. But, 7; contains a vertex of degree
3, 7; contains a vertex of degree 4 and 7; has no vertices of degree 4. Hence, 7), 7, and 7; are non.
isomorphic trees. Now, we show that any tree J with five vertices is isomorphic to one of 7, 7,, 7,
For this, consider a tree T with five vertices. By property (3), T has four edges. Hence, the degree of
each vertex of Tis $4.
Case (i): Suppose that 7 has a vertex of degree 4. In this case, all the four edges are incident on
this vertex. Hence, T is isomorphic to 7).
Case (ii): Suppose that T has no vertices of degree 4, but T has a vertex of degree 3.
Suppose v4, vy) V5, ¥y and v5 are vertices of T’and deg (v3) = 3. Then, there are three edges that are
incident with vy
=> v; has only three adjacent vertices.
Suppose v, vs and vs are adjacent vertices of v, Because T'is a connected graph, vertex v; cannot
be an isolated vertex. Therefore, v, is adjacent to one of the vertices v2, vz, vs. Since the total number
of edges in T'is 4, v; is adjacent to only one of the vertices v2, v4, ¥5. Hence, in this case, T is isomor-
phic to one of the trees as shown in Fig. 10.43.
My
Ms
Ms oe Ms Ye “ Ye “OM
Figure 10.43] Isomorphism of trees
However, each of these trees is isomorphic to 7. Hence, 7 is isomorphic to 7.
Case (iii): The degree of each vertex of Tis < 2. Since the sum of the degrees of the vertices is
2x 4=8, the degree of each vertex cannot be 1.
Therefore, there exists a vertex of degree 2.
Suppose the vertices of Tare v4, vz, v5, ¥g and vs, Let v3 be the vertex of degree 2. Then, vs has only
two adjacent vertices, say v, and v5, Since vertex v, of T is not an isolated vertex and v, is not an
adjacent vertex of v, it follows that v, is an adjacent vertex of v3, ¥4 OF V5.Graph Theory - |}
oo
Ya ¥% % ee 473
(a) "inna ayn aaa
(b)
-—-——— +.
MN —
‘ DT
()
(@)
Figure 10.44] Vertices of T
Suppose vy is an adjacent vertex of v,. Then v, cannot be an adjacent vertex of v,. Now, the degr
is? Consider vertex I follows that sis adjacent ier or but not vo both (Fig. 10.151)
Sjher case, T's isomorphic to 75, The case of v, being adjacent to v4 is similar to the case where y,
adjacent (0 V2. Hence, in this case also we can show that 7 is isomorphic to 7. Now, consider the
Ht i adjacent 10 vs, Since Tis connected, or vis adjacent tov, oF v4. If is adjacent tov
yp then as before we conclude that 7'is isomorphic to 7. I'vs is adjacent t0 v2 OF v4 then we can
je that Tis isomorphic to 75, Hence, we find that there are only three non-isomorphic tres
ih five vertices.
03.3 Rooted Trees
this section, we discuss some special types of trees and describe algorithms to implement some of
rooted tree is a tree in which a particular vertex is distinguished from the others and is called the root.
In contrast to natural trees, which have their roots at the bottom, in graph theory rooted trees are
Apically drawn with roots at the top.
First, we place the root v, at the top. Below the root and on the same level, we place the vertices
at can be eed trams the root on the same path of length 1. Under each of the vertices and on the
tne level, we place vertices that can be reached from the root on a same path of length 2. We
ntinue this, process until the entire tree is drawn.
10.18
lol ofa vertex is defined as the number of edges along
ofthe root is defined as 0. The vertices immediately Hn
the unique path between it and the root. The
der the root are said to in level 1, and so,0n-
aximum level to any vertex of the tree. The depth ofa474 Mathematical Foundation for Computer Science
Definition 10.20
Let be any internal vertex of rooted tree 7. The children of vare all those vertices th j
to vand are one level farther away from the root than v, at are adjacent
(or)
Let T'be a tree with vp as a root and Let (Vp, €1. Vs 2, Ya
achild of yy. for k= 1,2, a.m
Itwis a child of y then vis called the parent of w. Two vertices that are both child
ren of
parent then they are called siblings. ofthe same
%q) be a path in 7. Then, v, is called
Definition 10.21
{fa vertex v of T has no children, then v is called a leaf or a terminal verte. If is not a termina
vertex then it is called an internal vertex.
Definition 10.22
Let Tbe a rooted tree. Let w and v be distinct vertices in 7, Then, v is said to be a descendant of w if
wand v are on the unique path from the root of T'to v and u appears before v on this path.
Example 10.26) Consider the tree shown in Fig. 10.45 and describe its different components,
us Uw
Figure 10.45 | Rooted tree for Example 10.26
Solution In the rooted tree 7, the level of vertices 1,1; and 1, is 1; the level of vertices us, Wet Ms
ug and yo is 2; the level of vertices 111, 12 in 3 and the level of vertices 13 and th, is 4. The vertices
Ug, U7, Ugy Ugy Uy, My), Mp3 aNd m4 are leaves. All other vertices are internal vertices. The vertices us, M6»
U7, Uyy, Uy2, My3 aNd Wy, are descendants of v. ®
Definition 10.23 : a
‘An ordered rooted tree is a rooted tree in which the children of each vertex are assigned a fix
ordering.0.27] Consider
ie! ‘onsider the rooted tree 7 gj, Graph Thy
ree T given in Fig, 10 sory = 47s
10.46, ke
Figure
igure 10.46 | Rooted tree for Example 10.27
i) What is the root of T?
(
(ii) Find the leaves and the inter erti f
(What are the level of w oda eee
(iv) Fin
(v) Find the descendants of the vertices u and w.
om my aa the only vertex distinguished from the others and is located at the top of the
(ii) Leaves are those vertices that have no children. Hence,
internal vertices are w, x and z. :
(ii) The levels of w and z are 1 and 2 respectively.
Idren of z are y’ and 2’.
(iv) The children of w are x and z. The chil
y’ and z’, The descendants of ware x, y, 22’ and y’.
e
(v) The descendants of w are v, W152)
the leaves are v, x, yf and 2’. The
ition 10.24
eted tree is an m-ary ifevery internal vertex has atmost m children. An many tree is a full m-ary
ifevery internal vertex has m-children.
ary tree if
ree Tis called a bin
an ordered rooted t
dren. If'a rooted tree
dren, one child or two chil
da trivial tree. Ifa tree has one child then that
vertex has two children
jrild or a ri “a child (but not both). a vere
fo ida i hil is designated =F Che
mt + | vertices:
wre, each internal vet
the tree has 7 = mi
—
rex of T has ™
al vertex has =
+L vertices:
tices. Therefo
‘ot is mf. Thus,
fm 10.19 A full m-ary tree with ¢ inter
"Let Tbe a full m-ary tree with t-internal ve
and the total number of vertex except the ro
Hence the theorem.
i
0476 Mathematical Foundation for Computer Science
Mi
Result 10.2 full mrary tree with
(n
| im
()_nvertices has 1 D internal vertices and | ' n-I)n+i
m leaves,
m
(iW) rinternal vertices has n= mt + 1 vertices, /= Gm e+ I leaves.
ml —1 del
(itl) J leaves has n (mi-1) vertices and ¢ (=!) internal vertices,
(m1) (m-1)
Theorem 10.20 There are at most m* leaves in an m-ary tree of height h
Proof Leth be the height of an m-ary tree. We shall prove the theorem by using induction om p
Basic
p: Leth= 1. Then, the tree consists of a root with no
‘more than m-children, each of which
is a leaf.
Hence, there are no more than m’ = m leaves in an m-ary tree of height 1
Induction hypothesis: We assume the result is true for all m-ary tree of heights less than h
Inductive step: We prove the result for height h, Let Tbe an m-ary tree of height h. The leaves of Tate the
leaves of subtrees of 7 obtained by deleting the edges from the root to each of the vertices af lee! 1
Each of these subtrees has height less than or equal to/h~ 1. Hence, by the induction hypothesis, exch of
these rooted trees has atmost m! ' leaves. Since there are atmost m such subtrees, there are atmost m ot?
‘= m" leaves. Thus, by the principle of mathematical induction, the result is true for atmout ny leaves
Hence the theorem.
[Baie 1028
Solution Let n be the number of vertices of
‘ery non-trivial tree T has atleast two vertices of degree 1, Prove this statement.
n= 2 and m be the number of vertices of degree |
Let uy, up, ...4 tq be the m-vertices of degree 1. Then cach of the remaining (n-m) vertices
++ My has atleast degree 2. Thus, deg(u,) = 1 for i= 1,2, ...m
2 2fori=m+i,m+2, n
Therefore, deg(»,) = Sec) + ¥ dex(n,)
emit
My 5 19 Mags 2
= m+ x deg(v,)
tome
2 m+2(n-m)=2n-m
Again, ¥deg(y,) = 26¢=2(n~ t= 2n-2
rr)
Hence, 2n = 22 2n—m
=> me2
‘This proves that 7 contains atleast two vertices of degree |.OY
IfTisa complete N-ary tree “ern "
Satie Rec With & internal Vertices then show th
s hat the numb
n
rer of
, ince Tis a complete nary tr avin,
jon Sine mary tree having & inten
having & internal ertices, the total number of
ut 7, er Of vertices is
vem by
X= nk+ | ay k= Sh
n
Again r is the number of leaves in the trees, Therefore,
X= ktrt loge
Eliminating k, we get
we can write
=x-(r+1)
x-(r+I)=
n
m—n(rt =x
m-nr-n=x+1=0
nx-1)-(@=-1)= ar
(2-1) (@@-1) = ar
(x=1)
A tree has two vertices of degree 2, one vertex of degree 3 and three vertices of
degree 4. How many vertices of degree | does it have?
Solution Let x be the number of vertices of degree 1. The total number of vertices = 2+ 1 +3 +x=
§+x. The number of edges = 6 +x-1=5S+x.
The total degree of the tree=2xX2+1X3+3x4+1Xx
H=4t3tlatxa19tex
x
» Thus, the number of edges = Be
wy Dex
Oy asx
31940
Srey +28
ence, thee are 9 vertices of degree | in the tree.
°
"4 Spanning Tree
P inning te is defined as follows.Definition 10.26 Spanning tree
A subgraph 7 ofa graph G is said to be a spanning tree if
G, that is, V(TD) = V(G).
478 Mathematical Foundation for Computer Science |
4
i
sa tree and if T includes every vertey op
Discuss a spanning tree with an example.
Solution Suppose seven unive in one city are involved in a joint research project funded bya
major corporation. The research centers at each university frequently send a large amount of data to
the other universities. To finish the project on time and to expedite the transmission of data ang
protect it, the 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
ct fiber-optics line between some of the universities. In fact, it is not neces.
. The engineers look at the areas surrounding
not possible to lay a din
sary to have a direct line between any two universiti
the universities to determine the possible lines that can be laid to connect the universities. A graphical
representation of the situation is given in Fig. 10.47.
“eM
6 i]
ws 2 b<]o
es Z- |" a
yy
6
Figure 10.47 | Graphical representation for Example 10.31
To lay the fiber-optics lines so that the universities can be connected, but not necessarily directly
connected, the engineers find a tree 7 that is a subgraph of G such that T contains all the vertices of G.
One possible solution is shown by the tree 7 in Fig. 10.48.
up
MN
uy
Ur
% a) Us
Figure 10.48 | Subgraph of G
Clearly, Tis a spanning tree of G. If we associate the cost factor of laying the fiber-optics lines, then
we find a spanning tree that has the minimum cost. sninniny (
jag A spanning Wee OF « graph Heed Hot be unig Graph Theory - 11 479
He.
10,32 | Find all ap i trees of ve A
Hraph given in Fig,
9,
tas
igure 10.49 | Graph for Example 10.32
tion The graph G has four vertices
and hence each spa
peach wee can be ob ee ach spanning tree must have 4 —
ero ofthe Wo cba d by deleting two of the five edges of G Tene ra te ous
ys lead to disconnected yraphs, there are eight possible spanning wees 35 =
rp 1080, ight possible spanning trees as shown in
ay
NZNO NN
Figure 10,50] Spanning tree of G
The 3
orem 10.21 A simple graph G has a spanning tree if and only if Gis connected.
a spanning tree T. Thi
\d v are also vertices of
also serves as a pall
en, T contains every vertex of G. Let
fTand Tisa tree. Therefore, there is
fh between u and v in G. Hence,
ref Suppose that a simple graph G ha:
an ewe vertices of G. Then w an
an between w and v. Since Tis a subgraph, P
; ‘onnected graph.
fhvercly, suppose that Gis @ connected grap
Veyele non cycles, then G is a true. If Gis nota tree,
OW co and e, be an edge in Cy.
RY Verte fuel the graph G, = G- {e1)s which
Rgetg gy 10m G. Clearly, G, isa subgraph of G
lee ga ty. & connected graph. If G, is acyclic, then Gy
i, thee cc? from C; and construct a connected subgraph G2
iMber often? is a tree. If G, contains cycle, then We continue
gcs, it contains only a finite number of cycles.
wh. To prove that G has a spanning tree.
then G must contain a simple circuit. Let Cy be
obtained by deleting e, from G but not removing
and it contains all vertices of G. Ase, is an edge of
is a tree. If G, contains a cycle C2» then we
that contains all the vertices. IfG, in
this process. Since G has a finite
2822480 Mathematical Foundation for Computer Science
Hence, continuing the process of deleting an edge from a cycle, we obtain a connected
that contains all the vertices of G and is also acyclic. subgraph G,
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, ey v3 ¢4 %4€, V2 € vis a cycle. By removing ¢, from th
cycle we obtain the graph G, = G— {e4}. This is a connected subgraph and it contains a the verion,
of G, as shown in Fig. 10.51.
°
e Sa] ¥
vr
‘ <=
| ;
“8 Vs
Figure 10.51] Subgraph G,
Now, in the graph Gy, v; € v5 €3 vs €g ¥4 €4 ¥2 €; ¥; isa cycle. By removing eg from this cycle, we
obtain a subgraph G, = G— (e,, e,} as shown in Fig, 10.52.
i * M4
ey e
Yr
4 e
& Mo
Ms eM
Figure 10.52] Subgraph G,
This subgraph G, is a connected subgraph and contains all the vertices of G. In Gy, »; €3¥3 5%)
¥% & Y2 €; Vy is acycle. ;
By removing the edge es from this cycle, we obtain a subgraph G, = G — {e,, eg, es) as shown in
Fig. 10.53.
Sibgrph
Now, G; is a subgraph of G and it does not contain any cycle. ;
Hence, G, is a spanning tree of G.Graph Theory <1 4g,
910.34] Find all spanning trees for the graph G piven in Fig. 10.54, by ren
54, SMOving the edyes
in simple circuits
% M% M
“4 “% G vy
Graph G for Example 10.34
lain This graph ae only one cycle V2 v5 vs ¥». Removal of any edge of the cycle gives a tree,
jus, there ae three trees which contains all the vertices of G and hence are spanning trees of G.
Vy Ys % Mw % Ys v5 %
wy Ye Ys “ Ya Ys
y vt Ys
(a) 7 (b) Tr () Ts
[Figure 10.55] Spanning tree of G
‘The trees T;, 7, and 7; shown in
ig. 10,55 are spanning trees of G. "
Agorithms for constructing spanning trees
Theorem 10,22 ‘This theorem states that “every connected graph has a spanning tree.” Moreover, the
poof of this theorem gives the steps for constructing a spanning tree. However, the process of finding a
‘le und eliminating an edge may not be efficient. instead of constructing a spanning trees by
‘snoving edges, spanning tree can be built by successively adding edges.
Two algorithms based on this principle for finding a spanning tree are breadth-first search algo-
hn (BFSA) and depth-first search algorithm (DFSA).
Mreadth-first search algorithm or BFS algorithm
!nthis algorithm, « rooted tree is constructed and the underlying undirected graph of this rooted tree forms
‘spanning tree, ‘The idea of BFS is to visit all vertices on a given level before going to the next level.
Hovedure
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
| in the spanning tree. Order them in an arbitrary manner.
Step (3): For each vertex at level 1, visited in order, add each 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
level 2 in the tree.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.
spanning tree of a graph G, given in Fig, 10.56, by using BFSA.
ve Ms
“ Mo
we
%,
Vy "
[ Figure 10.56| Graph for Example 10.35
Solution Step (1) : Choose the vertex ‘y," 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 {v4, vp}, {¥4, V5} are added. The two vertices v,
and ¥, are in level | in the tree.
Step (3) : Add edges from these vertices at level 1 to adjacent vertices which are not already in
the tree. Hence, the edge {v5, v4} is added. The vertex v, is in level 2.
Step (4) : Add edge from v, in level 2 to adjacent vertices not already in the tree. Hence, the
edge (v4, vs} and {v4, v7} are added. The vertices v5 and v, are in level 3.
Step (5) : Add edge from vs at level 3 to adjacent vertices not already in the tree. Hence,
{¥5. Vg} is added.
The steps of breadth-first procedure are shown in Fig. 10.57.
Ms
SR 8
Vs Vs Vs La
(a) (b) (ce) (@)
ve Ly
‘
(e)
Figure 10.57] BFSA for Example 10.35
Hence, Fig. 10.57(e) is the required spanning tree.Gray
first search algorithm or Drs Bh Theory
i ives the proced .
, algorithm gives the pi ure to successive lev; i
Bs isalso known as back tracking evels in a tree at the earliest Possible opporty
Step (2): ca cach ncanting at this Vertex by successively adding edges as long as possible
see e's incident with the last vertex in the path without Producing any
tices of the graph, then the tree consisting of this path
+ 80 to the next step,
in the path. If possible, form anew Path starting at this
2 ‘es 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
one 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.
[sample 10.36] Find a spanning tree of the graph, given in Fig, 10.56, using DFS A.
{Solution ‘The spanning tree of the graph given in Fig. 10.56 can be obtained by the following proce-
dure:
vertex passing through vertic
Step (1) : Choose the vertex v, to be a root.
Step (2) : Form a path by successively adding edges incident with vertices which are not al-
ready in the path as long as possible. This procedure produces the path (v4, V3. V4. Vs.
YoY). we oo 5
Step (3) : Now backtrack to vg. There is no path beginning at v, containing vertices not already
Sai serve that there is no path.
Step (4) : Similarly, on backtracking to v,, we observe that there is no path. /
Step (5) : Backtrack to v, and form the path (vs, v3). This produces the required spanning tree
which is shown in Fig, 10.58,
“ “5
vi Ye
%
Figure 10.58] Spanning tree obtained by DFS 2————
|
484 Mathernatical Foundation for Computer Science
Thearem 10.23 (Capley's Theorem) The complete graph K, has n* * different spanning trees
Consider n= 4 The complete gragh in this case would have 4°? = 4° = 16 different spanni
All the spacming trees of a K, graph (Fig. 10.39} are shown in Fig. 10.60. Panning trees,
Minimal spanning trees
Let Gbe a weighted graph. A minimal spanning tee of Gis defined as a spanning tree of G with minimum
weight. The weighted graph G (Fig. 10.61) shows six cities and the costs of laying railway links beewee®
certain pairs of cities. We want to set up railway links between the cities at minimum costs.yy
Staph Theory 1) agg
solution can be represented by a subgraph. This
a p " subgraph
all the vertices and it must be connected. Also, it must have aie maine tee
‘of vertices: Thus, what we require is a minimal spanning mee NM Sie path betwee
nce it
aa = Neach
rithms. for minimal spanning trees
methods are available for finding a minimal spanning tree in «
ay, Kruskal algorithm and Prim's algorithm of finding a minimal aoe ee ¥° Methods
i ight j ‘ , ning tree for ;
med graph with no weight is negative are explained below: v0 algorithres soe 4 connected
ght algorithms. These two algorithms are examples of
ruskal’s algorithm
this algorithm, we first select an edge of G which has the low
jch are not loops. Then, for each successive step select another
make any cycle with the previously selected edges. Continue th
selected and these edges form an acyclic subgraph T of G which
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) the edge of lowest weight
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
step (2). .
est weight among the edges in G
edge of smallest weight that does
is process until (1 ~ 1) edges have
isa minimal spanning tree of G.
Find the minimal spanning tree of the graph given in Fig. 10,62 by using Kruskal’s
algorithm.
| Figure 10.62] Graph for Example 10.37
aad We collect the edges with their weights into Table 10.1.
|
|486 Mathematical Foundation for Computer Sclonce
Tablo 10.1 Woights of edges
Edge (as Ma) | (Wa Yad | (5 Vad | War M5) | Var Ya) | (Was Vo)
Woight | 1 2 4
Edge . (ye Ma) | Wa Yad | (Wa Med | ae 2) | (Vas vg)
Weight | 7 8 9 10 1" 14
The minimal spanning trees are calculated as follows:
Step (1) : Choose the edge (vy) which has the minimal weight [Fig, 10.63(a),
“
Figure 10.63 (a)| Step |
Step (2) : Add the next edge (v4, v4) [(Fig. 10.63(b)]
yy
LZ Me
Figure 10.63 (b)| Step 2
Step (3) : Add the next edge (1, v2) [Fig. 10.63(c)]
yy va
Los
Figure 10.63 (6)| Step 3
Step (4) : Add the next edge (v, v,) [Fig. 10.63(d)]
vy Me
LN V5Graph Thoory <1 447
wep (EAM E AE (NIFH, 106340)
Figure 10.63 (@)| Step 5
10.63]
Figure 10.63 () Minimum spanning tree
Sece the graph G has 7 vertices, it is enough to choose only 6 edges. Therefore, we stop the
and the minimal spanning tree is shown in Fig. 10.63(1). ®
's algorithm
gorithm starts at a designated vertex and chooses an edge with minimum weight, Consider this
and associated vertices as part of the desired tree, Then an edge with minimum weight which has
yet been selected is searched in which one of its nodes is in the tree while the other node is not.
Process terminates when (1 — 1) edges have been selected from a graph of m nodes to form a
spanning tree.
The algorithm consists of the following steps:
Input : A connected weighted graph G
Output : A minimal spanning tree T
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. ®
Find the minimal spanning tree of the weighted graph given in Fig. 10.64 by using
Prim’s algorithm.
ol488° Mathematical Foundation for Computer Science
K
s as 4
~ Hy ;
oe
10.64) Graph for Example 10.38
afon The following steps need to be carried out to determine the ‘minimum spanning tree of the
given weighted graph
Step (1) : Choose the vertex ‘a". Now
» edge with minimum weight incident on ¢
(2, @, (a, €). Let us choose
ais (a, ©),
the edge (a, ¢) (Fig, 10.65(a))
e
Figure 10.65 (a)| Step |
Step (2) : Now, w(a, 5) = 4, w(a, d) = 3, wa,
edge with minimum weight. The edge
3, w(e, b) = 2 and w(e, ) = 3. Choose the
(c, 6) has a minimal weight (Fig. 10 65(b)]
Step (3) : Again, w(a, ©) = 3, w(b, d) = | and
w(c, d) = 3. Choose the edge (6, d), which has
the minimum weight [Fig. 10.65(c)]
a b
de
Y
Seep 3Graph Theo;
ry = I
step (4) # Choose the edge (d, c) (Fig. 10.65 (d). Hence, all the ve *
minimal spanning tree is shown in [Fig. 10.65 (d)] tices are covered, Thus, the
a
e b
Figure 10.65 (d)| Spanning tree
"
103.5 Decision Trees
jooted trees can be used to model problems in which a series of decision leads to a solution. A binary
arch tree can be used to locate items based on a series of comparisons, where each comparison tells
tswhether we have located the item or whether we should go right or left in a subtree.
Consider the following guessing game: “Amutha thinks of a number n < 1000; each time Beula
ives an incorrect response, Amutha says whether Beula’s guess is less than or more than m; by mak-
iag atmost 10 guesses, Beula can find the number n”.
Suppose Amutha chooses 1 = 687. We can apply the binary search algorithm to find n. Beula’s first
guess is || = 500.
Since 500 )
6] A decision treo
At each intemal vertex, we select one of the two alter
Definition 10.27
A rooted tree in which
for each possible oute:
thereby selecting a subtree,
each internal vertex corresponds to a decision, with a subtree at
these vertices
“ome of the decision, is called a decision iree.
Example 10.39] Sort three distinct clements a, b, and c.
Solution
Case (i) Let a a, then compare b and c,
If} b can be discussed similarly,
The following Fig. 10.67 gi
ry decision tree.
arb
cra Ler]
exb
{ajor tb)
AN
|
|
wa woe wa mo
locating a counterfeit coin.
9] A decision tree for
Figure 10.6492 Mathematical Foundation for Computer Science
Tree in Fig. 10.69 shows that two weighings will identify the false coin.
Hence, from the result, “Ian m-ary tree of height has / eaves, then > [logy], tft
me NE MALY trey
is full and balanced, then = [log,,/]”, the height of the decision is atleast [* ‘ =2
Hence, atleast two weighings are needed. 3
The complexity of sorting algorithms
Many different sorting algorithms have been developed. To decide whether a particular son
algorithm is efficient, its complexity is determined. Using decision tree as models, a lower bound n®
the worst-case complexity of sorting algorithm can be evaluated. an
We can use decision trees to model sorting algorithms and to determine an estimate for the worst.
case complexity of these algorithms, Given that there are n elements. Hence there are n! possible
orderings of th ‘lements, since each of the ! permutations of these elements can be correct order,
The sorting algorithm are based on binary comparisons, ie, the comparison of two elements ata time.
The result of each such comparison narrows down the set of possible orderings. Thus, a sorting algo.
rithm based on binary comparisons can be represented by a binary decision tree in which each intemal
vertex represents a comparison of two elements. Each leaf represents one of the n! permutations of n
elements.
Theorem 10.24 A sorting algorithm based on binary comparison requires atleast [log m!] compari-
sons,
Proof The complexity of a sort based on binary comparisons is measured in terms of number of such
comparisons used. The largest number of binary comparisons always needed to sort a list with m
elements gives the worst-case performance of the algorithm.
The most comparisons used equals the longest path length in the decision tree representing the
sorting procedure.
Inotherwords, the largest number of comparisons ever needed is equal to the height of the decision
tree. Since the height of a binary tree with m! leaves is atleast [log m!]_, atleast [log m!] comparisons
are needed.
Corollary 10.5 The number of comparisons used by a sorting algorithm to sort m elements based on
binary comparisons is Q (m log m).
Proof Weuse theorem (12.51) to provide a big-Omega estimate for the number of comparisons used
by a sorting algorithm based on binary comparison. Note that [log m!] is © (m log m), one of the
jis estimate 1S
commonly used reference functions for the computational complexity of algorithm. Thi ;
correct because [log m!] is (m log m). Also, [log m!] is 2 (m log m), since log m!> (nlcem) for
m> 4, Consequently [log m!] is © (mm log m).
Hence the Corollary.
Theorem 10.25 The average number of comparisons used by a sorting algorithm to sort m elements
based on binary comparisons is (m log m).Graph Theory 11 493
eo f The average number of comparisons used by a sorting algorithm based
Presthe average depth ofa leaf inthe decision tre representing the sorting a sorta” compa
already We have the result, the average depth of a leaf in a binary tree with W vertices (1
log N).
ystake =m! and also note that a function that is © (log m!) is also © (m log m), because
. log m!
(mon m)
Hence the theorem.
|_ —__—_————— EXERCISES ——__________
0.5 Which of the graphs given in Fig. 10.70 are (a) Find the parents of v, and vy.
trees? (b) Find the children of v, and v..
Pe (c) Find the descendents of v, and v,.
yoo OMS % vs (@) Find the leaves,
(c) Find the internal vertices.
10.8 Consider the rooted tree given in Fig. 10.66.
(a) Identify the path from the root u to each of
MOMs Me “ i the following vertices and find the level at
Ee vertex v5, ¥g and vs.
(@) ) nate tne
(b) Find the leaves of 7.
u
vy v2
M3
We
| ‘s \ vs
© % “Me
Ys
Tree for Problem 10.8
10.9 Find the spanning tree for each of the graphs
shown in Fig. 10.73 by removing edges.
Graphs for Problem 10.5
10.6 Find all trees with six vertices.
10.7 Consider the tree with root at v, as shown in
Fig. 10.71.
“ree for Problem 10.7494 Mathematical Foundation for Computer Science
10.12 Oban spanning tse forthe
/ Fig. 1.76 by ain ead nm
Using vortoxondoting vy,
®
Gy [Flewre 10:76] Graph tor Problem 1012
10.73] Graphs for Problem i 1013 se Pingtung
10:10 Draw all the spanning tees ofthe graph given hing ue forthe weighed pap gen ge
in Fig. 10.74, nna
; ; ”
Figure 10.78] Graphs for Problem 10.14
[Figure 10.74]
Graph for Problem 10.10
10.11 Obtain a spar
ning tee for the graphs shown in
10.75 bs
Y using a depth-first search ap-
proach,
9)
Wan vet een,
“ee Figure 10.77] Graphs for Problem 10.13
% % ¥
10.14 Use Kruskal’s algorithm to find a minimam
spanning tree for the weighted graphs
LD shown in Fig, 10.78,
%
©
Wt verte ordering
Vee te
ey
Graphs for Problem 10.11