Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

15

APTER
Graph Theory II

G r a p h C o l o u r i n g

to certaln
assignment of colours to elements of a graph subject
IS an
other colouring
ornaphcolouring

aints tarting point of graph colouring 1s the vertex colouring. The


l h es t a r t i

colouring. An
h é Ilike
s edge
olouring and region colouring can be transformed into vertex or a
graph is just a vertex colouring of its line graph. The region colouring
o faa
g
of colouring of vertex of its planar dual graph. In this chapter we present
v Q u r n g

the problem of
co
0ncerning vertex
concerning
vertex colouring and edge colouring of graphs and their applications.
reSulls
sic
2 Vertex Colouring
ion of colours to the vertices of G, one colour to each vertex, so that the adjacent
The
simply G vertex
. ae a5signed different colours isvertex hasthe proper colouring of
called or

been assigned a colour according to a proper


cing of G. A graph in which every of G
n is called a properly coloured graph. The n-colouring of G is a proper colouring
UTIng is

FColours. colouring, then G is said to be n-colourable.


IfG has n

colours
Chromatic Number: The chromatic number of a graph G is the minimum number of
i.e. the minimum number of colours needed to assign colours to each
zdod for a proper colouring
EN of Gsuch that no
two adjacent vertices are of same colour. It is denoted by x (G). Thus a

K chromatic if y (G) =
K.
h TheGisgraph of Fig. 15.1 of n colouring for n = 2,3,4 are displayed, with positive integers in

nalcicles designating the colours. Here X (G)=2.

(a) (b) (c)


Fig. 15.1
In
graph colouring, we
we consider the colouring of simple connected graphs only. This is so
Se the colouring of vertices of one component of a disconnected graph has no effect on the
b the other considered for Parallel
En
two
vertices can be ireplaced by a loops
ponents. Self colouring.
are not
single edge without affecting the adjacency of vertices.
edges
(i) A
graph is graph
h consisting of only isolated vertices is 1-chromatic. The chromatic number
tnull
also .
consisting
Sn, wheren is the number of vertices of G.
Simple CLCdgraph
connected gra with one or more edges is at least 2 i.e.. x (G) 22.
605
606 ATEXTBOOK OF DISCRETE GRNEHEORY.
(iv) Chromatie number of a graph having a triangle is at least 3 cCRETE MATHEMA. - I

chro
nu
chromatic n hcr
um b e. of the
graph A,-V obtained
by deletion of avertex from
607

required to colour a triangle)


G. then at most d
(because throc cola Note:
:) 9
7he
The

from
deletcd
o a compliete graph then the graph
v,
remains to be complete So. K, -
() If deg (V) =
d for a vertex v in colours are I number of vertices. o
required Sor
-

Is
n V
ving
of the vertices adjacent to v. pEope Golaurtn verex
Braph
h a v

K, -V) =n-1
fa

npele
(vi) Every k-chromatic graph has at least k vertices, say v. V2 .

VSuch that subgraph


of
o fa graph G. Then: (G)2 n.
i= 1,2k. deg lo2 1

I fA,
1s
Number ofcycle(C,
a

(Vi) If H is a subgraph of G, then z (H) Sx (G) matic


2
ai
Chrom The chromatic
chro number
of a cycle: with n vertices
Theorem 15.1. Every tree with two or more vertices is 2-chromatic
atic. Theorem
1 5 . 4 .

(ii) 3 if n is odd (C,)Is


even

Proof: Choose any vertex v in the given tree T. Consider T ae 1 n


is

cycle
ycle C,has the vertices v, 2 has
V, appearing in order of
a rooted tree at vertex v and paint v with colour I. Paint all vertices 2
.
Let
the

v must coloured
becolo with different colour the cycle. If we
say with colour-2
is adjacent to v, buut not to v, So we can assign colour I because v, is
Proolt

adjacent tov using colour 2. Next, paint the vertices adjacent to these S g colour- to
V

vertices (that just have been coloured with 2) using colours 1. Continue elv assign
alternately assign colour
colour-2, colour-i, to the vertex

this colouring processtill every vertex in T has been painted.


f a c e n tt o

W a y
e we
c an
Can colour-2.. othe vertices v. Vg
ts
Thus, all vertices at odd distances from v have colour 2, while specnvely
n which is again adjacent to
even the las svertex v,
v, will be assigned colour-2. Thus
1.

T nis colours only but not less than 2. y 2


have colour 1. Hence y(C,) 2 ifn is even.
c o l o u r e

and vertices at even distances from v be can


=

C,
the last
ertex cannot be assigned any of colour-I
verte.
and colour-2 because this
even

Now along any path in 7, the vertices are of alternating colours. We knou s is odd
v , - (which
ifni ) I f ni s
is aassigned colour-2) and
is
only one path between any two vertices in a tree, s0 no two adjacent veticec there is one an jacent
verdexisa d
to
which
v, (which is assigned colour-1). So
assigned a new colour, say colour-3. Thus if n is odd then can be
colour. Thus T can be properly coloured using two colours. Hence x (7) = 2 ie. Tit he same v,
should

less than 3. Hence z{C,) =3 ifn is odd. C,


lastvertexcolours but
not

Note: The converse of the theorem is not true i.e. not every 2-chromatic i -chromasi, 3
C3. C
and C are shown below.
C is 2-chromatic but it is not a tree. The gpo graphs
of

(1) 2) 1)
Chromatic Number of a Bi-Partite Graph (Knd
Theorem 15.2. The chromatic number of a non-null graph is 2 if and
md only
only ifif tho
the graph _ 2)
bipartite.
Proof: Let G be a bipartite graph. So its vertex set V can be partitioned in twosets -
Vgy.)and V, = {,, r .,}such that every edge of G joins some v, to some u, Singe
of the vertices in V, are adjacent, we can assign a colour-1 to cach v, Since u, is adiacent h (3) (2) C4 (1) ) C (1)
to a (2 Fig. 15.2.
and since no two of u, s are adjacent we can assign colour-2 to each u, Thus the graph is colemnd
only with colour-I and colour-2, Hence z(G) =
2.
Note () If C, is a subgraph of a graph G then
Conversely, let G be a 2 chromatic graph ie. z(G) = 2. Let V, denote the set ofall erticsli
(a) x(G)2 2 if n even (b)x(G)2 3 ifn is odd.
which first colour is assigned and V be the set of all vertices for which second colour is asignei in the following example:
(i) The converse of the theorem 1s not true as shown
Thus V, and V, are disjoint and V= Vu Hence the two colour classes form a partitionof G (1) 2)
Otherwise at least two vertices in V, or V, have the same colour. Therefore, G is bipartite graph (2)
Note: The chromatic number of acomplete bipartite graph is 2 ie. zK,)=2. G G
Chromatic Number of a Complete Graph (K)
Theorem 15.3. The chromatic number of a complete graph with n vertices (K) is n.
(1) (1) (4)
(3)
Proof: Let vi, V2s V, are n vertices of a complete graph K, Let a colour C, beassig
.,

to v, and since
v, adjacent to v, a different colour C, is required to be assigned to
is , N Noneof G, and G, is cycle but 7(G) =2 and z(G)=3.
of the
dto if one
Since
v, 1S adjacent to both
v, and v,, so another colour C, (different from C, C) 1S eqi neorem 15.5. A graph G with a least one edee is 2-chormatic if and only
gned o
be assigned to vy, In this way the different colours C. C2 C, are required to be assga
olour as
following conditions is satisfied.
the vertices
V, Vz .V respectively because no two vertices can be assigned the same co (a) Gis atree.
every two vertices of K, are adjacent. Thus at least n colours are required for proper coou 6) Every cycle of G has even
K Hence the chromatic number of K, is n. length
(c) Gis bipartite graph.
a
608 A TEXTBC 609
OF
Vertex Colouring Algorithm CRETE MATHEH
DISCRE GRAPHTHEORY
nductivehypothesig.
I

G ) + 1.
nnose thatk> | is an
integer such that for any
any simple graph
simpit E
G,
There are a number of colouring algorithms which gives
Colours for proper colouring of graph and here we present the appro uihtvernCes, Let G
be a aple graph
with k + I vertices. of G
Welch-Powell algorithm following lgorithmthe mun
lo
Inducti g r a p h
G.
G
= G V. Ihe graph G, is obtained Consider
a vertex r
from G by deleting the

t
the
all the edges incident with v. Clearly, A(G,) AG). The grap
Input is a graph G. n da l s od e l e t i n g

k vertices. Thus by the inductive hypothesis


I. Order the vertices of G in decreasing degree (suo graph with
z(G,) S
by at mostAG1
Some vertices may have the same degree). ordering may not De
rerer v

s lsmmpA(G)+1.
a
his
This implies that ,
G) adjacent
adjacent vertices.
can be properly coloured
Because A(G) S AG) + 1, it follows that
A(G) + I
(G)
2. Assign colour to paint the first vertex and to paint, in unige 6 has at
most
are needed to colour these A(G) adiacent vertices. Thus from
one
the list that is not adjacent to a vertex previously painted with sequential order
order, each ven
s.
NO"+I
colours
unused colour is definitely available to colour vertex v. Hence
) + I colours one
t h e4 ( G )

3. Repeat 2 the process of painting previously non-coloured Vertio ur theseA(C)+,

4. Repeat 3 with a third colour, then


a fourth colour, and so on until G)E4()+1 the
in the above theorem becomes an cquality when G is a

5. Exit.
The algorithm only gives an upper bound for Z(G), i.e., the algorisk
verices are cose Note.
1he
i n e q

graph
u a l i

K,
t y

(ii) cycle Cn is odd


isn - I and
vertex
Z{8,)
complete

algorithm does not


=

0 degree ce of each n
the minimum number of colours which is needed to paint G. the
(K)= n =n -1 +1 =A(n)+ 1
InA,
Example 1. Consider the graph G in Fig. 15.3, use the Wetch o.
.. the degree of
each vertex is 2 and z(C,) 3 ifn is odd. =

G and find z(G). gorithm in


cycla
C,
C)= 3 =2+ 1=A(C)+1
Brook's
(Brook's
Theorem) If G is a connected graph other than a complete grapn
Theorem)
15.7.
x(G) s AG)
T h e o r e

then
3,
V3 2
heorem reduces the upper of z{0) by I for a particular class of graphs.
7VA
,

4(G)
ith
N o t e :

tthe chromatic
number of the graph G
Example
ale 2,
2. Find
Find

V6 V7

Fig. 15.3.
G
Solution. We list the vertices of G in decreasing degrees as shown
shown below,
below. We
We refer to
as a, b, c, etc. Assign colour a to the first vertex , in the list. The next and onlv chs
not adjacent to v, is v,. assign a colour a to v,. Now, we move to next uncoloured yeri
vertex in te
list and assign a colour b tov, The uncoloured vertex in the list not adjacent to v,is Caufion. The graph induced by Tour vertices a, b, c and d is a complete subgraph of G.
colour b to v,. Since all the remaining uncoloured vertices are adjacent to v,or v, moe XG) 2 4. ...(1)
c. Now assign a colour c to v The uncoloured vertex in the list not adjacent to v,is.tos colee
Since
deg (a) =
deg (b) 4; deg (0) deg («)-3; deg (e) =2
= =

colour e to , Hence v, is also not adjacet with v, but it is adjacent with v, Hence, ae 4
canalt A(G) =
maximum of the degrees of all vertices =

coloured with c. Assign colour d to only left out vertex V.


Brook's
Thus, all the vertices are painted. The completed assignment is listed below Again, G is a connected graph other than a
complete graph with A(G) =4>3, by
theorem
Vertex A(G) i.e. 11G) s4 (2)
Z(G) s

Degree 5 4 3 3 From (1) and (2) x(G) 4. =

Colour C b d Example 3. Find the chromatic nunmber of wheel graph W

Upper Bound of Chromatic Number Solution.


There is no efficient and convenient procedure to find out the chromatic number ofu 2
arbitrary graph G. However there are various results which give upper bounds for thechon
3:
Vs
number of an arbitrary graph if the degree of their vertices are known.
Theorem 15.6. For any graph G. G) s A(G) + 1. where A(G) is the maximum dtge
a vertex in G.
4 3
Proof: We prove this theorem by induction on n, where n is the number of verticies Since there is a triangle subgraph of u
1
Basic step: Letn= 1. Then Gis agraph
with only one vertex and
and AG) =0. This implies that z(G) S A(G)+ 1 for n =1.
Ghasnoedge. fene" (G) 2 3
CO

I
ict
s

viS
616 A TEXTBOOK
OF
DISCRETE
MATHEMA
For example, if G = K,. then

P0.) = ( - 1) (a - 2) ( - 3) and the chromatic number is a


mber is 4
when = 4. sincel
Theorem 15.14. The chromatic polynomial of a tree with n yverticon
is
)>6e
P,0) = ( - 1y-1

of.
Proof Let G be a tree with n vertices. We prove the
theorem by induction
nas one vertex which can be coloured in A distinct ways.

Then P )
=
. n=\.b
I fn 2, then G has one edge, so two colours are required for
for the nr. the
graph. Here c, = 0, c, = 2. Then P 0 ) = 0+ [A(A - 1)]2!]2 = a(n - 1). proper colouriy
We assume the result is true for all trees having lesser than n
vertices.
with n vertices. Since G is a tree it must have at least one pendant vertex. LetuNow
of G. Let G' =G- v. Then G is a tree with n -I vertices. The
The
be pendant vtAt
by inductive
M -1- hypothes
Now for each proper colouring of G' the given graph can be
coloured
the vertexv with the colour other than the vertex adjacent to the vertex v (one and b
properly
adjacent to v as v is a pendant vertex).
Thus v can be coloured with (A- 1) colours for each proper colouring ofG. Thist
of ways of colouring G is
P,(0) 0 - 1ya-1)=A( - 1-t
Example 9. For each graph, the constant term in its chromatic polynomial is ZeTO
Solution. Let the chromatic polynomial of a graph G of n be vertices be
P. (1) = a " + a," +a,-1Ata,

Since (G) 2 1 for any graph G.


P,() 0 for 0
= =

4x0 +ax0t t a x 0 + a, =0
a,=0.

Example 10. Ifa graph has at least one edge then the sum ofthe coeffecients in is chnona.
polynomial is 0.
Solution. Let G = (V, E),|E |2 1 be a graph and its chromatic polynomial be

Since G
P,a)= a,A" +a,"l++a,ta,
has at least one edge then at least two vertices of G are adjacent. do We a

properly colour G wth only one colour. Consequently, x(G) 22 P1)=0


or
a.1 +a 1t.ta 1t a, =0
or
at.ta-1t a, =0. be
chromal.
cannot
Example 11. Explain why each of the following polynomials
polynomial,

(a) n +572- 3 + 5
(b) +313-32 tem a
constant
Since the
Solution. (a) The polynomial cannot be a chromatic polynomial
5, not 0.
sum of the coefmc
(b) The polynomial cannot be a chromatic polynomial since the o
not 0.
eHTHEORY-1

chromatic polynomial ofa connected


the 617
fiample12.Detern
mine
graph with three
graph. say G has three vertices, so its chromatic vertices.
Smce
the given
polynomial is
onion.
P0) C C,*eC
edge, since it is conneo ted. So, only
lcast
one colour cannot
al
possibilities. prop
n a t e
are two
There
trian then c,
must

ices of G form a 0 and


=
vertic
c= 3! =
6. So, in this
une
l h r c e

case
m
7p o l y n o m i a l b e c o
onalie es
m
1:

M-1)2-MA- IA -2).
Cast
* m m n l C
p o l

=3140-1)D
= 3!'C; 3!
P4)
t h e three vertices does not make a triangle then it makes a path (i.e., a tree).
C a s2
e: 1 1

and c, =3!
Sa.c=2 chromatic polynomial is
case the
in this
,30-)a-2
herc 2C+31C
P,R)2°C =2. 2! 3!

13. Find
the chromatic polynomial of the following graph
ample
Examp
V

V4 2

graph consists of 5 vertices, the chromatic polynomial is denoted by


dhution. Since the

+ -DA-2),tC4 A(-1)a-2)(0a-3)
Pl)= qh+ 3! 4!

A(-1-2)A-3-4)
5!

subgraph, s0 7(C) 2 3 and hence e, =c, 0.


=

The graph G has triangles as

be coloured with 3 colours in


When we have three colours, the clique vertices {v, V2 Vz} can
Hence, c =
6
=6 different ways. be coloured in
fie Similarly, have 4 colours, then the clique vertices
when we v, V2, V,} can

choices.
C(4,3)= 24 ways and the fourth colour can
be assigned to v, or
v, which give two

Hencec, 24 x 2 48 andc; 5! 120


=
= =
=

PAJ--4-2,4gAA-)A-2)0-3) .120 0-)a-2)0%-3)0-4)


P0) 3! 4! 5!

MA-1)0.-2) [1 +2(-3)+(-3) -4)]


20.-1) (-2) (2- 5. +7).
(nl
621
I1
Y-
THEOR
b (= d)
P H

(b) (C
(a) Fig. 15.5
(b). Now
Splution. Deleling
dino t h e theedge e from G, we get G =G-e as shown in Fig. 15.5
v e r t i c e s .
Then the chromatic polynomial of G' is

ith 4 P(G, ) MA - )(0-2).


1s a
endpoints of e i.e., b and d, we get G" as shown in Fig. 15.5 (c). G"
merging the
hence chromatic polynomial of G" is
and
rpletegraphA P(G", ) = ( - 1).

the chromatic polynomial of G is


Now: b yd e c o
mDOsition theorem,
PG, A)= 2 -1P -0 -1)-2)
=
M- 1)I(A -1 (-2)J -

P (4) = 0 - 1) (22- 31+3)

-43 +612-3A.
X(G) =
2 since
P (1) =0 and P (2) + 0.
romatic polynomial of any cycle C, of length n is
Theorem
15.16 The
P,0)= (-1' +(-1"(a-1).
has vertices where 2 3. We prove the theorem by
cycle C of length n n n

Proof. The
uction.
Then, chromatic polynomial of C, ( = -

1) (a -2).
Ear=3, C becomes K.
statement
Also from
the given
P,0) (-1P (-1Pa-1)
= ( -1) (12-21+1 - 1)

= M - 1)n-2).

statement so true for n =


3.
The given
statement is true for some positive integer m 2 3.
us assume that
the given
Let
Then for any cycle of length m,
P) =
( - 1"+(-1y" (- 1)
Let us consider the cycle C of length (m + 1).
We delete an edge from the cycle C+ Since
deletion of an edge from a cycle does not alter
number of vertices in the cycle, the graph is a path,
which is a tree with (m + 1) vertices.
Therefore, its chromatic polynomial is ( - 1)"
Again contracting edge from C yields a cycle
an
of length m, which by inductive hypothesis
sa chromatic polynomial ( - 1y"+(-1y" (- 1). the chromatic polynomial for
By deletion-contraction property of chromatic polynomial,
= ( - 1 "- { ( - 1)" + (-1)" ( - 1)}

= ( - 1ym ( - 1)-(-1" ( - 1)
= ( - 1y*"l + ( - 1 ) * ( - 1)
VJ

A TEXTB0OK OF
622
Thus the given statement is true for n = m + 1 sCRETE MATHEM
DiSCRETE
Hence by principle of mathematical induction, the chromatic
Iength n is
P ) ( a - 1+(-1" (à - 1). polynomial of an
Chromatic Polynomial for certain graphs are:

| A( - 1) ( - 2)
Triangle K
Path graph P, A(7 -1y" -1
Complete graph R,
-

1) ( -

2).( -

(n -

1))
Tree with n vertices ( 1"-1

Cycle C, (a-1y" +(-1)" (a - 1)


Example 19. Find the chromatic polynomials of each of the six connectad
four vertices.

Solution. G Pa )
( -1) =4 - 313+312-a
= Ki,3 ( 1)3 =1* - 313 +32-
= Ca ( -1 +
(-1) (a- 1) =** -

43 +622-3
N ( - 1 -2) -*-4.3 2
A ( - 1) ( - 2) = 1* - 5% + 82-43

= KA - 1)( -2) (A- 3)= * - 6 1232-61.

15.4. Edge Colouring


An edge colouring of a graph G is an assignment of colours to N

the edges of G so that no two edges with a common vertex receive


the same colour. The minimum number of colours required in an edge
G: e1
colouring of G is called the chromatie index of G and is denoted by
(G). Fig. 15.23 shows a graph G for which x'(G) 3. =

edge e2 e4 es 6 V4
co 2 3 3 1 2
lour

If G has K-edge colouring, then G is said to be K edge colourable.

Lower Bound of '(G


To obtain a lower bound for '(G), we look for the largest vertex-degree A(G) m gner
which gives
x'(G) 2 A(G)
Upper Bound of ( G
To obtain an upper bound for '(G), we note that if G has m edges, then
(G) m
However, this upper bound has been improved by V. G. Vizing and C.E. Shan
16
CHAPTER

16.1 Introduction
Trees form one of the most widely used subclass of graphs. This is due
to the
ofhe applications of graph theory, directly or indirectly, involve trees, Tree fact
Tree occurs in tha
nierarchy.
where many elements are to be organized into some short of hierarchy, In
In
computer
siv
scienge s
are useful in organizing
and storing data in a database.

In this chapter we introduce the basic terminology of tree. We look


look atat subtr
rooted trees and binary trees and also many applications of trees.
subtrees of te

16.2. Trees and their Properties


A tree is a connected acyclic graph i.e. a connected graph having no cycle. Its edpe
are
branches. Fig. 16.1. are examples of trees with atmost five vertices. Fig. 16.2. (a)and(
trees, since they have cycles.
A tree with only one vertex is called a trivial tree otherwise T is a nontrivial tree

1 vertex
2 vertices

3 vertices 4 verties 5 vertices

Fig. 16.1

(a) (b)
Fig. 16.2
A collection of trees is called a Forest.
Characterisations a st h e
detr

r e e s have many equivalent characterisations, any of which could De s o eat

Such characterisation are useful because we need only verify that a grapu. imole and
simple
to prove that it is a tree, after which we can use all other properties. A

theorems on the general properties of trees are given below.

652
Cofam.in
653

between every pair of vertices in a tree, 7.


one
and only one path
re
is
exist a one path between every pair of
there must
I h e o r e m1 6 . 1 . T h e r

ted ggraph,
raph

vertices u and v of T but union of these


connected

a between two
Since
7Is
distinct paths
two

Let
t h e r
area

na cycleandithen
7 cannot be a tree.
.
cotain a
m

pair of vertices,
Wl
tits
between every
is one and only one path
wConverse!y
p a i s

G
G there
tho
in a graph
Theorem16.2 . If
then G is connected. A cycle
in
between every pair of vertices
exists aa pa path vertices u, v such that
that there is at least one pair of
exists
hore
there

Proof.
Since
more vertices) implies Since G has one and only one path between every pair
between u and v.
paths G is a tree.
two
distinct

cycles, erefore,
There
have no

es G can
vith n vertices has n-1 edges.
16.3. A
tree T of T.
prem
by induction on n, the number of vertices
theorem is proved
he Since it has no cycles, 7 cannot
Proo. When n
=
then T has only one vertex.

Basis ofInduction:
has e
1. =
0 =

ie. it
edge theorem is true for n =k22 where k is some positive integer.
kaneany Suppose the
step: Let T be a tree with k+1 vertices
and let
is true for n =k+ 1.
Inductive
the result
hic fo show that from Twe obtain the graph T- uv. Then
the graph
remove the dge uv
le use t
Then if we v, from
edgeof7. If there were a path, say u, V, V ..,

rbesconnected since !T- uUv contains no (u, V) path. U in 7.


back the edge uv there would be cycle u, v, V,., V,
a
added E
when we
can disconnect the graph
then
0 v
is
from a
disconnected. The removal of
an edge graph
Thus. T- nv
7, and T, Since there
were no
So T- uv has two components, say,
components.
itlo at most
two
are connected and are
without cycles. Thus, 7, and T,
with, both components
geles in T to begin This means that we can apply
the induction hypothesis
trees and each has fewer than n vertices.
ge

o7, and T, to give


e(T) = v ( T ) - 1 |

1
e(T.)= v (T)
-

of a single edge from T gives that


But the construction ofT, and 7, by removal
e (T) =e (T,)+e (T) + T

and that
v(7)= v (T) + v (T,)
it follows that
l-1 =k
1+1 v (T)- I =k+
e (1) (T) 1 v (T,) -
=
+ =
v
-

Thus T has k edges, as required.


induction the theorem is proved.
nence by the principle of mathematical with vertices and
a connected graph n

,Orem 16.4. For any positive integer n, if G is


-I edges, then Gis a tree. but arbitrarily chosen graph
is a particular
positive integer
n and
be suppose G
a
Let that a tree is a connected graph
hat i nnected and hasn vertices and n 1 edges. We know n - I We have to prove
c We have proved in previous theorem that a treeconnected. edges.
has
withoutYcles. G intok
then G is We decompose
convers
I S e that
if G has no cycles and n-1 edges, t nas no cycles since G has no

componer is connected ana


, Each component
G,... G,.
cycles. Hen )=7-kor e
=

n - k. Then
cach C, is a tree. Now, e, =n,- I and i=l

tree.
Hence, & Is a
follows that k=
k
uat I or G has only one component.
654 ATEXTBO0K OF
DISCRETE
Theorem 16.5 A graph is a tree if and only if it is minimally connectod
Proof. Let G be a graph with n vertices and we assume that G is a
HEMAtr.
tree with n
know that a tree with n number of vertices has (n- 1) num
amber of edges. If one verig
G, then it has (n-2) edges and G becomes disconnected. Hence G is a minim isde
Conversely, let G be a minimally connected graph with n number ofve Onece
of edges of G2 n - I as G is a connected graph. If possible, let G be not a trea vertices. Ihe naunbe
circuit and G becomes still connected if one edge of this circuit is removed from Then Gcomtac
our hypothesis that G is a minimally connected graph. Hence G is atree s contraie

The results of the preceding theorems can be summarised by saying that the fal
different but equivalent definitions of tree. A graph with n vertices is called atreei
1. G is connected and has no cycles (acyclic)
2. G is connected and has n-1 edges
3. Gis a acyclic and has n-1 edges
4. There is exactly one path between every pair of vertices in G
5. G is a minimally connected graph.
Rooted Trees
A rooted tree is a tree in which a particular vertex is distinguished from the others and,
the root. In contrast to natural trees, which have their roots at the bottom, in graph theoa iscle
trees are typically drawn with their roots at the top. First, we place the root at the top. Underb
and on the same level, we place the vertices that can be reached from the root on a simpe pah i
length 1. Under each of these vertices and on the sameleve,we place vertices that canbere
from the root on a simple path of length 2. We continue in this way until the entire tree is i
We givedefinitions of some terms related to it.
1. The level of a vertex is the number of edges along the unique patk1 between it and the n
The level of the root is defined as 0. The vertices immediately under the root are said to be ina
1 and so on.
2. The height of a rooted tree is the maximum level to any vertex of the tree. The depth e
a vertex v in a tree is the length of the path from the root to v.
vertices thaa
3. Given any internal vertex v of a rooted tree, the children of v are all hose
If w is a ch.ld of v, the visdk
adjacent to v and are one level further away from the root than v. are called sibling
the parent of w, and two vertices that are both children of the same paren1
4. If the vertex u has no children, then u is called a leaf (pendant or a terminal verts.

non-pendant vertex in a is called an internal vertex.


5. The descendants of the vertex u is the set consisting of all the children of utogen

the descents of those children. Given vertices v and w, if v lies on the unique path betwen
the root, then v is an ancestor of w and w is a descendant of v.
These terms are illustrated in Fig. 16.3.
Root Levelu

Level

d is a child of c Level 2
c is a parent of d C

d and e are sib lings


- L e v e l 3

- - - -

d
---
enclosed
region
ertices in
of 9
descendants

are

Fig. 16.3
655
the
rooted
tree in Fig. 16.4.
EES Consider

Emple
le
1.

g
Fig. 16.4

root
o f 7?
the
is
(a)
What
and the ternal vertices of T.
leaves
the
levels of c and e.
are
the lev
What
children of c and e.
the
h Find endants of the vertices
descend
a and c.
Find the
(e
Solution. (a) Verte a is distinguished as the only vertex located at the top of the tree. There

root.
a is the
(6) The leaves arethose vertices that have no children. These are b, f, g and h. The internal
and e.
esare c, d
c and are I and 2 respectively.
The levels of
e
il
of c are d and e and of e are g and h.
d The children
e The descendants of a are b, c, d, e, f g. h. The descendants of c are d e, fs, h.
Definition. A rooted tree is an m-ary if every internal vertex has at most m children. Am-ary
a full m-ary tree if every internal vertex has exactly m children. In particular, the 2-ary tree
ed binary tree.

he relationship between i, the number of internal vertices and l, the number of leaves of a
-ary tree can be proved by using the following theorem.
"heorem 16.6. A full m-ary tree with i internal vertex has n = mi +1 vertices.
"roof. Since the tree is a full m-ary, each internal vertex has m children and the number of
l vertex is i, the total number
of vertex except the root is mi.
herefore, the tree has n =mi + 1 vertices.
nce l 1S the number of leaves, we have n =1+ i.Using the two
i, the
following results equalities n =
mi +
| and
full m-ary tree
can easily be deduced.
with
Verices has i
=(n-1) /
internal vertices and
m
[(m - 1) n + I]/ m leaves =

i) i i
vertices n =mi + 1 vertices and = (m 1) i+ l leaves
has
il leaves hasn
-

(ml 1)/ (m 1) vertices and i ( 1)/ (m - 1) internal vertices.


-

eorem 16.7. There are


-

oof. We prove the atmost m" leaves in an m-ary tree of height h.


nsis atof theorem by mathematical induction.
his a
leaf On1, The tree consists of a root with no more than m children, each
e r e are no
huction Hypothesis: more than m =
m leaves in an m-ary of height l.
w e assume that the result is true for all m-ary trees of heights less

Auction Step: Let


Aned by T be an
m-a tree of height h. The leaves of T are the leaves of subtrees
d -ary
deleting the ges from the root to each of the vertices of level 1. Each of these
edge
656 A
TEXTB0OK OF
subtrees has height less than or equal h - 1. So by the inductive
SCRETE MATHEAMIAT
DISCRET all spanning trees of the graph G shown in Fig. 16.5
657

m
trees has at most m' leaves. Since there are al most m such caPothesjs
leaves. there are at most m.n" =
m".
yOothesis, each of
subtrees, caen
ranye Fmd.

wilh these
aximaymu "
This proves the theorem. a

Example 2. Every otrivial tree 1 has at least tiwo vertices of d. Fig. 16.5
Solution. Let n = the number of vertices ofT (n 2 2) and
nd m =t has four vertices and hence each
m the =

tumber of graph G spanning


deleting two of the five edge: of tree must have 4 1 =3
Let ,. ". denote the m of degree1. Then G.This can be done in
verlices
can be
cach
s o l u t i o n .T h e

of the remaintf ways ilead to disconnected


2. the
graphs. Thus there are
has at least degree
ning n- ofmdegs 10
of
m-1 p., two

1. 2, .
that eight spanning
deg () 1 for i
=
= m.
Thus T6.6.

2 2 for i = m*1, m 2 , n. venir n


in
Fig.

deg(,)= deg(,)+2 deg(y,) = m+2 deg(v)


I=m+I i=m+|
=|
2 m+2(7 m ) = 2n - n

2e 2(n-1) 2n-2
deg(v;) = = =

Again

21-2 2 211- m m2 2. Fig. 16.6


Hence
This proves that T contains at least two vertices of degree 1 A simple graph G has a spanning tree if and only if G is connected.
hat simple graph
Theorem 16.8.

G has a
Example 3. In a complete n-ary ree with i internal vertices, the numk suppose that a
spanning tree T. T
contains every vertex of
gven by p = (n - 1) ( r - )/n. of leaf Prool. First,

vertice
ec
of G. Since a and b are aiso verices of 7 and T is a tree, there is a path
vertex p and b be . Since Tis
T is ssubgraph, P also serves as path between a and b in G. Hence G is
Solution. Since the
Since
tree is complete n-ary navingI internal vertices, total. G
Leta.
a
and
0.

IS X = n.i+ 1 so that i = ( r - 1)/n.


of venies Phetveen

mnecied,
Conversely, suppos
that G is connected. If G is not a tree, it must contain a
simpleedge
circuit.
Again p is the number of leaves in the trees so X =i +p +1. one of these simple circuits. The resulting subgraph has one fewer but
from

Eliminating i from (1) and (2), we get an


edge
vertice
and is connected. If this subgraph is not a it has tree,
R e m o v e

the
all move an edge that 1S in a simple circuit. Repeat this process until no simple
contains

P= (n- 1) (r- 1/n.


remove.

sill before,
so cause there
only are a finite
number of edges in the
Example 4. A tree has two vertices of degree 2, one vertex of degree 3 and the. circut; This is
possible
graph, the
vhen no simple circuits remain Thus we eventually produce an acyclic subgraph
Cuit remain.
degree 4. How mamy vertices of degree I does it have?
ee
yerlices o process termil

The tree is a spanning1tree


since it contains every vertex of G
Solution. Let r
be the required number. Now, total number of vertices 2+ 1+3+rec.
is a tree. all spanning tree Ot the graph G shown in Fig. 16.7
Hence the number of edges is 6 +x- 1 =5 +x
Fxample 6. Find
[In a tree |
The total degree ofthe tree = 2 x 2+ 1 x3+ 3 x 4+1 x x = 19 +x E|=|V-1|
19+x
So, the number of edges is
2 2e- deg () C

Fig. 16.7
Now, 19+ 5+X
connected. It has 6 edges and 6 vertices and hence each spanning
Solution. The graph G is
So 6 -5 =
has to be deleted from G. The graph G has one
I edges
19 +x = 10 + 2r
treemust have 6-1 =5 edges. which contain all
of any edge of the cycle gives a tree. There are three trees
or 9 cyclec be c, removal
the vertices of G and hence spanning trees.
Thus, there are 9 vertices of degree one in the tree.
e

16.3. Spanning Tree


A subgraph T of a connected graph GV, E) is called a spanning tree if () Tis
a tean b
(i) T includes every vertex of G i.e. V(T) VVG). If | =n and m, then the |E spannngut
= = O a D

G must have n vertices and hence n-1 edges. We must remove m (n- 1) edges from to -

Fig. 16.8
a spanning tree. In
removing these edges one must ensure that the resulting graph remaincou Note that a spanning tree of a graph need not be unique.
and further there is no circuit in it.
(A-ntil
A
TEXTBCO0K OF
DIs
Example 6(). Find all the spanning trees
graph shown below anning ihe
trees on the
The
mnberotditeras
Terent
complete graph
s g i v e nb e l o u
without proof
K,can be found fSorm 659
ylay&heorem 6.9. The complete graph K has t'
all
t h
spanning trees of different spanning trees. Calay's
Give

there will be 4 16
ranple
&.

Here
n
=

= 4,
4 so
different spanning
Solution. The number
s h o w n b e l o O w

trees. All the


of vertices in the
graph,
=4, The n
4. The salution.

2
he spanning
number oft
r
number of edges to be detected to get the spanning trees =
Thus, there are eight spanning, trees and they are - n+\=5-4+\= edges, m. S m

Example 7. Find all spanning trees of the connected 4


graph

D E H

C
G
Solution. Since the vertex B contains 3
and G becomes
self-loop, we remove the selfla
3
F-loop from the 3

G': BH

3 . 3
4
C
The graph is connected and it has 9 for Constructing
Spanning Trees
edges and 8 vertices so rithms
deleted from the graph to get a spanning tree which is 9-( f constructing spanning
trees by
removing edges, spanning tree can
connected and does hedges has
The spanning trees of the graph G' are
given below: sutesivelyadding edges.
Two based on this algorithms
principle for finding a
be built
F (BFS)
Search and Depth-first Search (DFS) spannig tree are

BFS Algorithm
) B D E
H (ii) Be
DES is to visit all vertices on a
The ide given level betore going into the next level until
G sl are visited.
C
F
Procedure.

(ii) B Arbitrarily
Ard
choose a vertex and
designate it as the root. Then add all edges incident to this
(iv) B- that the addition of edges does not produce
E D iertex, such any cycle.
m The new vertices added at this stage become the vertices at level I in the
G
G arbitrarily order them.
spanning tree,
A Next, for each vertex at level 1, VISited in order, add each edge incident to this vertex to
(v B- H te tree as long as it does not produce any cycle.
(vi) B H
(i) Arbitrarily order the children of each vertex at level 1. This produces the vertices at level
G 2in the tree.

() Continue the same procedure until all the vertices in the tree have been added.

(vii) B (i) The procedure ends, since there are only a finite number of edges in the graph.
H (vii) B-
E (vi) Aspanning tree is produced since we have produced a tree without cycle comtaining eveny
C G
venex of the graph.
V

(A-na
660
ATEXTBOOK OF
Example 9. Use BFS algorithm
Solution. () Choose the vertex a to be the root.
to find a
spanning trec of
graph
DISCRETE MI
G of yitt o rDIS,
a n d
B E S
discard all paral edges and self 661
loops from the gven cConnected
(i) Add edges incident with all vertices adjacent to
Fig, tg a f o
DIs

G is a directed graph then


ia graph
connectedg
a, we
so that edges fa. b}. {a, c} are added. The two vertices b
and onstruct the
c are in level I in the tree. a
spa.
tree of the graph of Fig. 16.11
using Depth-first search
corresponding
(ii) Add edges from these vertices at level I to adjacent
Fnda

vertices not already in the tree. Hence the edge {c,


d} is ranyle
1 0

algorithm.
added. The vertex d is in level 2. (why {b, d} is not
joined ?2) a
(iv) Add edge from d in level 2 to adjacent vertices
not
not .
Fig. 16.9
d. e and {d. g} are added. Hence e and g are in level 3. already in
the
()Add edge from e at level 5 to
adjacent vertices tree. Th.
is added.
not already in .

he tree
he Fig. 16.11
and hen Form a path by successive
adding
produces the path edges incident with vertice
The steps of Breath fast
C h o o s et h e v e r t e x

procedure are shown in Fig. 16.10 nossible. This pro


possible.

e.j as
solution.
Cho

b as long ertices
a-c-d-e-f-g.
he path nath
There isno path beginning atj containing vertices not
tof
d and form already visited.
ralrenay
back
track
at e,
there is no path. So move backtrack at
a a
traes
track
N o w

ack
b a c k

tree whic is shown in the path d-


a aner
ired
C e st h e r e q u i r e d
spanning
Fig. 16.12. b.
e
DSpodces
sinlanty

(a) (b) (c)

Fig. 16.12
S is to visit all vertice
The
basic
idea ofE
sequentially on given level before it
a

(e) Note:
goes
tien e x tl e v e l .

to higher levels at the first


Fig. 16.10
TheDFS
proceeds
successive
opportunity
Hence Fig.16.10. (e) is the required spanning tree. arndamental Circuits

DFS Algorithm tree


na tree of aa
of graph G. I hen the edges of G that
a spanning
are in T are called
Let Tbe not in T is called chord of G with respect branches
An alternative to Breath-first search is Depth-first search which proceeds to dGTheedgeof G
that is a
to T. A cireuit formed by
spanning tree T of a
tracking successive levag
in tree at the earliest grapn is called a Fundamental circuit of G with respect
a
possible opportunity. DFS is also called back
sdlinga
o i
chord e to a
relative to chord e. The cut set containing exactly branch
Procedure. spanning
T
tree Tr one
of Tis called fun-
o
of G to w :t.T.
(i) Arbitrarily choose a vertex from the vertices of the graph and mental cutset

(i) Form a path star ting at this vertex by successIvely adding


designate it asas ihothe roou
designate nsider the
Consia
spanning tree Tof the graph G as shown below:
edges as long as possible wke 1
each new edge is incident with the last vertex in the
path without producing any cycle. Whese
(i) If the path goes through all vertices of the graph, the tree
spanning tree.
consisting of this path i,
T:
Otherwise, move back to the next to last vertex the
in path, and, if possible, form a new not
starting at this vertex passing through vertices that were not already visited.
(i) If this cannot be done, move back another vertex in the 2
the path. and repeat.
path, that is two vertices back in e

The branches of G are e,, e, and e,


(V) Repeat this
procedure, beginning at the last vertex visited, moving back up the path oce The chords of G are e, and
ertex at a time. e
forming new paths that are as long as possible until no more edges can be adikt 5

(V7) This process ends since the


the chord e, is added to the spanning tree, then one circuit v,-,--Y, lOmeu
dAMOWn as fundamental circuit. If the chord e, is added, the cireut v. -"-,-1,b
then
graph has a finite number of edges and is conneated.
Spanning tree is produced. anoher fundamental circuit.
662 A
A n t

TEXTB00K OF DisC
EATHESM
Notes 663
1. mental circuit is defined with of eedges and
nber of the number
respect to a e
ktn 2 k, k
spanning tree. umbero
o f
vertices,
then rank and nullity is
=
for
2. Fundamental circuit with respect to a spanning tree in a grank ts ofa
graph
G
defined as connected graph)
is Rankr=N - k
mot unique.
N e

3. A given cireuit may be fundamental circuit with


respect nbe
spanning tree in the same graph. me +k

spanmmng tree bu ,
1
with respect to other
-

=e of n
ac
vertices and
and e
edges, the number
Nullity
of
4. If G is a connected simple graph with n vertices and e edoe
graph

of the graph
an
equal to the edges be removed
number of chords
to
,
any
a

with respect to any spanning tree 7, so it has r fundamental it has


to
with
l o r

nullity
r general, respect to a
e-{ nt of nullityy i.e., the number of understroyed edges is called rank which givany
c a l l e d

is

5. For every branch here is corresponding cutset since


ning trec breaks the spanning tree into two trees.
removal c
N
wh respee uT n

eaanung
trewo f ' G
lic

Thecomplecment with to aany spanning tree.


gives
Example 11. Find fundamental circui for the graphs shown below
branch Îrom G
branches
of'G
respect

a
s
ol
Via G in1 which each edge e has be
igned a non-negative
cyanter
HeightedGraph

is graph
F Fig. 16.13 shows a
ph a
hted ht (Or enh G is defined to be the weighted graph. The weight (or number
Sum of the
weights of the ede length)
weighted

to finding, in a suitable edges in the


amount

st.Manyoptimisation blems
such
a
weighted graph, a certain type
t ap a t h
m
1
minimum ( o r m a x i naximum) weight.

Wsuberaph
tiaimal
Spanning Trees

Solution: We first use BFS algorithm to find the spanning tree. First .
weightd graph. The weight
w e i g h t d

of
is the sum of
a
spanning tree of G
lel edges. Deleting one parallel edge (v,, v,) we get the graph G, e all connected
the
loops and. a
minimal spanning
of G is a spanning tree of G with
tree
minimum weight. The
N
puara Let
Gbe
e d g e s .

5.13. shows six cities and the costs of


laying railway links between
n irailway links between the cities at minimum costs. The centain
the
of Fig.
nejghts G of
graplh to set up
want solution can
ghted We This subgraph must be a spanning tree since it covers all
a i so fc l i e s .

subgraph. the vertices


G d by
a the road system), it must be connected (so that any city can be reached from
epresented
ch Cyve unique simple path between each pair of tices. Thus what is needed is a
(80that
have

it
must

of whose weights
whose is minimum i.e., a minimal spanning tree.
of
,

tne
m
sum

() Choose the vertex v, to be the root.


tree

spanning
imal Spanning Trees
orithm for Minim
(i) Add edge incident with all vertices to , so that edge (v, v,) is added several methods availa for actually finding a minimal spanning tree in a given
(ii) Add edges from this vertex v, to adjacent vertices not already in the troe and Prim of finding a minimal spanning tree for a connected
to Kruskal
zorithmsdue
and (v. v,) are added. Hence here
no weight
is negative are below. These algorithms are example of
presented
(iv) Add edges from v, and v, to adjacent vertices not already in tree. Hence ehiedgrap
g r e d ya l g o r i t h m s . greedy algorithm is a procedure that makes an optimal choice at each of is
A
.

and (vv) are added and we get a spanning tree. (v. previous
choices.
regard to
dens without 4
The steps of BFS procedure are shown on the next page.

A
V

V4 7 6
N
2
Fig. 16.13

have ll and Kruskal's Algorithm graph G which


is a
After converting the given graph in simple graph, we e =
n =7. Sotherea This algorithm provides an acyclic subgraph
T of a connected weighted
r11 7 +1 = 5 fundamental circuits and these are v, - V, - ", - ", relative to edge(x, t
involves the following steps:
vV,--v, relative to edge (v, v,). v,-V, -V,- v,-v, relative to edge (v, ").V--Y-
minimal spanning tree of G. The algorithm
A connected weighted graph G.
reletive to edge (", V) and v - V - V,-V,-', - V, Telative to edge ( , V).
Input:
Output: A minimal spanning tree 1.
( A n t

664
A
TEXTB0OK OF finds a minimal 665
DIsCRET
Kruskal's
kal's algorithm
spanning tree of the graph
h o w

Step 1. List all the cdges (which do not form a loop) of G of


MIToHrdEeSASsf
r n p l e1 ,S h o S h o w

mEES
non-decreasing
9
3.

weights of minimum weight (If more than onc


Step 2. Sclect an edge
on

of T. cdge of
trarily choose one of them).
select
This the first
an edge
edge
of minmum
weight from
minim
nimum.
8

Step 3. At cach stage.


docs not 1orim a circuit with the
all the remainingedges of G il l 7

edges
selected in 7. Include the edge in T.
previously I cdges have been
Step 4. Repeat step 3 until
n- selected.
when n is the number of vertices
in G.
11
0
illustrate these steps.
The following examples
Example 12. Show how Kruskal's algorithm find a minimal
14
Fig. 16.14. 9
spanning tree for the graph of
e Fig. 16.155
Solution:
Step 1: List the edges in non-decreasing order of their weights, as ig. 1614
Edge b. c)(c, e)(c, (a, b)(e, d)(a Sulution:
edges
in non-decreasing
nor
order of their
weights, as in Table 16.2
| 2 3 3 4 L i s t the
|Weight
Table 16.1
b,e) Step:
. d)| (e. g)(6.e)(d. g)|(d. e) (d. c)(a. d) (a. b)|d.«..8
(6,

Step 2: Select the edge (b, c) since it has the


smallest weight, include it in E d g e :
(a
c)| 2 3 45 6 7 89 10 1112
b T. Table 16.2
Weight

Step 3. Select an edge with the next smallest weight (c, e) since
ce it doe
it does he
the edge (a. c)
since it has the smallest weight, include it i
the existing edges in T, so include it in T. not fom Select

b
cirun Step
2:

Step 4. Select an edge with the next smallest weight (c, d)} edge With the next smaliest weight (b, d) since it does not form cycle with
since it does not
Step 3. it in T.
the existing edges in T, so include it in T. fom edges
in 7, so
s o include
existing
b d the

an edge witn the next smaiest weight (e. g) since it does not form cycle with
e CHon 4, Select
in 7, so include it in T.
Step 5. Select an edge with the next smallest weight (a, b) since it does not edges
not faform the existing D
the existing edges in T, so include it in T. creuit w

b
since it does form cyele with
Step 5. Select an edge with the next smallest weight (b, e) not

in T, include it in T.
the existing edges so

Since G contains 5 vertices and have chosen 4 9


mal
we
edges, we stop the algorithm and the mi
spanning tree is produced.
(A-nt)
666
A TEXTBOOK OF

the
Step 6. Select
existing edges
an

in T.
edge with the next smallest
include it in T.
weight (d, c) sinoo
since
DiSCRETE MATHE. w

yithj
the next smallest weight (v, v,) Since it
does not form
667
so
does not a n
c d g e

t in 7.
T includei t
cycle with
fom y.
Select V6 V2

Step 7. Select an edge with the next smallest with the


next smallest weight (v,, v,) since it does not
weight (d. A sinco an
e d e

it in T
form cycle with
the existing edges in T, so include it in 7.
does clude
i n c l u d e

Secct

not T.
so
V6 2
\orm Step4.
in

cyde
4
Vs

wit
the next smallest weight (", ") Since it does not form
Siep
5
elect an edg
Sele
include it in 7 eycle with
so
in T,
7,.

ves
eUges
in
V6 V2
Since G contains 7 vertices and we have chosen 6
en/stng

edges, the process uthe

mal spanning tree is


produced. terminants and the
Example 14. Using Kruskal's algorithm find a spanning tree with s
graph below. Also calculate the total weight of minimun
spanning tree. smallest weight (v, V) since
V tOmt elect an edge
h the next
i twith it does not cycle with the
2 Step6. include
itiin T
so
9 ,
12 2Nisting
edges
in

Vs 2 10 V3
1
11
20
6
3
15 4 8 Vs 7
VA
vertices and we have chosen 5 edges, we stop the algorithm and tho mini-
ntains 6
Solution. Since of the spanning tree is 3 + 8+7+5 10=3.
no Iree is produced.
The weight
malSpa
Step 1. List the edges in non-decreasing order of their weight as in Table 16.3
Prim's Algorithm
chooses an edge with minimum wejght
Edge starting at a designated vertex
Initialy the algorithm as part of the desired tree. Then iterate, looking for
and associated vertices
ansiders this edge
Weight 789 10 1112 odoe with minimum weight
not yet selected that has one of its vertices
in the tree while the other
vertices
terminates when n I edges have been selected from a graph of n
-

Table 16.3 verex is not.


The process
tree. The algorithm involves the following steps.
form a minimal spanning
to
Step 2. Select the edge (v, v) since it has the smallest weight 3, include it in T connected weighted graph
G.
Input: A
V6 tree T.
Output: A minimal spanning two vertices except the
and all parallel edges between
1. Remove all self loops (if exist) with the selected
Step all the edges incident
Select any vertex in G. Among
one with minimum weight.
minimum weight. Include it
in T.
vertex, choose an edge of a vertex already
included
of smallest weight joining
Step 2. At each stage, choose an edge in T. Inchude t in
the edges
form a circuit with
it does not
n
anda vertex not yet included, if included.
until all the vertices of G
are
Step 3. Repeat
the minimal aning tree the following 689
668 ATEXTBOOK OF DISCD steps are followed.
eREENT
lind

the startingvertex. The


edge with smalest
t o

ondr
Example 15 (). Find the mnumal spannng tree of the weiphr tex r,as

yin
h

cOse t h
v

e
e

ca
and include it in I(spanning tree) weinghn incident
Prim's algorithm. choose
the

We

ve

8.wVv) 5, WV, 2,and wly, v=8.


it 7T
in We choose the ods
inimumandinc include

V3
:
Fig. 16.16
Solution. 1. We choose tne veriex v, Now edge with smallest
so we choose the edge for (v, V) w(y, V,)=3, w(v, 8, w (v,
minimum aand include in T.v)=5,
)= 8, w(,"J=4 and
1 ) = F g

r { l ,

Since it in minimum
Agh0se (v,
A g a l n
V)
. 1)=12
suep
eéc
3. V

2. Now w( .)=4, w{v,v,)=3, (V, V) =5, w{V, v)= 2 and wi.


"

the edge (v, V.) Since it is minimum.


S.e
ligible edges, " (v, v) =8, w{r, v)= 12, v{y, r}=4 we choose
elligible

NOW
ámong

and inç
include it in T.
4. m i n i m u m
m i n i m u

Step

since
itis
t
is

3. Again w (, v) =3, w (v, v)=I and w (p, ")=3. We choose the ad

4 V3
vertex v, IS yetincluded Now
not (y, v) =8, mr, v)= 12 ,v)=1
4. Now we choose the edge (v, v). Now al the vertices are convered. The n: the
Only
it is minimum and include in T.
Step5, it
tree is produced. sinceit
choose (, )
We 2
N 1
5

2
3
V2

tree is Obtained and the total weight of the tree is


The minimal spanning
The weight of the minimal spanning tre is 2+2+3+4+7= 18

3+2+1+2=8
in Tabular Form
Prim's AIgorithm between two vertices encept
Example 16 (a). Describe Prim's algorithm and use this to find out the minimge
Step 1: Remove all self-loops (if exist) and all parallel edges
vertices by v, V.,. . Tabulate given
the weights of the
of the following graph. minimum weight. Label the
the one with wilh respect to the diagonal
and the diagonal
2 Vs 8 xn table. This table is symmetrie
edges of Gin ann
to v, set the weight of edge
the (r. v) as
If there is no edge connecting v,
is empty. it to the vertev which
has smallest
ie. first row and conect
Step 2: Start from the vertexv, formed.
Then a tree r, r, is
cntry in Ist row of the table, say, y,
2 5
670 ( n t

671
A
TEXTBOOK OF DISCR V,-ro and v-row,
i.e., Ist, 2nd and Srd
in
Step 3:
Ist row and kth
Connect the tree v,, v, to the vertex
v, (* V,» V,) that has
RETE MAT >mnaliest
entr
try
in
vrOw,

to v,
or v,)
corresponds
which to v, v,
or
rowS is 3
(we
except v, v, which aredo
row. Thus smallest ens ponds
sortices, say, v,. Thus tne
two veruces, the tree
a tree
v,. v. v, is formea. ty amonL Tesp ofthese v,. , V, V, is
fomed
Step 4: Continue this process of selection of vertices until
co
d n .T a k e
anyone
4

(n
sp

tree with n 1) edoe.


edges
-

vertices has n- 1 edges). These edges form a


Example 16
minimal spanning t are lç
selinectG.ed (
(6). Find by Prim's algorithm a minimal spanning tree fromn
nabeo

the
3 V2

3 4

-rOw, v,-row, ",-row and v,-rOw, i.e., Ist, 2nd, 3rd and 4th row
entry in v,
2 y whi
5 :T h e
smallest
vg, v, which are already taken). Ihus the tree
v, v, V, v, v, is
3 2shichcoTesponds
to
to v,
(exCept

S I e p e S p o n d s

below

snOWn V

Solution: The given graph is a connected weighted graph having 5 s as

spanning tree has 4 edges. tices. So a irned

Step 1: The tabulated form of the weights of its edges are given below

V4
4 2 3

V33 2 3 o this is the required minimal spanning tree. The weight of


A(=5-1)
(=5
edges,
V4 3 00
3 2 has 4 10.
+2
Since
this
tree
ree is 2 +3 +3
Vs3 3 2 t h i sm i n i m a ls p a n n i n g

and Kruskal's Algorithm


D i f t e r e n c eb e t w e e n P r i m ' s

The smallest entry in


v,-row, i.e., the Ist row of the t incident to a vertex, al-
Step 2: Start form the vertex v, edges of minimum weight
edge
that are

Take one of these three vertioe every step


any rithm at
3, which corresponds to the
vertex v, or v, or V5. tices, say v, Inpri iforming
a cycle, are chosen.

formed shown below: not

v, is
as and incident to
the tree v iin
Rady
the
tree

edges of
of minimum weight that are not necessarily a

V algorithm,
Kruskal's
forming a cycleis choser
But in tree
andnot
the
I e n e x
alreadyin
16.4. Binary Tree Each child in a
atmost two children.
each vertex has
which vertex has at
rooted tree
in
both), and an intemal
is right child (not
tree
a
A hinary child or a
internal vertex has
exactly
either a left which each
in
N3 Ainary tree
is designated A full binary
is a tree
child.
right
left and
one
most ane whose root
Ist and 3rd rows is 2 which corespont to of v is the binary
tree
and v,-row, i.e.,
3: Smallest entry in v,-row
Wo children. subtree
Step tree T, the left descendants,
and whose
shown below: vertex v
of a binary and all its
is formed as internal child of v
The right
V. Then the tree v,, v,, v, Given an
consist of the left left subtree
together.
vertices of the
vertices
whose
of v, the
left child connect
s the of T that
of all those
edges
consist intem
dges analogously. cach oft
is

since
füll binarytree
defined
subtree of v is
and Fig. 16.17
(b) is a
tree
is a binary
ig.16.17 (a)

vertices has two children.


AL

672 ATEXTB0OK OF DISCRE 673


RETE MATHEA Ihurem1610, In
any
D i n a r y
tree on n vertices, the number of
endent vertices 1s
equal
endant vertices in a binary
16.10.

tree on
e u m b e r o fp e n
numbe
n
vertices bek. The
ofde
degree I and the
remaining (n -

k - 1)
There is exactly
v e r t i c e s

vertices of de
degree 3,
ne
k
L e r

Prw
=2
x no of edges.
ertices

=2(n - 1)
of'v

- f -dePCes * j +kx l
) t 2 2x1
3-2k-| =2n-2
d e ! r

o f

Siun

internal vertices in a
binary tree is one less
than
o r - ( t1 Y 2

The
The
number
n u

the num
16.17
K
Theorem
enulant
verices ains x + y vertices, where x number of =

(a)
tree

internal vertices in the binary tree.


pendant vertices.
i.e.,
b i n a r y

Fig. 16.17 (b) of non-pendant


L e t
n e
ees
Therefore. the total
Prool

A tree in which there


is exactly one vertex of degree two and
and each of aunter
r=

ofvertices,
n u m b e rd

+ 2 So, X =(r*y+ 1)/2 =>y=x- 1.


called a binary tree. The vertex of huo is
degree two the other r =(
degree one or three is v
right childre of b shown in called root of t
Br
propert.
the left and
Example 17. What are
Fig. T h i s
s h o w st h a t

internal vertices= Number of pendant vertices 1.


and right subtrees of a?
16.18! What Number o f i
ve that
that the maximum number of vertices on level n of a binary
are the 1 0 . 1 2
P r o v e

Theorem

r o e is on
tree i level 0 and there can only one vertex at this level.
The
fa binary
he
root

on level
1 is 2, on level 2 is 4 =2 and so on. We prove the
theorem
P r o o .1 h e
vertices
mavimunnunmber «
cal i n d u c t i o n .

man
athematical hen n 0 , the only vertex is the root. Thus the maximum number of
Whe
induction:

20= 1,
Basis of =
0 is
level
n
assume that
that the
t theorem is ttrue for level k, where n2k20. So,
on : We
f
ertices
uction
hypothesis

vertices on level k is 2
k of
number vertex in binary tree has maximum degree 2, then the maximum
Fig. 16.18 T h em a x .
Since
each
Step: vel k + I is twice the maximum number of level k. Hence, the maximum
Juction
Solution. The left child of b is d and the right child is e. The left subtre m u m b e ro f v e r t i c e s

= 1 is 2.2* 2 . Hence, the theorem is proved.


=

vel k
=

at
evel
le

number of vertices in a binary tree of height h is


onsists
consists of verti
vertices

subtree
sists of the vertices b, d,
e and j and the right of a of the vertices c, nber
of Prove
that the maxim

Il6.19 (a) and (6) respectively.


g, h, iai Theorem
16.13

whose figures are shown in Fig.


-1,h20 that the
maximum number of vertices on level n of a binary tree is 2". So,
known

Proof.
It is
vertices in a binary of height h is
uhe m a x i m u m
number of
number

2h+-1
I+2 + 2 + .
+2 = -

vertices is log, (n + 1)
height of a binary tree
on n
minimum
that the
Theorem
16.14. Show
K
is
heightis
(a) (b) maximum
possible
the binary tree
-

I and maximum number of vertices in


Fig. 16.19 vertices. The
tree of n
binary
Proof. Let Tbe
a

2 " - 1. But T
has n vertices.
Properties of Binary Trees ofheight h is 1 2
21 n

Theorem 16.9 The number of vertices in a binary tree isalways odd.


h 2 log(n + 1)-1 binary tree is m
vertex of degre:
n-vertex

Proof Consider a binary tree on n vertices. This tree possess exactly one i.e.
minimum possible height of an
hence the equalto
three. Thus there are n-I vertices of odd degrees. Sine te integer, than or
and other vertices of degree one or But h is an
smallest integer greater
two it follows than n-1 is even and hen 1| where l nl
denotes the

nunaber of vertices of odd degree in a graph is always even,


=log.(n+ 1)-
nis odd.

You might also like