Module 6 Graphs (E)
Module 6 Graphs (E)
MODULE 6
GRAPH THEORY
Dr. Bhakti palkar
12/12/24 2
Topics Covered
Graphs and Subgraphs 05 CO4
6.1 Definitions, Paths and circuits,
Types of Graphs,
Eulerian and Hamiltonian
6.2 Planer graphs
6.3 Isomorphism of graphs
6.4 Subgraph
12/12/24 4
Definitions - Graph
A graph G consists of a finite set v of objects called
vertices, a finite set E of objects called edges and a
function that assigns to each edge a subset {v, w} where
v and w are vertices (and may be the same).
We will write G = (V, E, )
12/12/24 5
Graph
Let V={1, 2, 3, 4}
and E={ e1, e2, e3, e4, e5}.
Let g be defined by
(e1)= (e5) = {1, 2},
(e2)={4, 3}, (e3)= {1, 3}, (e4)={2, 4}.
Then G={V, E, ) is a graph as shown in
12/12/24 6
u v
12/12/24 7
Definitions
Degree :
The degree of a vertex is the number of edges
having that vertex as an end point.
Loop :
A graph may contain an edge from a vertex to
itself, such an edge is referred to as a loop. A loop
contributes 2 to the degree of a vertex. Since that
vertex serves as both end points of the loop.
Isolated Vertex :
A vertex with degree 0 will be called an isolated
vertex.
Adjacent Vertices :
A pair of vertices that determine an edge are
adjacent vertices.
12/12/24 8
u v
w
12/12/24 9
Directed graph
Directed Graph: G(V, E), set of vertices V, and set of
Edges E, that are ordered pair of elements of V (directed
edges)
Representation Example: G(V, E), V = {u, v, w}, E = {(u, v),
(v, w), (w, u)}
u v
w
12/12/24 10
u v
w
12/12/24 11
Connected graph
A graph is called connected if there is a path from any
vertex to any other vertex in the graph.
Otherwise, the graph is disconnected. If the graph is
disconnected, the various connected pieces are called the
components of the graph.
12/12/24 12
Problem
Determine whether the graph (shown in Fig. 6.5) is
connected or disconnected. If disconnected find its
connected component.
Complete Graph
For each integer n 1, let Kn denote the graph with vertices
{v1, v2, … vn } and with an edge {vi, vj} for every i and j.
In other words, every vertex in Kn is connected to every
other vertex. In
12/12/24 14
More Graphs
Linear graph:
Discrete Graph:
12/12/24 15
Multigraph
Directed graph having multiple edges between two vertices
is called as multigraph. Undirected graph having more
than one edge between two vertices is also called as
Multigraph.
12/12/24 16
Subgraph
(a)
contains all the end points of edges in E1. Then H = (V1, E1,
1) is also a graph, where 1 is restricted to edges in E1.
Such a graph H is called a subgraph of G.
12/12/24 18
Spanning Subgraph
A subgraph is said to be spanning subgraph if it contains
all the vertices of G.
12/12/24 19
Complement of Subgraph
The complement of a subgraph G' = (V', E') with respect to
the graph G = (V, E) is another subgraph
G" = (V", E") such that E" is equal to E – E' and V" contains
only the vertices with which the edges in E" are incident.
12/12/24 20
Complement of Subgraph
u u u
v
w v w v
G H1 H2
12/12/24 21
Subgraph Isomorphism
The subgraph isomorphism is a computational task in
which two graphs G and H are given as input, and one
must determine whether G contains a subgraph that is
isomorphic to H.
Handshaking Lemma
Consider a graph G with e number of edges and n number
of vertices. Since each edge contributes two degrees, the
sum of the degrees of all vertices in G is twice the number
of edges in G i.e.
∑ d( vi) = 2 e
12/12/24 23
Problem
How many nodes are necessary to construct a graph with
exactly 6 edges in which each node is of degree 2.
Soln. : Suppose there are n vertices in the graph with
6 edges. Also, given the degree of each vertex is 2.
Therefore by handshaking lemma,
Σd (vi)=2e = 2 6
d (v1) + d (v2) + … + d (vn) = 12.
= 12
2n = 12
n = 6
Hence, 6 nodes are required to construct a graph with 6
edges in which each node is of degree 2.
12/12/24 24
Problem
Determine the number of edges in a graph with 6 nodes, 2
of degree 4 and 4 of degree 2. Draw two such graphs.
12/12/24 25
Problem
Determine the number of edges in a graph with 6 nodes, 2
of degree 4 and 4 of degree 2. Draw two such graphs.
Soln: Suppose the graph with 6 vertices has e number of
edges. Therefore, by handshaking lemma.
Σd (vi) = 2e
d (v1) + d (v2) + d (v3) + d (v4) + d (v5) + d (v6 ) = 2e
Now, given 2 vertices are of degree 4 and 4 vertices are of
degree 2.
Hence from the above equation
(4 + 4) + (2 + 2 + 2 + 2) = 2e
16 = 2e
e = 8
12/12/24 26
Example
12/12/24 29
Example
12/12/24 33
Examples
Problem
Determine the Eulerian and Hamiltonian path, if exists, in
the following graphs.
Hamiltonian path : p, u, v, q, s, t, r
Hamiltonian circuit : r, p, u, v, q, s, t, r
Eulerian path : (p, u, v, q, s, v, u, r, t, s, r, p, q)
Hamiltonian path : c, d, e, b, a
Hamiltonian circuit : c, d, e , b, a, c
Eulerian path : (e, d, b, a, d, c, a, e, b)
12/12/24 36
(a)
(b)
12/12/24 37
Isomorphic Graph
Graph - Isomorphism
Representation example: G1 = (V1, E1) , G2 = (V2, E2)
f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2
No. of vertices:4
No. of edges:4
All vertices have degree 2
u1 u2 v1 v2
u3 u4 v4
v3
12/12/24 41
Isomorphism of Graphs
Example I: Are the following two graphs isomorphic?
a a
e
b b
e
c c d
d
Isomorphism of Graphs
Example II: How about these two graphs?
a a
b
e
e
b
c c
d
d
Isomorphism of Graphs
Example III: Are the following two graphs isomorphic?
Solution:
Both graphs contain
8 vertices and 10 edges
Nos of vertices of degree 2 = 4
Nos of vertices of degree 3 = 4
Adjacency : There exists no vertex
of degree 3 whose adjacent vertices
have same degree in both graphs
So its not ISOMORPHIC
12/12/24 44
Isomorphism of Graphs
Example IV: Are the following two graphs isomorphic?
Isomorphism of Graphs
Example V: Are the following two graphs isomorphic?
Isomorphism of Graphs
Example VI: Are the following two graphs isomorphic?
Planar Graphs
• A graph (or multigraph) G is called planar if G can be
drawn in the plane with its edges intersecting only at
vertices of G, such a drawing of G is called an embedding
of G in the plane.
• Application Example: VLSI design (overlapping edges
requires extra layers), Circuit design (cannot overlap wires
on board)
• Representation examples: K1,K2,K3,K4 are planar, Kn for
n>4 are non-planar
K4
12/12/24 48
Examples
12/12/24 49
Planer Graph
• Theorem : Euler's connected planar graph theorem
v–
e+r=2
number number
number of regions
of vertices of edges
12/12/24 51
Q. 1) By drawing the graph, show that following graphs are planar graphs
12/12/24 52
12/12/24 53
Q. 2 : How many edges must a planar graph have if it has 7 regions and 5
nodes. Draw one such graph.
Soln. :
According to Euler's formula, in a planar graph
v–e+r = 2
where v, e, r are the number of vertices, edges and regions in a planar
graph.
Here v = 5, r =7, e = ?
v–e+r =2
5 – e + 7=2
e=10
Hence the given graph must have 10 edges.
12/12/24 54
(a) Simple
Graph (a) Multi-Graph
12/12/24 56
By Euler's theorem,
| V | – | E | + | R |=2
20 – 30 + | R |=2
| R |=12