Download as ppsx, pdf, or txt
Download as ppsx, pdf, or txt
You are on page 1of 60

Unit-5

Graph theory
BY PURVI TANDEL

03/13/2024 1
Graphs and Sub-graphs
Definitions and basic concepts

Topics of Types of graphs


Isomorphism
Unit 5 Adjacent vertices and incident vertices
Walk, path and circuits
Applications of Graphs:
Euler’s graph
Hamiltonian paths and circuits
Shortest path problems – Dijkstra’s algorithm
Travelling salesman problem

03/13/2024 2
Graph
A graph, written as G = G (V, E) consists of two components:
(I) The finite set of vertices V, also called points(Nodes) and
(II)The finite set of edges E, also called lines or arcs connecting pair of vertices.

03/13/2024 3
Graph
A graph consists of a nonempty set (The set of vertices),
(The set of edges) and a mapping from to .

V =V ( G )= { 𝑣 1 , 𝑣 2 , 𝑣 3 , … }The set of vertices(nods/points/dots/junctions).

E=E ( G )={ 𝑒 1 , 𝑒2 , 𝑒 3 , … }The set of edges(branch/line/arc).

The elements of are called vertices and the elements of are called edges of
a graph .

Note Throughout this unit we shall consider and are finite set.

03/13/2024 4
Graph
𝑣2 𝑣 7 V ={ 𝑣 1 , 𝑣 2 , 𝑣 3 , 𝑣 4 , 𝑣 5 , 𝑣 6 , 𝑣7 , 𝑣 8 , 𝑣 9 }
𝑒5 𝑣8
𝑒2 E= { 𝑒1 , 𝑒2 , 𝑒 3 ,𝑒 4 , 𝑒 5 ,𝑒 6 , 𝑒 7 ,𝑒 8 , 𝑒 9 ,𝑒 10 }
𝑣3
𝑒1 𝑣1
𝑒3 𝑣5 𝑒 1= ( 𝑣 1 , 𝑣 1 ) 𝑒 6 =( 𝑣 4 ,𝑣 5 )
𝑒6
𝑒7 𝑒 2= ( 𝑣 1 , 𝑣 2 ) 𝑒 7= ( 𝑣 5 , 𝑣 6 )
𝑒4
𝑒8 𝑣6 𝑒 3= ( 𝑣 2 , 𝑣 4 ) 𝑒 8= ( 𝑣 4 , 𝑣 9 )
𝑣4
𝑒9 𝑒 4 =( 𝑣1 , 𝑣 4 ) 𝑒 9 =( 𝑣 4 ,𝑣 9 )
𝑒 10 𝑣9 𝑒 5=( 𝑣 2 , 𝑣3 ) 𝑒 10 =( 𝑣 4 , 𝑣 9 )

03/13/2024
G 5
Graph
End Points:
Each pair of vertices connecting with an edge is called the
end points. Ex. {v1, v2}

Origin or Source of edge:


In each pair of vertices connecting through an edge, first
element is called the origin or the source of the edge.

Terminus or Terminating vertex:


Second element is called the terminus or terminating
vertex.

03/13/2024 6
Graph
Finite Graph:
Usually in a graph G we denote the number of vertices by
n and the number of edges by m. If both m and n are finite,
G is said to be a finite graph.

Indegree:
The indegree of a vertex v in a directed graph is the
number of edges ending at it, and is denoted as indeg (v).
Ex. For v2 vertex indegree is 2.

Outdegree:
The outdegree of a vertex v in a directed graph is the
number of edges beginning from it, and is denoted as
outdeg (v). Ex. For v2 vertex outdegree is 2.
03/13/2024 7
Graph
Degree of a vertex:
The degree of a vertex denoted by d(v) or deg(v) is the
number of edges connected with it. Ex. Vertex v2 has
degree 4.

03/13/2024 8
Adjacent Vertices & Incident Edge
Any edge e can be made by one OR two
vertices. 𝑢 𝑣
𝑒 𝑒
𝑢
𝑒= (𝑢 , 𝑣 )
𝑒= (𝑢 , 𝑢 ) unordered
𝑒= ( 𝑣 , 𝑢 ) pair
If two vertices and are joined by an edge then and are said to be
adjacent vertices.

An edge which joins the vertices and is said to be incident to the


vertices and .
03/13/2024 9
Loop(Sling) & Parallel Edges(Multiple Edges)
An edge of a graph G that joins a If two vertices of a graph are
joined by
vertex to itself is called a loop. more than one edge then these
i.e., A loop is an edge . edges are called parallel edges.

𝑒 𝑢 𝑒1
𝑒= (𝑢 , 𝑢 ) 𝑒2
𝑢 𝑒3 𝑣
Here is a self loop Here and are parallel edges.

03/13/2024 10
Directed Edge, Initial Vertex and Terminal Vertex
In a graph an edge which is associated with an ordered pair of vertices to
is called directed edge of a graph .

Let be a graph and let be a directed edge associated with the


order pair of vertices and then the edge is said to be initiating
(originating) in the vertex and terminating(ending)
in the vertex .
The vertex is called initial vertex of edge . 𝑢 𝑒 𝑣
The vertex is called terminal vertex of edge .
𝑒=¿ 𝑢, 𝑣>¿ ordered
𝑒≠<𝑣 ,𝑢>¿ pair

03/13/2024 11
Directed Graph(Digraph)
A graph in which every edge is directed is called a directed graph.

G1 G2 G3
03/13/2024 12
Undirected Edge and Undirected Graph
In a graph an edge which is associated with an unordered pair of
vertices and is called undirected edge of a graph .

𝑢 𝑒 𝑣 𝑒= (𝑢 , 𝑣 )
Unordered
𝑒= ( 𝑣 , 𝑢 ) pair

A graph in which every edge is


undirected is called an undirected graph.

03/13/2024 13
Mixed Graph and Distinct Edges
If some edges of a graph are The two possible edges between a
directed and some edges are pair of vertices which are
undirected then is said to be opposite
in direction which are known as
a mixed distinct
graph. edges.

03/13/2024 14
Multi Graph and Simple Graph
Any graph which contains some A graph which has neither
parallel edges is called a loop nor parallel edges is called a
multigraph.
simple graph.

03/13/2024 15
Weighted Graph
A graph in which weight are It can happen that two graphs
assigned which look entirely
to every edge is called a weighted different
but both may represent the
graph. same
graph.

G1 G2
03/13/2024 16
Isolated Vertex and Null Graph
In a graph a vertex which is not A graph which contains only isolated
adjacent to any other vertex vertices is called a null
is
called an isolated vertex. graph.

G
In , are isolated vertices.
03/13/2024 17
Pseudo Graph
In a graph in which loops and multiple edges are allowed is called a
pseudo graph.

03/13/2024 18
Method 1 Example 1
Que: Draw the undirected graph where and and its incidence relations given as:
Discuss all the terms.

Sol 𝑒 𝑒7 𝑑 𝑒4 𝑐
:
𝑒6 𝑒1
𝑒3

𝑎 𝑒 𝑏 𝑒5
2

03/13/2024 19
Method 1 Example 1(continue)
𝑒 𝑒7 𝑑 𝑒4 𝑐  All edges of are undirected.

𝑒6 𝑒1 Directed graph No
𝑒3
Undirected graph Yes
𝑎 𝑒 𝑏 𝑒5 Mixed graph No
2
Multi graph Yes
and are adjacent vertices.
and are not adjacent.
Simple graph No
has no isolated vertex. Weighted graph No
is incident to and . Null graph No
is a loop.
and are parallel edges.

03/13/2024 20
Method 1 Example 2
Que: Draw the directed graph where and and its incidence relation given as:

Discuss all the term.

Sol
: 𝑏 𝑒3 𝑐 𝑒5 𝑓 𝑒6

𝑒8
𝑔
𝑒1 𝑒4
𝑒7
𝑎 𝑒2 𝑑 𝑒
03/13/2024 21
Method 1 Example 2(continue)
𝑒6  All edges of are directed.
𝑏 𝑒3 𝑐 𝑒5 𝑓

𝑒8
𝑔 Directed graph Yes
𝑒1 𝑒4
𝑒7 Undirected graph No
𝑎 𝑒2 𝑑 𝑒 Mixed graph No
and are adjacent vertices.
Multi graph No
and are not adjacent. Simple graph No
is isolated vertex. Weighted graph No
is incident to and . Null graph No
is loop.
There are no parallel edges.

03/13/2024 22
Order of a Graph and Size of a Graph
The number of vertices in is called
order of a graph .
The order of G is denoted by .

The number of edges in is called

G
size of a graph .
The size of G is denoted by .
Here .

03/13/2024 23
Degree of a Vertex
Let be an undirected graph then the
degree of a vertex is defined as
the number of edges incident on .

The degree of a vertex is denoted


by OR OR .

Note Self-loop will be counted twice in G


the
degree of a corresponding vertex. d ( 𝑣7 )= 0

03/13/2024 24
Odd Vertex, Even Vertex, Isolated Vertex and Pendant Vertex

A vertex with odd degree is called an odd vertex.

A vertex with even degree is called an even vertex.

A vertex with zero degree is called an isolated vertex.

A vertex with one degree is called a pendant vertex.

03/13/2024 25
Odd Vertex, Even Vertex, Isolated Vertex and Pendant Vertex
d ( 𝑣7 )= 0

are odd vertices in .


are even vertices in .
are isolated vertices in .
are pendant vertices in .
03/13/2024 26
Handshaking Theorem(Degree Sum Formula/ Theorem of Graph Theory)
Statement Any undirected graph with ‘’ vertices and ‘’ edges,
𝑛

∑ ( 𝑖)
d 𝑣 ¿ d ( 𝑣1 ) +d ( 𝑣 2 ) + …+d ( 𝑣𝑛 )
.

𝑖=1

Proof Let be an undirected graph with ‘’ vertices


and ‘’ edges.
Let , then ‘’ have two terminated vertices say .
By definition of degree of vertex, is count in the degree of and
degree of .

03/13/2024 27
Handshaking Theorem(Degree Sum Formula/ Theorem of Graph Theory)
Proof Continue
Therefore, every edge of is count twice and if is a loop then it is also
count twice.
Hence, the sum of degree of all the vertices of is twice the number of
edges. 𝑛

∑ d ( 𝑣 𝑖 ) =2 𝑒.
i.e.
𝑖=1

03/13/2024 28
Example on Handshaking Theorem
Example Verify Handshaking theorem for the following graph .

Solution In , the number of vertices is


and the number of edges is .
𝑛=9

∑ d ( 𝑣 𝑖 )¿ d ( 𝑣 ) +d ( 𝑣 ) + d ( 𝑣 ) + d ( 𝑣 )
1 2 3 4
𝑖=1
+ d ( 𝑣 5 ) +d ( 𝑣6 ) +d ( 𝑣7 ) +d ( 𝑣8 ) +d ( 𝑣 9 )
¿ 4+3+1+6+2+1+ 0+ 0+3
¿ 20¿ 2 ( 10 ).
Hence, Handshaking theorem is verified for the graph .
03/13/2024 29
Theorem of Graph Theory
Statement In any undirected graph , the number of odd vertices is even.

Proof Let be a graph with ‘’ vertices and ‘’ edges.


𝑛
By first theorem of graph ∑ d ( 𝑣 𝑖 ) =2 𝑒.
theory 𝑖=1

We divide into two sets say and . Where, is the set of even
vertices and is the set of odd vertices.

Therefore, ∑ d ( 𝑣 ) + ∑ d ( 𝑣 )=2 𝑒 .
𝑣 ∈U 𝑣 ∈W
03/13/2024 30
Theorem of Graph Theory
Proof Continue Example

⇒ ∑ d ( 𝑣 )=2𝑒 − ∑ d ( 𝑣 )
𝑣∈W 𝑣 ∈U
even even

⇒ ∑ d ( 𝑣 )is an even number.


𝑣∈W

Hence, the number of odd vertices


has (even) number of odd vertices.
is even in any undirected graph .

03/13/2024 31
Outdegree and Indegree of a Vertex for a Directed Graph
Let be a directed graph then for any vertex , the number of edges which
have as their initial vertex is called the outdegree of the vertex .
OR
In a directed graph , the number of edges directed outwards vertex is called
outdegree of the vertex .

Let be a directed graph then for any vertex , the number of edges which
have as their terminal vertex is called the indegree of the vertex .
OR
In a directed graph , the number of edges directed towards vertex is called
indegree of the vertex .
03/13/2024 32
Total Degree of a Vertex for a Directed Graph
Let be a directed graph then the sum of indegree and outdegree of vertex
is called the total degree of the vertex .

The outdegree of the vertex is denoted by .


The indegree of the vertex is denoted by .
The total degree of the vertex is denoted by .
i.e. .

Note The total degree of an isolated vertex is .


The vertex with degree is known as pendant vertex.

03/13/2024 33
Example of Degree for a Directed Graph
Example Find outdegree, indegree and total degree of all the vertices of
following graph .
Solution

Vertex Outdegree Indegree Total


𝑣1 d
+ ¿ ( 𝑣 1) =1¿
d ( 𝑣 1 )=1 degree

d ( 𝑣1 ) =2
𝑣2 d
+ ¿( 𝑣 2 )=2 ¿
d ( 𝑣 2 )= 2 d ( 𝑣2 ) = 4

𝑣3 + ¿( 𝑣 )=1 ¿
d ( 𝑣 3 ) =1 d ( 𝑣3 )= 2
G

d 3

𝑣4 d
+ ¿( 𝑣 4 )=2 ¿
d ( 𝑣 4 ) =2 d ( 𝑣 4 ) =4

03/13/2024 34
Degree Sum Formula for a Directed Graph
Statement In a directed graph with ‘’ vertices and ‘’ edges,
𝑛 𝑛 𝑛
∑d +¿ (𝑣 𝑖 )
¿ ∑ d ( 𝑣 𝑖¿

) 𝑒and∑ d ( 𝑣 𝑖 ) =2 𝑒.
𝑖 =1 𝑖 =1 𝑖=1

OR

The sum of indegrees of all the vertices of a simple digraph is equal to sum of
outdegrees of all its vertices which is equal to the number of edges of the
graph.

03/13/2024 35
Degree Sum Formula for a Directed Graph
Proof

Let be a directed graph with ‘’ vertices and ‘’ edges.


A vertex has indegree corresponding to simple edge is exactly .
Once an edge is count for indegree it will not count for outdegree for the
same vertex.
When we are adding the indegree of vertex, each edge is counted exactly
once.
Hence, total of indegree of all the vertices is same as the number of edges.

03/13/2024 36
Degree Sum Formula for a Directed Graph
𝑛
Proof continue
i.e. ∑ d ( 𝑣 𝑖 ) =𝑒 .

𝑖=1

𝑛
Similarly, we can ∑d +¿ (𝑣 𝑖 )=𝑒
.¿
prove 𝑖 =1
𝑛 𝑛 𝑛

∑ d (𝑣𝑖) ¿ ∑ d +¿ (𝑣 𝑖 )
+∑ d ( 𝑣 𝑖 ) ¿

𝑖=1 𝑖=1 𝑖=1

¿ 𝑒 +𝑒.

03/13/2024 37
Example of Degree Sum Formula for a Directed Graph
Example Verify degree sum formula for the following directed graph .
Solution In , the number of vertices is
and the number of edges is .

∑d +¿ (𝑣 𝑖 )
4 4
G
=6=𝑒, ¿∑ d ( 𝑣 ) =6=𝑒¿ ∑ d ( 𝑣 ) =12=2𝑒 .

𝑖 𝑖
𝑖=1 𝑖 =1 𝑖 =1
03/13/2024 38
Regular Graph
A graph in which all the vertices having same degree is called a regular graph.
If for every vertex if for some then is called a
regular graph.

regular regular

regular graphs
03/13/2024 39
Regular Graph

Petersen
Graph
regular graphs

03/13/2024 40
Complete Graph
A simple graph in which there exists an edge between every pair of vertices is
called a complete
graph.
A complete graph with vertices is denoted by .
The complete graph withvertices is regular.

K1 K2 K3
regular regular regular
03/13/2024 41
Complete Graph

K4 K5 K6
regular regular regular
Complete Graph
n (n −1)
The complete graph with n vertices has edges.
2

The complete graph with vertices has


5 ( 5− 1 ) 5 ( 4 )
2
¿
2 ¿ 10edges.

K5
Subgraph
Let and be two graphs. Then is said to be a subgraph of if
and . Here is called a super graph of .

Note The graph as well as the null


graph obtained by deleting all the
edges of are subgraphs of .

Other subgraphs of can be obtained


by deleting certain vertices and edges
Here is subgraph of . of .
Vertex Deleted Subgraph
The graph obtain by deletion of a vertex from a given graph is called a
vertex deleted subgraph of . It is denoted by .

𝑎 𝑎

𝑒 𝑏 𝑒 𝑏

𝑑 𝑐 𝑑 𝑐
G
Edge Deleted Subgraph
The graph obtain by deletion of an edge from a given graph is called an
edge deleted subgraph of . It is denoted by .

𝑎 𝑎
𝑒1 𝑒1

𝑒 𝑏 𝑒 𝑏

𝑑 𝑐 𝑑 𝑐
G
Example on Vertex Deleted Subgraph and Edge Deleted
Subgraph
Example Find subgraphs from given graph by deleting a vertex and an edge .

Solution
𝑣1 v1 𝑣1
𝑒1 𝑒7 𝑒6 e1 e7 𝑒6 𝑒1 𝑒7 𝑒6
𝑒8 𝑒8 𝑒8
𝑣2 𝑣2 𝑣2
𝑣5 𝑣5 𝑣5
𝑒2 𝑒5 𝑒2 𝑒5 𝑒2 𝑒5
𝑒3 𝑒3 𝑒3
𝑣3 𝑒4 𝑣4 𝑣3 𝑒4 𝑣4 𝑣3 e4 𝑣4

G G −{v 1 } G −{e 4 }
Complement of a Subgraph
Let be a complete graph and be a subgraph of . The complement of a
subgraph is obtained by remove all edges of which is present in .
It is denoted by .
a a a

e b e b e b

d c d c d c
G S S
Converse(Reversal/Directional Dual) of a Directed Graph
The converse of a directed graph is a directed graph
in which the relation is the converse of the relation .
The diagram is obtained from by reversing the directions of all edges in .
v2 𝐯𝟐

v1 v3 𝐯𝟏 𝐯𝟑

v4 𝐯𝟒

G ~
G
Types of Graphs
1. Null Graph
2. Complete Graph
3. Regular Graph
4. Complementary Graph
5. Weighted Graph
6. Bipartite Graph

03/13/2024 50
Isomorphic Graph Bijection means one-one & onto
function
A graph is said to be isomorphic to the graph
if there exists a bijection between the set of vertices and and a bijection
between the set of edges and such that is an edge with end vertices
and in then the corresponding edge has end vertices and in
which correspond to and respectively. If such pair of bijection exist then
it is called a graph isomorphism and it is denoted by .

According to the definition of isomorphism we note that any two vertices in one
graph which are joined by an edge must have the corresponding vertices in the
other graph also joined by an edge and hence a bijection is exists between the
edges as well.
Example of Isomorphic Graph
Arrange vertices from both graphs having same
degree in decreasing order
1 𝑎 Vertex Edge
5 Mapping Mapping
2 𝑒 𝑏 1 →𝑎 ( 1 , 3) →( 𝑎 , 𝑏)
3→𝑏 ( 3 , 5) → ( 𝑏 , 𝑐)
5→𝑐 ( 5 , 2) →( 𝑐 , 𝑑 )
4 3 2→𝑑 (2 , 4 ) →( 𝑑 , 𝑒 )
G1 𝑑 𝑐
G2 4→𝑒 ( 4 , 1 ) → ( 𝑒 , 𝑎)
Here vertex mapping and edge mapping both are one-one and onto (bijective).
Hence, there exists a bijection between set of vertices and set of edges.
and are isomorphic. i.e. .
Arrange vertices from both graphs having same
degree in decreasing order
Example of Non-Isomorphic Graph
𝟏 𝐯𝟏 Vertex Edge
Mapping Mapping
1 →𝑣 1 ¿ 1 , 2>→<𝑣 1 , 𝑣 2> ¿
2 → 𝑣 2 ¿ 2 , 3>→< 𝑣 2 , 𝑣 3 > ¿
𝟑 𝐯𝟑
𝟐 𝐯𝟐 3 → 𝑣 3 ¿ 𝟑 , 𝟏>↛ <𝒗 𝟑 , 𝒗 𝟏> ¿
G1 G2
Here and both has same number of vertices and edges but is not
isomorphic to . i.e. . Because .
Example of Isomorphic Graph
Arrange vertices from both graphs having same
degree in decreasing order
4 u3 u4 Vertex Edge
Mapping Mapping
2 3 1 →𝑢 3 ¿ 1 , 3>→<𝑢 3 ,𝑢 4 >¿
2 →𝑢 1 ¿ 1 , 2>→<𝑢3 , 𝑢1 >¿
3 → 𝑢4 ¿ 2 , 4 >→<𝑢 1 , 𝑢2 >¿
1 u2 u1
G1 G2 4 →𝑢 2 ¿ 3 , 4> →< 𝑢4 , 𝑢2 >¿

Here vertex mapping and edge mapping both are one-one and onto (bijective).
Hence, there exists a bijection between set of vertices and set of edges.
and are isomorphic. i.e. .
Properties of Isomorphic Graph
(1) Two isomorphic graphs must have the same number of vertices.
(2) Two isomorphic graphs must have the same number of edges.
(3) Two isomorphic graphs must have an same number of vertices with given degree.
Note Above properties are necessary properties if two graphs becomes isomorphic.
But it is not sufficient.
Example
Here in and , above three properties
are satisfied. But they are not
isomorphic.

G H
Method 2 Example (a)
Question Check whether the following pair of graphs and are isomorphic or not
with
2 𝒆𝟒 3
description. 𝑏 𝑑 𝑓
𝒆𝟏 𝒆𝟓
𝒆𝟔
𝒆𝟐
1 4𝒆 ′

𝒆𝟐 𝒆

𝟓
𝒆𝟖

𝒆𝟗

𝒆𝟕 𝟏 ′
𝒆 𝟑𝒆 ′ 𝒆𝟔

𝒆𝟑 𝒆𝟖 𝟒

𝒆𝟕
𝑎 𝑐 𝑒
𝒆𝟗
6 5
G H
Method 2 Example (a)(continue)
Solution Vertex Edge Mapping
Mappin
1 →𝑎
g 𝑒1 → 𝑒1

𝑒 6 →𝑒′
6
2→𝑏 𝑒2 → 𝑒2

𝑒 7 →𝑒

7
3→𝑐 ′
𝑒 3 →𝑒 3 𝑒 8 →𝑒 ′
8
4→𝑑 ′
𝑒4 → 𝑒4 𝑒 9 →𝑒 ′
9
5→𝑒 𝑒5 → 𝑒5

6→ 𝑓
Here vertex mapping and edge mapping both are one-one and onto (bijective).
Hence, there exists a bijection between set of vertices and set of edges.
and are isomorphic. i.e. .
Method 2 Example 2
Question Draw all possible different simple digraphs having three vertices and up
to
isomorphism. Show that there is only one digraph with no edges, one
with
one edge, four with two edges, four with three edges, four with four
edges,
one with five edges & one with six
edges.
Solution one digraph with no one digraph with one
edge edge
Method 2 Example 2(continue)
Four digraphs with two edges Four digraphs with three edges
Method 2 Example 2(continue)
Four digraphs with four One digraph with five
edges edges

One digraph with six edges

You might also like