Professional Documents
Culture Documents
Graph 2
Graph 2
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
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
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
chro
nu
chromatic n hcr
um b e. of the
graph A,-V obtained
by deletion of avertex from
607
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 .
I fA,
1s
Number ofcycle(C,
a
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
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.
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
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
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 )
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
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. =
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 =
I
ict
s
viS
616 A TEXTBOOK
OF
DISCRETE
MATHEMA
For example, if G = K,. then
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,
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
(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
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
+ -DA-2),tC4 A(-1)a-2)(0a-3)
Pl)= qh+ 3! 4!
A(-1-2)A-3-4)
5!
choices.
C(4,3)= 24 ways and the fourth colour can
be assigned to v, or
v, which give two
(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
-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).
= ( - 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
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
edge e2 e4 es 6 V4
co 2 3 3 1 2
lour
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.
1 vertex
2 vertices
Fig. 16.1
(a) (b)
Fig. 16.2
A collection of trees is called a Forest.
Characterisations a st h e
detr
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
652
Cofam.in
653
ted ggraph,
raph
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 ..,
1
e(T.)= v (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
-
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.
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
---
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
-
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 =
1. 2, .
that eight spanning
deg () 1 for i
=
= m.
Thus T6.6.
2e 2(n-1) 2n-2
deg(v;) = = =
Again
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.
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
the
all move an edge that 1S in a simple circuit. Repeat this process until no simple
contains
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
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
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
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
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
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
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
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 .
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
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
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
eaanung
trewo f ' G
lic
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
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 .
it
must
of whose weights
whose is minimum i.e., a minimal spanning tree.
of
,
tne
m
sum
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
664
A
TEXTB0OK OF finds a minimal 665
DIsCRET
Kruskal's
kal's algorithm
spanning tree of the graph
h o w
mEES
non-decreasing
9
3.
of T. cdge of
trarily choose one of them).
select
This the first
an edge
edge
of minmum
weight from
minim
nimum.
8
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 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
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
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
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
-
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
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
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
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
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
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
Step 1: The tabulated form of the weights of its edges are given below
V4
4 2 3
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)
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
ofvertices,
n u m b e rd
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
vel k
=
at
evel
le
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
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
-
2 " - 1. But T
has n vertices.
Properties of Binary Trees ofheight h is 1 2
21 n
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