GRAPH
THEORY- I & II
NOTES
DISCRETE MATHEMATICS,
DATA STRUCTURES,
DESIGN AND ANALYSIS OF ALGORITHMS
Graph Theory
Graph:
A graph G=(V, E,ϕ) consists of a non-empty set V called
the set of vertices(nodes, points) of the graph, E is said to be
the set of edges of the graph and ϕ is a mapping from the set of
edges E to a set of ordered or unordered pairs of elements of V.
Example: e1 For the beside Graph G=(V,E, ϕ)
V2 V={V1,V2,V3,V4}
V1
e4 e5 e2 E={e1,e2,e3,e4,e5}
Φ is defined by
V4 V3
e3 Φ(e1)={v1,v2}
Φ(e2)={v2,v3}
Fig: Graph G Φ(e3)={v3,v4}
Φ(e4)={v4,v1}
Φ(e5)={v1,v3}
Graphs-
•A graph is a collection of vertices connected to each other through a set of edges.
•The study of graphs is known as Graph Theory
Formal Definition
Formally,
A graph is defined as an ordered pair of a set of vertices and a set of edges.
G = (V, E)
Here, V is the set of vertices and E is the set of edges connecting the vertices.
Example-
In this graph,
V={A,B,C,D,E}
E = { AB , AC , BD , CD , DE }
.
Adjacent nodes:
The pair of nodes that are connected by an edge are called
adjacent nodes.
Example:
in the above fig, edge e1 is connected by two vertices v1 and
v2, hence v1 and v2 are called adjacent nodes or vertices.
edge e2 is connected by two vertices v2 and v3, hence v2
and v3 are called adjacent nodes or vertices.
edge e3 is connected by two vertices v3 and v4, hence v3
and v4 are called adjacent nodes or vertices etc...
e1
V1 V2
e4 e5 e2 Fig: Graph G
V4 V3
e3
Incident:
Consider the graph G, in which an edge e that connects the
nodes u and v is said to be incident on each of the nodes.
Example:
Consider the below graph G.
edge e1 incident on v1 and v2.
edge e2 incident on v2 and v3.
edge e3 incident on v3 and v4.
edge e4 incident on v1 and v4.
edge e5 incident on v1 and v3.
e1
V1 V2
e4 e5 e2 Fig: Graph G
V4 V3
e3
Isolated node or vertex:
A node of a graph which is not adjacent to any other node is
called an isolated node.
Example: Consider the below graph G , Vertex V3 is called an
Isolated node or vertex because it is not adjacent to any other
node in the graph. V1 V2
V3
Fig: Graph G
V5 V4
Isolated Graph:
A graph containing only isolated vertices or nodes(no edges) is
called a Isolated graph or null graph.
Example: V1 V2
Fig: Isolated or null
V3 V4 Graph G
Directed edge and Undirected edge:
Consider the graph G=(V,E), an edge which is associated with
an order pair of vertices is called a directed edge of graph G,
while an edge which is associated with an unordered pair of
vertices is called an undirected edge.
Directed graph and Undirected graph:
A graph in which every edge is directed is called directed
graph or digraph.
A graph in which every edge is not directed is called an
undirected graph
Example: a. Directed Graph b. Undirected Graph
V1 V1
V2 V3 V2 V3
Mixed Graph:
In a graph G, some edges are directed and some edges are
undirected, then that graph is called a Mixed Graph.
Example:
V4 V1
Fig: Graph G
V3 V2
from the above graph G, V1-V2 ,v4-v1 are directed edges and
V1-V3,v3-v4 and V3-V2 are undirected edges, hence it is a Mixed
graph.
Loop:
An edge of a graph which joins a vertex to itself is called a loop.
e1 e2
Example: V1 V2 e2 is a loop from
the beside graph G
Fig: Graph G
Parallel Edges:
In a graph, if some pair of vertices are joined by more than one
edge, then such edges are called “parallel edges”.
Example:
V1
e4 e5 Fig: Graph G
e3 e1 V3
V2
e2
From the above graph G, e4 and e3 are parallel edges and e1 and e5 are
also parallel edges.
Multigraph: A graph which contains some parallel edges and loops is
called Multigraph. V1
Fig: Multi
V2 V3 Graph G
Simple Graph:
Any graph without containing any parallel edges and loops is
known as Simple graph.
e1 e1 e5
V1 V2 V1 V2
e3 e2 e4 e3
V3 V3 e2
The graph G1Fiigs:aGrsaimphpGle1graph becauseFiitgd: GoersapnhoGt c2ontain any loops
and parallel edges.
The graph G2 is a Multigraph because at vertex v2, e5 is a loop and
e3 and e2 edges are parallel edges.
Finite and Infinite Graph:
A graph is said to be finite graph if its vertex set and edge set
are finite(countable), otherwise it is an infinite graph.
Trivial Graph:
A finite graph with one vertex and no edges i.e., a single vertex is
called the trivial Graph.
Example:
V1
Fig: Graph G
Consider the above graph G, it contains only one vertex and no
edges. Hence, the graph G is called a trivial graph.
Isolated Vertex:
In any graph, a vertex which is not adjacent to any other vertex
is called an Isolated Vertex.
Null graph:
A graph with only isolated vertices is called a null graph. In
other words, the set of edges in a null graph is empty.
Weighted Graph:
A graph in which weights are assigned to every edge is
called a weighted graph.
Example: 3
V1
V2
6
12 V3 Fig: Graph G
V5 5
8 V4
Here 3,6,5,8 and 12 are the weights assigned to each edge
respectively in the above graph.
Order and Size of a Graph:
If the graph G is finite, |V| denotes the number of vertices of G,
known as order of G.
| E | denotes the number of edges of G, known as Size of G.
Example: Consider the following graph G
V1 V2
V6
V3 Fig: Graph G
V5 V4
|V| denotes the number of vertices of G=Order of G=6
| E | denotes the number of edges of G=Size of G=8
Incidence:
Let G(V,E) be a graph e E, e={u,v}, then e is said to be
incident with vertices u and v. The vertices u and v are said to be
incident with e.
Note: Two vertices u and v are said to be adjacent, if the two vertices
are joined by an edge e, where e E such that e={ u, v}
Degree of a vertex: (Undirected graph)
The number of edges incident on a vertex is called the
Degree of a vertex. Let v be a vertex in a Undirected graph G, then
the degree of a vertex v is denoted by deg(v).
While calculating the degree of a vertex, loop is counted
twice.
Example: Consider the below graph , find out the degree of each
vertex.
V1 V3
V2
V5 V4 V6
The degree of a vertex means number of edges incident
on that vertex. Each loop is counted twice. By observing the
above undirected graph, the degree of each vertex is
deg(v1)=6
deg(v2)=3
deg(v3)=5
deg(v4)=4
deg(v5)=6
deg(v6)=0
Degree of a vertex: (Directed graph)
In the case of directed graph, degree of a vertex is the sum
of indegree and outdegree of that vertex.
total deg(v) =indeg(v)+outdeg(v)
where indeg(v) means indegree of a vertex v
outdeg(v) means outdegree of a vertex v
The number of edges incident into a vertex v is called the
indegree of a vertex.
The number of edges incident out of a vertex v is called the
outdegree of a vertex.
The sum of the outdegree and indegree of a vertex v is called its
total degree.
Example: Consider the following directed graph, find out the
indegree, outdegree and total degree of every vertex
V3
V1
V2
V5 V4 V6
This table shows the indegree, outdegree and Total
degree of every vertex in the given graph
Degree of a Indegree Outdegree Total
vertex Degree=Indegree
2 4
V1 2 1 + Outdegree
V2 3 2
V3 2 2 6
V4 3 3 3
V5 0 0 5
V6 4
6
0
Handshaking Theorem (or ) Handshaking Property:
Let G =(V, E) be an undirected graph with | E | edges and | V | vertices then ∑ deg(vi)= 2*| E | i.e.,
Sum of the degrees of all vertices in a given graph is equal to twice the number of edges.
Example-1: Find the number of vertices, number of edges and the degree of each vertex in the following
undirected graph . Verify the handshaking theorem.
Sol: for the above graph, deg(E)=E4 deg(F)=1
The number of vertices=6
The number of edges=9
deg(A)=2 deg(B)=4 deg(C)=4Bdeg(D)=3
AC D F
According to the Handshaking theorem, Sum of the
degrees of all vertices in a given graph is equal to twice the
number of edges.
∑ deg(vi)= 2*| E |
∑ deg(vi)= deg(A)+deg(B)+ deg(C)+ deg(D)+ deg(E)+deg(F)
=2+4+4+3+4+1
=18
2*| E | = 2*9
=18
∑ deg(vi)= 2*| E |
18=18
Hence, the given graph satisfies the Handshaking theorem
Example-2: Find the number of vertices, number of edges and the
degree of each vertex in the following undirected graph . Verify
the handshaking theorem.
AD
BC
Sol: for the above graph,
The number of vertices=4
The number of edges=7
deg(A)=2 deg(B)=5 deg(C)=3 deg(D)=4
According to the Handshaking theorem, Sum of the
degrees of all vertices in a given graph is equal to twice the
number of edges.
∑ deg(vi)= 2*| E |
∑ deg(vi)= deg(A)+deg(B)+ deg(C)+ deg(D)
=2+5+3+4
=14
2*| E | = 2*7
=14
∑ deg(vi)= 2*| E |
14=14
Hence, the given graph satisfies the Handshaking theorem
Theorem: in every graph, the number of vertices of odd degrees is
even.
Pendant vertex:
A vertex of degree one is called a pendant vertex or end vertex.
An edge incident on a pendant vertex is called a pendant edge.
Isolated vertex:
A vertex of degree zero is called a isolated vertex.
Example:
e1
V1 V2 V7
e2
VIn6 the abovVe3graph, the vVe4rtices v4 andV5v6 are pendant vertices.
The vertices v5 and v7 are isolated vertices.
NOTE: Two adjacent edges are said to be in series if their common
vertex is of degree two.
From the above graph, the edges e1 and e2 are in series, since
deg(v1)=2.
NOTE: if G is a simple graph with n vertices then 0≤ deg(V)≤ n-1
V1 V2 V1 V2
V4 V3
V4 V3
From the above graph-1, it contains 4 vertices, deg(v1)=3,
deg(v2)=2, deg(v3)=3 and deg(v4)=2, hence we can say that each
vertex has the degree between 0 and 3.
From the above graph-2, it contains 4 vertices, deg(v1)=3,
deg(v2)=3, deg(v3)=3 and deg(v4)=3, hence we can say that each
vertex has the degree between 0 and 3.
NOTE: The minimum of all the degrees of the vertices of a graph
G is denoted by δ(G) and the maximum of all the degrees of the
vertices of G is denoted by ∆(G).
NOTE: For a simple graph G with |V|=n, we have
0≤ δ(G)≤ deg(V)≤ ∆(G)≤ n-1
V1 V2
V4 V3
For the above graph, deg(v1)=3, deg(v2)=4, deg(v3)=2, deg(v4)=3
Therefore δ(G) =2 and ∆(G)=4
2 ≤ deg(V)≤ 4
Complete Graph:
A simple graph, in which there is exactly one edge between
each pair of distinct vertices is called a complete graph.
A complete graph with n vertices is denoted by Kn
The following figures show the complete graphs from K1
through K6.
V1 V1 V2 V1
KK11 KK22 V2 V3
A Complete A Complete
Graph with Graph with KK33
2 vertices A Complete
1 vertex Graph with
3 vertices
V1 V2 V1 V2 V3
V1 V4
V4 V3 V5 V2
V6 V5
K4 V4 V3
A Complete KK55 KK66
Graph with A Complete
4 vertices A Complete Graph with
Graph with 6 vertices
5 vertices
NOTE: The total number of edges in a complete graph with n
vertices Kn is nC2 or n*(n-1)/2
NOTE: The total number of edges in a simple graph with n
vertices is n*(n-1)/2
Regular Graph:
Regular Graph is a simple graph , in which every vertex has the
same degree. If every vertex in a regular graph has degree K,
then that graph is called K-regular graph.
Example: a. 2-Regular Graph b. 3-Regular Graph
V1
V1
V2 V3 V2 V6
V3 V5
V4
Bipartite Graph:
A bipartite graph is an undirected graph whose set of vertices
can be partitioned into two sets M and N in such a way that
each edge joins a vertex in M to a vertex N and no edge joins
either two vertices in M or two vertices in N.
Example: G=(V,E) is an undirected graph, in which V is the set of
vertices V={v1,v2,v3,v4,v5,v6}.
The set of vertices in V can be partitioned into two sets
M and N i.e., V=M ∪ N
M={ v1,v3,v5}
N={v2,v4,v6}
These two sets satisfy the condition M ∩ N=ϕ
M V1 V3 V5
K3,3
A Bipartite
Graph
N V2 V4 V6
Complete Bipartite Graph:
A complete bipartite graph is a bipartite graph in which every
vertex of M is connected to every other vertex of N.
if M contains m vertices and N contains n vertices, then the
complete bipartite graph is denoted by Km,n
Example: Construct K2,3 and K3,3 complete bipartite graph
V1 V2 A1 A2 A3
V3 V4 V5 B1 B2 B3
K2,3 K3,3
A Complete A Complete
Bipartite Graph Bipartite Graph
Subgraphs:
A graph H=(V’,E’) is called a subgraph of G=(V,E), if V’ ⊆ V
and E’ ⊆ E.
if H is a subgraph of G, we write it as H ⊆ G.
if V’ ⊂ V and E’ ⊂ E, then H is called a proper subgraph of G.
Spanning Subgraph:
A subgraph H=(V’,E’) of G=(V,E) is called a spanning
subgraph of G if and only if V’ = V
Induced subgraph:
A subgraph H=(V’,E’) of G=(V,E), where V’ ⊆ V and E’
consists of only those edges that are incident on the elements of
V’, is called an Induced subgraph of G.
NOTE:
The Graph G and the null graph are subgraph of G
Example-1: e1
V1 e7 e8 V3 e7 V2
e3 V1
V2 e2 e5 e4
e2 e5 e4
V4 V5 V4 V5
e6
Fig: A Subgraph of G
Fig: Graph G
V1 V2 V3 e7 V2
V1
V4 V5 e2 e5 e4
V5
Fig: A Spanning V4
Subgraph of G e6
Fig: A induced Subgraph of G
Induced by {v1,v2.v4.v5}
Example-2: Show the different subgraphs of a given graph G
A A C
BC B
DE E
Fig: Graph G A Subgraph of G
A A
BC BC
DE E
A Spanning Subgraph of G An induced Subgraph of G
Representation of Graphs:
Graphs can represented in the following ways.
1. Adjacency Matrix Representation
2. Incidence Matrix Representation
3. Path Matrix Representation.
A matrix is a convenient and useful way of representing a graph.
1. Adjacency Matrix Representation: (Undirected Graph)
Let G=(V,E) be a simple graph with n vertices ordered
from v1 to vn, then the matrix AG=[aij] is called the adjacency
matrix of the graph G. The elements of AG=[aij] is defined by
the following rule.
aij = 1 when vi is adjacent to vj
0 otherwise
Example: for the following graph, The adjacency matrix is
AB v1 v2
DC v3 v4
Fig: Graph G Fig: Graph G1
A B CD v1 v2 v3 v4
A01 11 v1 0 1 1 1
B10 10 v2 1 0 1 0
C11 01 v3 1 1 0 0
D10 10 v4 1 0 0 0
Adjacency Matrix of Graph G Adjacency Matrix of Graph G1
Properties of Adjacency Matrix:
1. An adjacency matrix completely defines a simple graph, hence
it does not contain any loops, each diagonal entry of A=[aij]=0,
for i=1,2,......,n.
2. The adjacency matrix of simple graph is symmetric i.e., aij=aji,
since both of these entries are 1 when vi and vj are adjacent and
both are 0 when vi and vj are not adjacent .
3. Deg(vi) is equal to the number of 1’s in the ith row or ith column
of AG.
AB A B CD
DC A02 02
B20 11
C01 12
D21 20
Fig: Graph G with loops and Adjacency Matrix of Graph G
parallel edges
Adjacency Matrix Representation: (Directed Graph)
Let G=(V,E) be a simple graph with n vertices ordered
from v1 to vn, then the matrix AG=[aij] is called the adjacency
matrix of the graph G. The elements of AG=[aij] is defined by
the following rule.
aij = 1 If (vi, vj )E
0 otherwise
Properties of Adjacency Matrix: (Directed Graph)
1. The adjacency matrix for a directed graph may or may not be a
symmetric matrix, since there may not be an edge from vj to vi
when there is an edge from vi to vj
2. The number of elements in the ith row whose value is 1 is equal
to the out degree of the vertex vi.
Example: for the following directed graphs, The adjacency
matrices of directed graphs are
AB v1 v2
DC v3 v4
Fig: Graph G Fig: Graph G1
A B CD v1 v2 v3 v4
A01 10 v1 0 1 1 0
B00 10 v2 0 1 1 0
C00 01 v3 0 0 0 1
D10 00 v4 1 1 0 0
Adjacency Matrix of Graph G Adjacency Matrix of Graph G1
2. Incidence Matrix Representation:(Undirected Graph)
Let G=(V,E) be a simple graph with n vertices ordered
from v1 to vn and edges from e1 to em then the matrix IG=[mij]
is called the incidence matrix of the graph G. The elements of
IG=[mij] is defined by the following rule.
mij = 1 when vi is incident with ej
0 otherwise
Example: Write down the incidence matrix for the graph.
A e3 B e6
e4 C
e1 e2 e5
D E
Fig: Graph G
Sol: Incidence matrix for the above graph is
e1 e2 e3 e4 e5 e6
A 1 1 0 0 00
B 0 0 1 1 01
IG= C 0 0 0 0 1 1
D 101000
E 0 1 0 1 10
Properties of Incidence Matrix:
1. The incidence matrix contains only 0 and 1.
2. The number of 1’s in each row equals to the degree of the
corresponding vertex.
3. A row with all zeros represents an isolated vertex.
4. The parallel edges in a graph produce identical columns in its
incidence matrix.
5. Every edge is incident on exactly two vertices, each column of the
incidence matrix has exactly two ones except the loop.
6. A row with a single unit entry corresponds to a pendant vertex.
2. Incidence Matrix Representation: (Directed Graph)
Let G=(V,E) be a simple graph with n vertices ordered from
v1 to vn and edges from e1 to em and with no self loops, then
the matrix BG=[bij] is called the incidence matrix of the directed
graph G. The elements of BG=[bij] is defined by the following
rule.
1 when vi is the initial vertex of the edge ej
bij = -1 if vi is the final vertex of ej
0 otherwise
Note: if the graph is not directed, then change all -1 entries into 1.
Example-1: Write down the incidence matrix for the directed
graph.
e2 e6
v2 v3
e1 e3 e5 e7 v5 Fig: Graph G
v1 e4 e8
v4
e9
Sol: The incidence matrix for the directed graph is
e1 e2 e3 e4 e5 e6 e7 e8 e9
v1 -1 0 -1 -1 0 0 0 0 0
v2 1 1 0 0 0 0 0 0 0
v3 0 -1 1 0 1 1 -1 0 0
v4 0 0 0 1 -1 0 0 1 -1
v5 0 0 0 0 0 -1 1 -1 1
3.Path Matrix:
Let G=(V,E) be a simple graph with n vertices ordered
from v1 to vn and with no self loops and parallel edges,
then the matrix PG=[pij] is called the path matrix of the graph G.
The elements of PG=[pij] is defined by the following rule.
pij = 1 if there is a path from vi to vj
0 otherwise
Example: Write down the path matrix for the following graph.
AB A B CD
A11 11
DC B11 11
C11 11
Fig: Graph G D11 11
Fig: Path Matrix of Graph G
Planar Graph:
A graph G is said to be planar if it can be drawn in a plane
with out its edges crossing.
A graph G is said to be non-planar if it can not be drawn in a
plane with out its edges crossing.
Example:
AB AB
DC DC
Fig: Graph G
Fig: Planar Graph of G
Example-2: Check the following graph is planar or not.
A
BE
Fig: Graph G
Sol: A graph G is said tCo be planar if iDt can be drawn in a plane with out
its edges crossing.
A
BE
Fig: Planar Graph
The above graph is a planarCgraph because inDthat graph thoefraebaorevneograanpyhedGge crossings
Example-3: Check the graph K5 is planar or not.
A
BE
Fig: Graph G
Sol: A graph G is said tCo be planar if iDt can be drawn in a plane with out
its edges crossing.
Edge crossing A
BE
Fig: Non-Planar
The above graph is not a plaCnar graph becausDe it containsGgerdragapephchrGoosfsainbgove
Example-4: Check the graph K2,3 is planar or not.
V1 V2
Sol: A graph G is said to be planar if it can be drawn in a plane with out its edges
crossing. V3 V4
V5
The above gVra1ph is a planVa2r graph because in that graph there are no any edge
crossings.
V3 V4 V5
Example-5: Check the graph K3,3 is planar or not.
V1 V2 V3
Sol: A graph G isVs4aid to be pVla5nar if it cVa6n be drawn in a plane with out its
edges crossing.
V1 V2 V3
V6
.
V4 V5
Edge crossing
The above graph is not a planar graph because in that graph
there is only one edge crossing.
NOTE: A plane graph divides the plane into regions. A region is
characterized by the cycle that forms its boundary. These regions
are connected portions of the plane.
Example:
V1 r6
r5
r1
V2 r2
V4
r3
r4
V3 V5
in each plane , plane graph G determines a region of infinite
area called the exterior region of G. In the above example r6 is the
exterior region. The vertices and edges of G incident with a region
r make up the boundary of the region r.
In the above example, v1-v2-v3-v1 is the boundary of region r1.
Degree of a region:
The degree of a region r is the length of its boundary,
denoted by deg(r).
from the above graph G
deg(r1)=3
deg(r2)=3
deg(r3)=3
deg(r4)=3
deg(r5)=3
deg(r6)=3
EULER’S FORMULA OR THEOREM
A Connected planar graph G with V vertices and E edges
has exactly | E |- |V | + 2 regions called Euler’s formula or
Euler’s theorem. It can be defined as the following form.
| R | = | E |- | V | + 2
(or)
| V | - | E | +| R| = 2
Where | R | is the number of Regions
| V | is the number of Vertices
| E | is the number of Edges