0% found this document useful (0 votes)
26 views52 pages

UNIT V A

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views52 pages

UNIT V A

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

ACE

Engineering College

UNIT – V
GRAPH THEORY
Graphs: Graphs and Graph Models, Graph Terminology and
Special Types of Graphs, Representing Graphs and Graph
Isomorphism, Connectivity, Euler and Hamilton Paths,
Shortest-Path Problems, Planar Graphs, Graph Coloring.

Trees: Introduction to Trees, Applications of Trees, Tree


Traversal, Spanning Trees, Minimum Spanning Trees

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

➢ Directed graph(Digraph)
• Definition
• Initial and Terminal vertices
• Directed Loop
• Parallel directed edges
• Multiple directed edges
• Isolated vertex
• Source and Sink
• In-Degree and Out-Degree
• First Theorem of Digraph Theory

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Directed Graph or Digraph


A directed graph is a graph in which the edges are directed
edges
OR
A directed graph is pair (V,E), where V is a non-empty set and
E is a set of ordered pairs of elements taken from the set V
➢The directed graph (V,E) is denoted by D = (V,E) or D = D(V,E)
or just D
➢The elements in V are called vertices or nodes or points and
the set V is called vertex set
➢The elements in E are called directed edges and the set E is
called directed edge set
➢ For any edge AB, A is called initial vertex and B is called
terminal vertex
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Types of Edges:
Directed Loop: A directed edge beginning and ending with the
same vertex is A is called directed loop and is denoted by
(A,A) or AA

Parallel Directed Edges: Two directed edges having same


initial and terminal vertices are called parallel directed edges

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Multiple Directed Edges: Two or more directed edges having


same initial and terminal vertices are called Multiple directed
edges

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Types of Vertices:
Isolated Vertex: A vertex which is neither initial vertex nor
terminal vertex for any directed edge is called isolated vertex

Non-Isolated Vertex: A vertex which is either initial vertex or


terminal vertex or both for any directed edge is called non-
isolated vertex

Source: A non-isolated vertex which is not a terminal vertex


for any directed edge is called Source

Sink: A non-isolated vertex which is not a initial vertex for


any directed edge is called Sink

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

In-Degree of a vertex: The number of edges coming to the


vertex v in any directed graph is called In-Degree of the vertex
v or incoming degree of v and is denoted by d-(v) or id(v)

Out-Degree of a vertex: The number of edges going form the


vertex v in any directed graph is called Out-Degree of the
vertex v or outgoing degree of v and is denoted by d+(v) or
od(v)

Note: (1) If d+(v) = 0 then v is sink


(2) If d-(v) = 0 then v is source
(3) If d+(v) = 0 = d-(v) then v is isolated vertex
(4) If d+(v) or d-(v) or both are not equal to zero
then v is non-isolated vertex
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

First Theorem of Digraph Theory:


In every digraph D, the sum of the out-degrees of all vertices
is equal to the sum of the in-degrees of all the vertices, each
sum being equal to the number of edges in D

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Undirected Graph or Graph:


•Definition
•Order and Size of Graph
•Simple Graph, Multigraph, General Graph
•Adjacent edges and Adjacent vertices
•Complete Graph
•Bipartite Graph
•Complete Bipartite Graph
•Vertex degree, degree of a graph, isolated and pendant
vertex
•Regular Graph
•Fundamental Theory of Graph Theory
•Graph Isomorphism
•Sub graph
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Undirected Graph or Graph:


•Spanning sub graph
•Walks and their classifications
•Connected and Disconnected graphs
•Euler circuits and Euler trails
•Hamilton cycle and Hamilton paths
•Planar and non-planar graphs
•Graph colouring
•Chromatic number
•Map colouring

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Undirected Graph or Graph:


An Undirected graph is a graph in which the edges are
undirected edges
OR
A directed graph is pair (V,E), where V is a non-empty set and
E is a set of unordered pairs of elements taken from the set V
➢The graph (V,E) is denoted by G = (V,E) or G = G(V,E)or just G
➢The elements in V are called vertices or nodes or points and
the set V is called vertex set
➢The elements in E are called Undirected edges and the set E
is called undirected edge set
➢A graph with no edges is called null graph
➢A graph with only one vertex is called trivial graph

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Order and Size of a Graph:


➢The number of vertices in a graph is called order of the
graph and the number of edges of the graph is called size of
the graph
➢For any graph G = (V,E), the cardinality of the set V (i.e IVI)
is called order of G and the cardinality of the set E (i.e IEI) is
called size of G
➢A graph of order n and size m is called an ( n, m) graph
End Vertices :
If there is an edge joining two vertices A and B then A and B
are called the end vertices of that particular edge

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Types of Edges:
Loop: An edge with the same end vertices is called loop

Parallel Edges: Two edges having same end vertices are called
parallel edges

Multiple Edges: Two or more edges having same end vertices


are called Multiple edges

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Simple Graph: A graph which does not contain loops and multiple
edges is called simple graph

Loop-Free Graph: A graph which does not contain loops is called


loop-free graph

Multigraph: A graph which contains multiple edges but not


loops is called Multigraph.

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

General Graph: A graph which contains loops or multiple edges or


both is called General graph

Labelled Graph: If the names are assigned to the vertices of a graph


then it is called labelled graph

Unlabeled graph: If the names are not assigned to the vertices of a


graph then it is called unlabelled graph

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Incidence : A vertex v is said to be incident on the edge e if v is an end


vertex of the edge e of a graph G
Since every edge has two end vertices, so every edge is incident on two
vertices one at each end
Adjacent Edges : Two edges are said to be adjacent edges if they have
common vertex
Adjacent Vertices : Two vertices are said to be adjacent vertices if
there is an edge joining them
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Properties of Simple Graph:


(1) A connected simple graph with n vertices must contain
(n-1) edges
(2) A connected simple graph with n vertices must contain
at most n(n-1)/2 edges
( Since every vertex must me connected to remaining vertice
in this case the degree of every vertex is (n-1)
From the sum of degrees theorem(Handshaking property
sum of degrees of vertices = 2lEl
deg(v1) + deg (v2)+-----+ deg(vn) = 2lEl
(n-1) + (n-1) +---------+ (n-1) = 2lEl
n(n-1) = 2lEl ➔ lEl = n(n-1)/2
(3)

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Complete Graph:
A simple graph of order ≥ 2 in which there is an edge between every
pair of vertices is called complete graph or full graph
A complete graph with n ≥ 2 is denoted by Kn

K5 graph is called Kuratowski’s first graph


V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Bipartite Graph:
A simple graph G is such that its vertex set is the union of two mutually
disjoint nonempty sets V1 and V2 which are such that every edge in G
joins a vertex in V1 and a vertex in V2. Then the graph G is called a
Bipartite graph and the graph is denoted by G = (V1 , V2 ;E ). Here V1 and
V2 are called bipartite of a vertex set V

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Complete Bipartite Graph:


A bipartite graph G = (V1 , V2 ;E ) is called a complete bipartite graph if
there is an edge between every vertex in V1 and every vertex in V2
➢A complete bipartite graph in which V1 and V2 contain r and s vertices
respectively with r ≤ s, is denoted by Kr,s
➢Kr,s has r + s vertices and rs edges that is Kr,s is of order r + s and size rs

K3,3 is called Kuratowski’s second graph


V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Vertex Degree and Handshaking Property:


Vertex Degree: Let G = (V,E) be a graph and v be a vertex in G
➢The number of edges of G that are incident on v (i.e the number of
edges of G terminating on v) with loops counted twice is called the
degree of the vertex v
➢The degree of the vertex v is denoted by deg(v) or d(v)
Degree of the Graph:
➢The minimum of the degrees of vertices of a graph is called the degree
of the graph
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Isolated Vertex, Pendant Vertex:


➢A vertex in a graph which is not an end vertex of any edge of the graph
is called an isolated vertex
➢ A vertex is an isolated vertex iff its degree is zero
➢ A vertex of degree 1 is called pendant vertex.
➢ An edge incident on a pendant vertex is called pendant edge
➢ Null graph contains no edges, so every vertex in a null graph is an
isolated vertex
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Handshaking Property:
(Fundamental Theorem of Graph Theory)
Statement: The sum of the degrees of all the vertices in a graph is an
even number and this number is equal to twice the number of edges in
the graph.
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Regular Graph:
➢A graph in which all the vertices are of the same degree k is
called a regular graph of degree k or k-regular graph
➢ 3-regular graphs are called cubic graphs
➢ 3-regular graph which contains 10 vertices and 15 edges is
called Petersen graph
➢ 3-regular graph with 23 vertices is called 3- dimensional
hypercube and is denoted Q3
➢ A loop-free k- regular graph with 2k vertices is called k-dimensional
hypercube and is denoted by Qk
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Petersen Graph:

3-Dimensional Hypercube:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Graph Isomorphism:
Consider two graphs G = (V,E) and G1 = (V1,E1). If there exists a function
f: V→V1 such that (i) f is one-to-one and onto and (ii) for all vertices A,B
of G ,the edge {A,B} belongs to E if and only if {f(A), f(B)} belongs to E1.
Then f is called an isomorphism between G and G1
OR
Two graphs G and G1 are said to be isomorphic if there is a one-to-one
correspondence between their vertices and edges such that the
adjacency is preserved
When G and G1 are isomorphic, we write G G1
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Necessary Conditions for Isomorphism of Graphs:
If two graphs G and G1 are isomorphic then the following conditions are
satisfied
(1) Both have same number of vertices
(2) Both have same number of edges
(3) An equal number of vertices with a given degree
Note:
The above are only necessary conditions but not sufficient conditions
That is any graphs which satisfies the above conditions need not be
isomorphic
For Example:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Problems on Isomorphism:
(1) Prove that the following graphs are isomorphic

Ans: The given two graphs have (1) Same number of vertices (2) same
number of edges (3) equal number of vertices with given degree
The one-to-one correspondence between edges is given by
{u1,u2} ↔{v1,v4}, {u1,u3} ↔{v1,v3}
{u2,u4} ↔{v4,v2}, {u3,u4} ↔{v3,v2 }
The one-to-one correspondence between vertices is given by
u1 ↔ v1 , u2 ↔ v4 , u3 ↔ v3 , u4 ↔ v2
Therefore the given two graphs are isomorphic to each other

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
(2) Prove that the following graphs are not isomorphic

Ans:
The given two graphs have (1) same number of vertices
(2) Unequal number of edges
So the given two graphs are not isomorphic since the given
two graphs are not having same number of edges

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Sub Graphs:
For any two graphs G and G1, we say that G1 is a sub graph of G if the
following conditions are satisfied
(1) All the vertices and all the edges of G1 are in G
(2) Each edge of G1 has the same end vertices in G as in G1
Examples:

Note: (1) Every graph is a sub graph of itself


(2) Every simple graph of n vertices is a sub graph of the complete graph Kn
(3) If G1 is a sub graph of G2 and G2 is a sub graph of G then G1 is a sub graph
of G
(4) Every single vertex in a graph G is a sub graph of G
(5) Every single edge in a graph G,together with its end vertices is a sub graph
of G
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Spanning Subgraphs:
For any given graph G = (V,E), if there is a subgraph G1 = (V1,E1) of G
such that V1 = V then G1 is called spanning subgraph of G
OR
A Subgraph of G which contains all the vertices of G, then it is called
spanning subgraph of G
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Induced Subgraphs:
For any given graph G = (V,E), if there is a subgraph G1 = (V1,E1) of G such that
every edge {A,B} of G, where A,B ϵ V1 is an edge of G1 also then G1 is called
subgraph of G induced by V1 and is denoted by <V1>
Examples:

Complement of Subgraph:
For a given graph G and a subgraph G1 of G, the subgraph of G obtained
by deleting all the edges of G1 from G, is called the complement of G1 in
G and is denoted by G-G1 or G1

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Complement of a simple graph:
We know that every simple graph of order n is a subgraph of the
complete graph Kn.
If G is a simple graph of order n, then the complement of G in Kn is
called the complement of a simple graph G and is denoted by G
Thus
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Walks and their Classification:
Walk: It is an alternating sequence of vertices and edges v1e1v2e2-----
ek vm which begins and ends with vertices and each edge in the
sequence is incident on the two end vertices.
➢The number of edges in the walk is called length of the walk
➢ A walk that begins and ends at the same vertex is called closed walk
➢ A walk that begins and ends with different vertices is called open walk
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Trail and Circuit:


➢A open walk in which the edges are not repeated more than once is called
Trail
➢A closed walk in which the edges are not repeated more than once is called
Circuit
Path and Cycle:
➢A trail in which the vertices are not repeated more than once is called a path
➢A circuit in which the vertices are not repeated more than once other than
initial and terminal vertices is called cycle
Example:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Connected and Disconnected Graphs:


➢Two vertices u and v are said to be connected if there is at lest one
path from u to v
➢A graph G is called connected if every pair of vertices are connected
Otherwise G is called disconnected graph
➢Every graph G consists of one or more connected graphs. Each such
connected graph is a subgraph of G and is called a component of G
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Euler Circuits and Euler trails:


➢Let G be a connected graph. If there is a circuit in G that contains all
the edges of G then that circuit is called an Euler Circuit or Eulerian line
or Euler tour in G
➢If there is a trail in G that contains all the edges of G then that trail is
called an Euler trail or Unicursal line in G
➢A connected graph that contains an Euler Circuit is called Euler graph
of Eulerian graph
➢A connected graph that contains an Euler trail is called a Semi-Euler
graph or unicursal graph
Example:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Hamilton Cycles and Hamilton Paths:
Let G be a connected graph.
➢If there is a cycle in G that contains all the vertices of G then that cycle is
called Hamilton Cycle in G
➢If there is a path in G that contains all the vertices of G then that path is
called Hamilton path in G
➢A graph that contains Hamilton cycles is called a Hamilton Graph or
Hamiltonian graph
➢A Hamilton cycle in a graph of n vertices consists of exactly n edges because
a cycle with n vertices has n edges
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Planar and Non-Planar Graphs:
A graph in which the edges intersects only at the vertices is called Planar
graph. Otherwise it is called Non-Planar graph
OR
A graph in which the edges are not crossing other than at the vertices is
called Planar graph. Otherwise it is called Non-Planar graph
Examples:

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
Problems:
(1) Prove that (a) a graph of order 5 and size 8 (b) a graph of order
6 and size 12 are planar.

(2) Show that K2,K3 and K4 are planar graphs.

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
(3) Prove that K2,2 and K2,3 are planar graphs .

(2) Show that K5 is not planar graph.

The above graph contains 10 edges. In these 10 edges 9 edges can be drawn without crossing them
each other but 10th edge can not be drawn without crossing the other edges. So it is not planar
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Graph Coloring:
➢For a given planar or non-planar graph G, if we assign the colours to
the vertices in such a way that no two adjacent vertices have the same
colour. Then we say that the graph G is properly coloured
➢A graph can have more than one proper colouring
➢Two non adjacent vertices in properly coloured graph can have the
same colour
Chromatic Number:
➢The least number of colours required to colour the graph is called
chromatic number
➢A k-chromatic graph is a graph that can be properly coloured with k
colours but not less than k colours
➢If a graph G is k-chromatic then k is called chromatic number of G
➢The chromatic number of a graph G is denoted by
➢The maximum number of colours required to colour the graph G is
equal to number of vertices of G
V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE
ACE
Engineering College

Examples:Find the chromatic numbers of the following graphs

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Map Colouring:
➢If we assign the colours to the regions of a map in such a way that no
two adjacent regions have the same colour then we say that the map is
properly coloured
➢A proper colouring of regions is called map colouring
Examples:

Five Colour Theorem:


The vertices of every connected simple planar graph can be properly
coloured with five colours
Four Colour Theorem:
Every simple, connected planar graph is 4-colourable

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College

Euler’s Formula:
Let G be planar graph. Then G consists of finite number of regions
The number of edges that form the boundary of the region is called
degree of the region
Let us consider the following planar graph

Euler’s Formula:
A connected planar graph G with n vertices and m edges has exactly
m – n + 2 regions in all of its diagrams.

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE


ACE
Engineering College
(3) Prove that the following graphs are isomorphic

Ans: The given two graphs have (1) Same number of vertices (2) same
number of edges (3) equal number of vertices with given degree
The one-to-one correspondence between edges is given by
{u1,u4} ↔{v1,v2}, {u1,u5} ↔{v1,v3}, {u1,u6} ↔{v1,v6}
{u2,u5} ↔{v4,v3}, {u2,u4} ↔{v4,v2}, {u2,u6} ↔{v4,v6}
{u3,u6} ↔{v5,v6}, {u3,u4} ↔{v5,v2}, {u3,u5} ↔{v5,v3}
The one-to-one correspondence between vertices is given by
u1 ↔ v1 , u2 ↔ v4 , u3 ↔ v5
u4 ↔ v2 , u5 ↔ v3 , u6 ↔ v6
Therefore the given two graphs are isomorphic to each other

V Chandra Sekhar Reddy, Assoc.Prof., Dept. of CSE

You might also like