Graph Theory
Graph Theory
4, STRAND ROAD,
P.O. CHANDANNAGAR
DISTRICT - HOOGHLY.
Contents :
7.5 Euler graphs –Euler path, Euler Circuit – Definition and examples.
1
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
7.1 Introduction
(Figure – 7.1.1)
Directed graph 5 vertices and 9 edges
Here the edge e1 associated with the ordered pair (v1,v4) but not (v4,v1). In the
diagram we use directional arrow from initial vertex v1 to the terminal vertex v4 to
show the ordering.
The edges e6 , e7 are parallel edges, because both are in the same direction. But
edges e2 and e3 are not parallel edges, because the directions are different.
2
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
(Figure – 7.1.2)
Graph with 5 vertices and 7 edges
Here the edge e7 is associated with a vertex pair (v4,v5). Also the other edges of the
graph associated with some specific pair of vertices.
Note - 1 : In drawing graph, it is immaterial whether the lines are drawn straight or
curved, long or short; what is important is the incidence between the edges and
vertices. Two graphs shown in [Figure – 7.1.3(a)] and [Figure – 7.1.3(b)] are same,
because incidence between edges and vertices is same in both the cases.
3
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Note - 2 : In a diagram of graph, sometimes two edges may seem to intersect at a point
that does not represent a vertex, for example, edges e and f in the graph
(figure–7.1.4) given below. Such edge should be thought of as being in different planes
and thus having no common point.
(Figure – 7.1.4)
Edges ‘e’ and ‘f’ have no common point.
Basic Terminology :
Self loop : An edge having the same vertex as both its end vertices is called a self loop.
In the above mentioned graph (Figure – 7.1.2), the edge e1 is a self loop with both
end vertices v2.
Parallel edges : When there are more than one edge associated with a given pair of
vertices, then the edges are called parallel edges. In the above mentioned graph
(Figure – 7.1.2), the edges e4 and e5 are parallel edges, because both the edges
associated with same pair of vertices (v1,v3).
Multi graph : A graph consisting of parallel edges but no self loop is called a multi
graph.
(Figure – 7.1.5)
Multi graph
4
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Pseudo graph : A graph consisting of parallel edges as well as self loops is called a
pseudo graph. It is also known as general graph.
(Figure – 7.1.6)
Pseudo graph
Simple graph : A graph that has neither self loop nor parallel edges is called a simple
graph.
(Figure – 7.1.7)
Simple graph
Finite and Infinite graph : A graph G=(V,E) is said to be finite graph if it has finite
number of vertices and finite number of edges. A graph which is not finite is called
infinite graph.
5
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
(Figure – 7.1.9)
Adjacent edges : Two non parallel edges are said to be adjacent, if they are incident
on a common vertex. For example, considering the above mentioned graph
(Figure– 7.1.9), edges e2 and e7 are adjacent.
Adjacent vertices : Two vertices are said to be adjacent, if they are end vertices of the
same edge. For example, in the above mentioned graph (Figure – 7.1.9), v4 and v5
are adjacent but v1 and v4 are not adjacent.
Degree of a vertex : The number of edges incident on a vertex vi , with self loop
counted twice, is called the degree, d(vi) of the vertex vi . The degree of a vertex is
also known as valence of a vertex.
6
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
(Figure – 7.1.10)
Digraph
Out-degree and In-degree of all the vertices of the above mentioned graph
(Figure – 7.1.10) is given below :
d+(v1) = 3 d-(v1) = 1
d+(v2) = 1 d-(v2) = 3
d+(v3) = 3 d-(v3) = 0
d+(v4) = 1 d-(v4) = 3
d+(v5) = 1 d-(v5) = 2
In any digraph G, the sum of all in-degrees is equal to the sum of all out-degrees, each
sum being equal to the number of edges in G.
n n
i.e Ʃd+(vi) = Ʃd-(vi)
i=1 I=1
7
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Odd and Even vertex : The vertex of odd degree is called odd vertex and the vertex of
even degree is called an even vertex.
(Figure – 7.1.11)
For example, considering the above mentioned graph (Figure – 7.1.11) , v1 , v3 are
even vertices and v2 , v4 are odd vertices.
Isolated vertex : A vertex with no incident edge is called an isolated vertex. The degree
of isolated vertex is zero.
For example, in the above mentioned graph (Figure – 7.1.11), v5 is an isolated vertex.
Pendant edge : The edge incident on to pendant vertex is known as pendant edge.
For example, in the above mentioned graph (Figure – 7.1.11), e4 is pendant edge.
Series : Two adjacent edges are said to be series if their common vertex is of degree
two.
For example, in the above mentioned graph (Figure – 7.1.11), edges e1 and e2 are
in series also edges e1 and e3 are in series.
Null graph : A graph without any edge, is called a null graph. All the vertices in a null
graph are isolated vertices.
(Figure – 7.1.12)
Null graph
8
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Regular graph : A graph in which all the vertices have same degree is called a regular
graph.
(Figure – 7.1.13)
A regular graph with three vertices, each of the vertices is of degree two.
Complete graph : A simple graph in which every pair of vertices are joined by edge is
called a complete graph.
(Figure – 7.1.14)
A complete graph.
G Ḡ
[Figure – 7.1.15 (a)] [Figure – 7.1.15 (b)]
The graph G is shown in Figure – 7.1.15 (a) and the complement of G i.e. Ḡ is shown in
Figure– 7.1.15 (b)
9
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Theorems on Graphs :
Proof : Let G be any graph with n number of vertices and e number of edges.
Let ek be an edge of G . If ek be a self loop at the vertex vi , then it contributes
2 to the degree of vi , i.e. to the sum of the degree of all vertices.
If ek is not a self loop, it is incident to , two distinct vertices, say vi and vj . Then it
contributes 1 to the degree of each of the vertices vi and vj i.e. ek contributes
2 to the sum of degrees of all vertices.
So we see that, an edge always contributes 2 to the sum of the degree of all vertices.
Therefore Sum of the degree of all vertices = 2 x number of edges
n
i.e. Ʃ d(vi) = 2e. (Proved)
I=1
Proof : If we consider the vertices with odd degrees and even degrees separately, the
sum of the degree of all vertices can be expressed as –
n
Ʃ d(vi) = Ʃ d(vj) + Ʃ d(vk) ---------(i)
I=1 even odd
We know that, the sum of degrees of all vertices is twice the number of edges.
n
i.e. Ʃ d(vi) = 2 x number of edges
I=1
So, the L.H.S. of equation (i) is even. Also Ʃ d(vj) is the sum of even numbers, so it
must be even
even
number.
Since, the L.H.S. of equation (i) is even and the first expression of R.H.S. of the same
equation is even, the second expression must be even.
Since, each d(vk) is odd, the total number of terms must be even to make the sum an
even number. Hence the theorem.
10
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Theorem – 3 : The maximum degree of any vertex in a simple graph with n vertices
is n – 1.
(Proved)
11
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
12
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
7.2 Sub-graphs
Observations :
13
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
The graph G’ is a spanning sub-graph of the graph G. Both the graphs G and
G’ have same vertex set i.e. V(G) = V(G’) = {v1,v2,v3,v4,v5}
14
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
15
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Induced sub-graphs : Let V be the vertex set of the graph G and V’ is a sub-
set of V. Then the sub-graph with the vertex set V’ together with all the edges of
G connecting the vertices in V’ is called the V’ – induced sub-graph of G.
16
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
7.3 Isomorphism
Note : It is observed by the definition of isomorphism that, two isomorphic graphs must
have –
(i) The same number of vertices.
(ii) The same number of edges.
(iii) An equal number of vertices with a given degree.
All the three conditions of isomorphism are satisfied by the graph G and G’. So they
are isomorphic
All the three conditions of isomorphism are satisfied by the graph G and G’. So they
are isomorphic
17
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
The two graphs shown in the Figure – 7.3.3(a) and Figure – 7.3.3(b) satisfies all three
conditions, but they are not isomorphic.
The two graphs shown in the Figure – 7.3.4(a) and Figure – 7.3.4(b) satisfies all three
conditions, but they are not isomorphic.
18
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
(Figure – 7.4.1)
Length of a walk : The number of edges present in a walk is the length of the walk.
For example, in the walk v3 d v4 e v2 f v5, of above mentioned graph (Figure – 7.4.1).
The length of the walk is 3.
Closed walk : If the starting and ending vertices of a walk are same vertices then the
walk is called a closed walk.
For example, the walk v2 b v3 d v4 e v2 of above mentioned graph (Figure – 7.4.1) is a
closed walk.
Open walk : If the starting and ending vertices of a walk are different then the walk is
called an open walk.
For example, the walk v3 d v4 e v2 f v5 of the above mentioned graph (figure – 7.4.1) is
an open walk.
19
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Path : An open walk in which no vertex appears more than once is called a path.
For example : v1 a v2 b v3 d v4 is a path of the above mentioned graph (Figure – 7.4.1)
Length of a path : The number of edges in a path is called the length of a path.
For example : Considering the path v1 a v2 b v3 d v4 of above mentioned graph
(Figure– 7.4.1), the length of path is 3.
(Figure – 7.4.2)
Connected graph
(Figure – 7.4.3)
Disconnected graph with 2 components
20
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Circuit : A closed walk in which no vertex, except the initial and the final vertex appears
more than once is called a circuit.
For example : v2 b v3 d v4 e v2 is a circuit drawn from the above mentioned graph
(Figure – 7.4.1)
Note : (i) A circuit is also called a cycle, elementary cycle, circular path, polygon.
(ii) Every vertex of a circuit is of degree two.
(iii) Every self loop is a circuit but not every circuit is self loop.
(Figure – 7.4.4)
Different circuits
21
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Euler Path : A path in a graph is said to be an Euler path if the path consists of all the
edges of the graph exactly once.
Euler graphs : If some closed walk in a graph contains all the edges of the graph, then
the walk is called an Euler line and the graph an Euler graph.
Note : (i) A walk is always connected. Since the Euler line contains all all the edges
of the graph, an Euler graph is always connected.
(ii) It is assumed that Euler graph do not have any isolated vertex.
(Figure – 7.5.1)
The above mentioned graphs (Figure – 7.5.1) are Euler Graphs.
22
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Hamiltonian graphs are named after Sir William Rowan Hamilton. He introduced the
problems of finding the circuit, which consists of all vertices of the graph exactly once.
Hamiltonian Path : A simple path of a connected graph which contains all vertices of
the graph exactly once is called a Hamiltonian path.
For example, the path v1 e1 v2 e3 v3 e4 v4 of the graph shown in Figure – 7.6.1(a)
is Hamiltonian path.
Note : (i) A Hamiltonian circuit in a graph with n vertices has exactly n number of
edges.
(ii) All the edges of the graph may not be included in the Hamiltonian circuit.
(iii) A Hamiltonian circuit contains exactly two edges incident on a vertex.
(iv) A Hamiltonian path is obtained by removing one edge from a Hamiltonian
circuit.
(v) A graph consisting of Hamiltonian circuit also contains a Hamiltonian path.
(vi) A graph without having any Hamiltonian circuit may have Hamiltonian path
23
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Solution : The given graph has 6 vertices and 8 edges. So the incidence matrix is of
order 6 x 8. The required incidence matrix is given below.
a b c d e f g h
v1 0 0 0 1 0 1 0 0
v2 0 0 0 0 1 1 1 1
v3 0 0 0 0 0 0 0 1
v4 1 1 1 0 1 0 0 0
v5 0 0 1 1 0 0 1 0
v6 1 1 0 0 0 0 0 0
24
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
e1 e2 e3 e4 e5 e6 e7
v1 1 0 1 0 0 1 0
v2 1 1 0 0 0 0 0
v3 0 1 1 1 1 0 0
v4 0 0 0 1 1 1 1
v5 0 0 0 0 0 0 1
25
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Solution : The given graph has 6 vertices and 8 edges. So the incidence matrix is of
order 6 x 8. The required incidence matrix is given below :
a b c d e f g h
v1 0 0 0 -1 0 1 0 0
v2 0 0 0 0 1 -1 1 -1
v3 0 0 0 0 0 0 0 1
v4 -1 -1 -1 0 -1 0 0 0
v5 0 0 1 1 0 0 -1 0
v6 1 1 0 0 0 0 0 0
e1 e2 e3 e4 e5 e6 e7
v1 1 0 1 0 0 0 -1
v2 -1 1 0 0 0 0 0
v3 0 -1 -1 1 0 0 0
v4 0 0 0 -1 1 -1 0
v5 0 0 0 0 -1 1 1
26
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
v1 v2 v3 v4 v5 v6
v1 0 1 0 0 1 1
v2 1 0 0 1 1 0
v3 0 0 0 1 0 0
v4 0 1 1 0 1 1
v5 1 1 0 1 0 0
v6 1 0 0 1 0 0
27
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
X= 1 0 0 1
0 0 1 1
0 1 1 1
1 1 1 0
Solution : If the v1, v2, v3, v4 be the vertices of the graph G, then the matrix can be –
v1 v2 v3 v4
X(G) = v1 1 0 0 1
v2 0 0 1 1
v3 0 1 1 1
v4 1 1 1 0
28
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
1 2 3 4 5
1 0 0 1 1 0
2 1 1 0 0 0
3 0 0 0 0 1
4 0 0 0 0 0
5 0 1 1 0 0
29
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
7.8 Algorithms
Shortest Path : The shortest path between a pair of vertices is the path of minimum
length among all paths between the pair of vertices.
Shortest path algorithm : There are several algorithms to find the shortest path
between two vertices in a connected weighted graph. Dijkstra’s algorithm and Floyd-
Warshall algorithms are the two important algorithms.
Dijkstra’s Algorithm : Dijkstra’s algorithms labels the vertices of the given graph. At
each stage in the algorithm some vertices have permanent labels and others temporary
labels. The algorithm begins by assigning a permanent label 0 to the starting vertex s
and a temporary label .∞ to the remaining n – 1 vertices.
From then on, in each iteration another vertex gets a permanent label, according to the
following rules.
1. Every vertex j that is not yet permanently labeled gets a new temporary label
whose value is given by
Min [ old label of j, (old label of I + dij) ]
Where i is the latest vertex permanently labeled, in the previous iteration and dij is
the direct distance between vertices I an j. If I and j are not joined by an edge,
then dij = .∞
2. The smallest value among all the temporary labels is found and this becomes the
permanent label of the corresponding vertex. In case of a tie, select any one of the
candidates for permanent labeling.
Steps 1 an 2 are repeated alternately until the destination vertex t gets a permanent
label.
30
E-CONTENTS : DISCRETE MATHEMATICS UNIT : GRAPH THEORY UNIT NO: 7
Floyd –Warshall Algorithm : Dijkstra’s algorithm is not suitable when our aim to find
the shortest distance between every pair of vertices in a connected weighted graph with
n vertices. There is another algorithm which determines the shortest distance between
every pair of vertices in a connected weighted graph. This algorithm is very popular
because of its simplicity. The algorithm is as follows.
Step 1 : If the graph contains any self loop discard it, If it contains parallel edges, then
discard all except that having the least weight.
Step 3 : For k = 1 to n
For I,j = 1 to n
Change d(I,j) by d(I,j) = min [d(I,j),d(I,k) + d(k,j)]
31