0% found this document useful (0 votes)
8 views75 pages

Notes-UNIT V - Graph Theory

Graph theory studies discrete structures consisting of vertices and edges, applicable in various fields such as chemistry, physics, and computer science. It includes definitions of different types of graphs, such as simple, regular, and bipartite graphs, along with concepts like vertex degree and the handshaking theorem. The document also provides examples and practice problems to illustrate the principles of graph theory.

Uploaded by

darkclown429
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)
8 views75 pages

Notes-UNIT V - Graph Theory

Graph theory studies discrete structures consisting of vertices and edges, applicable in various fields such as chemistry, physics, and computer science. It includes definitions of different types of graphs, such as simple, regular, and bipartite graphs, along with concepts like vertex degree and the handshaking theorem. The document also provides examples and practice problems to illustrate the principles of graph theory.

Uploaded by

darkclown429
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/ 75

UNIT V - GRAPH THEORY

Introduction

Graphs are discrete Structures consisting of vertices and edges. The


graph models can be used to represent almost every problem involving a
discrete arrangements of objects where we are not concerned with their
internal properties but with the inter-relationship. Graph theory is related
with many real field applications.

Graph Theory in Various fields


1. Chemistry - Chemical bonding [isomorphism]
2. Physics - Electrical Networks - planar graph
3. Computer - Networks
4. Biology - DNA Analysis
5. Transport - Road maps and routing

Examples

 Computer networks

 Distinguish between two chemical compounds with the same


molecular formula but different structures

 Solve shortest path problems between cities ,terminals

 Scheduling exams and assign channels to television stations

 Traffic network design, Finding cure for mental illness, designing


electrical networks, deciding on facility location.

Basic Definitions
A graph is any collection of Vertices (Dots) and Edges (Arcs/Lines)
that join the points.

Notation: Graph G =(V, E) or G(V,E), consists set of vertices denoted by


V, or by V(G)={v ,v ,v …..} and set of edges E, or E(G)={e ,e ,e …}.
1 2 3 1 2 3

[G(5, 7)] means vertices =5, edges=7

V(G) means vertex set, E(G) means edge set


Directed edge or Digraph: Ordered pair of vertices represented as (u,
v) directed from vertex u to v.

u v
Disregards any sense of dir

Undirected edge: Unordered pair of vertices represented as {u, v}.


ection and both end vertices can be interchanged. uv and vu both
represents the edge

u v

uv - edge (v,u)- directed edge, {v,u}-undirected

Loop or self loop: A loop is an edge whose end points are equal i.e., an
edge joining a vertex to itself is called a loop. Represented as {u, u} =
{u}.

Multiple Edges or parallel edges: Two or more edges joining the same
pair of vertices.

Isolated vertex : A vertex which is not adjacent to any other


vertex.(i.e., which is not connected by an edge to any other vertex).

Pendent vertex: If a vertex is incident with only one edge, it is called


pendent vertex.
In the above diagram, ‘x’ is the isolated vertex and ‘y’ is the pendent
vertex.

Adjacent vertices: Two vertices are adjacent if they are the endpoints of
an edge.

Here A and B are adjacent but A and D are not adjacent.

Adjacent edges: Two edges connected by a common vertex


AB and BD are adjacent, but AB and CD are not adjacent edges

Finite graph : A graph whose vertex set and edge set are finite.
Null graph : A graph whose vertex set and edge set are empty.
Empty graph : In a graph vertices exists, but no edges exits
All vertices are isolated vertices, then it is an empty graph
Pseudo graph : A graph in which loops and parallel edges are allowed.
Simple graph : A graph in which loops and parallel edges are
not allowed
Note: Graphs generally means , it is simple graphs.
Degree of a vertex
The degree of a vertex in an undirected graph is the number of
edges incident with that vertex.
[count the number of edges connected to a vertex]

In other words, you can determine the degree of a vertex in a displayed


graph by counting the lines that touch it.

The degree of the vertex v is denoted by deg(v).


Note :
1) A loop at a vertex contributes twice to the degree of that vertex.
2) Degree of a Pendant Vertex =1
3) Degree of a Isolated Vertex = 0

deg (u )=3 deg(v)=4 deg(w)=4 (since self loop is there)

deg(x) =0 (isolated vertex ) deg(y) =1 (pendent vertex)

Degree of a vertex in Directed graphs

u v

u – Initial vertex, v – Terminal vertex

For the edge (u, v), u is adjacent to v OR v is adjacent from u


In-degree (deg- (u)) or d-:

number edges coming towards the vertex number of edges for which
u is terminal vertex.

Out-degree (deg+ (u)) or d+:

Number of edges going away from the vertex

number of edges for which u is initial vertex.

In the above diagram, For V={u, v, w}, E={ (u, w), ( v, w), (u, v) },

deg-(u)=0, deg+(u)=2,

deg-(v)=1, deg+(v)=1,

deg-(w)=2, and deg+(w)= 0

Note:

1. A vertex with zero indegree is called a source vertex.

2. A vertex with zero outdegree is called a sink vertex

In the above graph source vertex =u, sink vertex =w

Types of graphs

I) Simple graphs - Graph without self loops and parallel edges

i) Regular graph

ii) Complete graph

iii) Bipartite graph

iv) Complete Bipartite graph

II) Multi graphs - Graph with self loops and (OR) parallel edges
Simple graphs

A graph in which there is only one edge between a pair of vertices is


called a simple graph. i.e., it has no loops or multiple edges.

This is not simple graph since it has multiple edges and loops.

Regular graph

In a simple graph if all vertices are of same degree, then it said to be


regular graph.
a b

c b

Since d(a)=d(b)=d(c)=d(d)=3

regular graph with degree 3


complete graph Kn

The complete graph on n vertices, denoted by Kn, is the simple graph


that contains exactly one edge between each pair of distinct vertices.

That is, a simple graph whose vertices are pairwise adjacent.

[each vertex is connected to all other vertices]

Try to draw complete graph with 6 vertices

Note:

1. All complete graphs are regular graphs

2. In a complete graph of n vertices then deg(v) =n-1

Bipartite Graph

A simple graph is called bipartite if its vertex set V can be partitioned


into two disjoint nonempty sets V1 and V2 such that every edge in the
graph connects a vertex in V1 with a vertex in V2. (So that no edge in G
connects either two vertices in V1 or two vertices in V2).

v1

v2
Complete bipartite graph Km,n

The complete bipartite graph Km,n is the graph that has its vertex set
partitioned into two subsets of m and n vertices, respectively. Two
vertices are connected if and only if they are in different subsets.
v1

v2

Note : The number of edges in a complete bipartite graph with ‘n’


𝑛2
vertices is atmost .
4

Multigraph

G(V,E), consists of set of vertices V, set of Edges E and a function f


from E to {{u, v}/ u, v ϵ V, u ≠ v}. The edges e1 and e2 are called
multiple or parallel edges if f (e1) = f (e2)

Example: V = {u, v, w}, E = {e1, e2, e3}


The Handshaking theorem

If G  (V , E ) is an undirected graph with e edges, then  deg(v )  2e .


i i

The sum of the degrees of all the vertices of an undirected graph is twice
the number of edges of the graph and hence even.

Result:

The number of vertices of odd degree in an undirected graph is even.

the no. of odd degree vertices in a graph is an even no.

Problems:

If all the vertices of an undirected graph are each of odd degree k, show
that the number of edges of the graph is a multiple of k.

Soln.

Since the number of vertices of odd degree in an undirected graph is


even, let it be 2𝑛. Let the number of edges be 𝑛𝑒 . Then by the hand-
shaking theorem, ∑2𝑛
𝑖=1 deg(𝑣𝑖 ) = 2𝑛𝑒 .

i.e., ∑2𝑛
𝑖=1 𝑘 = 2𝑛𝑒 or 2𝑛𝑘 = 2𝑛𝑒

∴ 𝑛𝑒 = 𝑛𝑘

i.e., the number of edges is a multiple of k.


Practice Problems:

Verify the hand shaking theorem for the following graphs

a) A B C

D F
E
A
V1
b) V2 V5

V3 V4

a) No. of vertices =6
No. of edges = 9
sum of the degrees of all the vertices = 2* number of edges

deg(A) =2 , deg(B) =5, deg(C) =3, deg(D) =3, deg(E) =3, deg(F) =2
LHS =  deg( v )  2  5  3  3  3  2  18
i i
RHS = 2* No, of edges = 2*9 =18
Hence handshaking theorem is verified.

b) vertices=5, edges =8
d(v1) =4, d(v2) =5 d(v3) =2, d(v4)=2, d(v5)=3
Sum of degree of all vertices= 16
2*e =2*8 =16 Hence handshaking theorem is verified.
c) If the a graph in which 2 vertices having degree 3 and remaining
vertices are having degree 2 and the total no. of edges 21 then how many
vertices are there?
sum of the degrees of all the vertices = 2* number of edges
(2*3)+(x*2) =2*e =2*21 =42
6+2x =42
2x =42-6=36
x =18 remaining vertices
no. of vertices = 18+2 =20

5) The number of vertices in a simple graph G which has 20 edges and

each vertex is of degree 4 is

sum of the degrees of all the vertices = 2* number of edges


x*4 =2e=2*20=40

x =10

No.of vertices =10

Problems

1) Find the number of vertices, the number of edges and the degree of
each vertex in the following undirected graph and verify handshaking
theorem.

Solution
The number of vertices = 6
The number of edges = 9
deg(A)= 2 ; deg(B)=4; deg(C)=4; deg(D)=3; deg(E)=4 ; deg(F)=1
sum of degree of all vertices = 18
2*e=2*9 =18
hence handshaking theorem is verified
2) Find the number of vertices, the number of edges and the degree of
each vertex in the following undirected graph and verify handshaking
theorem.

Solution
The number of vertices =5
The number of edges =13
deg(A)= 6 ; deg(B)=6; deg(C)=6; deg(D)=5; deg(E)=3

3) Find the in-degree and out-degree of of each vertex of each of the


following directed graphs also verify that the sum of the in-degrees or the
out-degrees equals the number of edges

Solution
𝑑𝑒𝑔− (𝐴) = 2, 𝑑𝑒𝑔− (𝐵) = 1, 𝑑𝑒𝑔− (𝐶) = 2, 𝑑𝑒𝑔− (𝐷) = 3, 𝑑𝑒𝑔− (𝐸) = 0
𝑑𝑒𝑔+ (𝐴) = 1, 𝑑𝑒𝑔+ (𝐵) = 2, 𝑑𝑒𝑔+ (𝐶) = 1, 𝑑𝑒𝑔+ (𝐷) = 1, 𝑑𝑒𝑔− (𝐸) = 3
∑ 𝑑𝑒𝑔− (𝐴) = ∑ 𝑑𝑒𝑔+ (𝐴) = 8=the number of edges.
4) Find the in-degree and out-degree of of each vertex of each of the
following directed graphs also verify that the sum of the in-degrees or the
out-degrees equals the number of edges

Solution
𝑑𝑒𝑔− (𝐴) = 5, 𝑑𝑒𝑔− (𝐵) = 3, 𝑑𝑒𝑔− (𝐶) = 1, 𝑑𝑒𝑔− (𝐷) = 4 𝑑𝑒𝑔+ (𝐴) = 2, 𝑑𝑒𝑔+ (𝐵) =
3, 𝑑𝑒𝑔+ (𝐶) = 6, 𝑑𝑒𝑔+ (𝐷) = 2
∑ 𝑑𝑒𝑔− (𝐴) = ∑ 𝑑𝑒𝑔+ (𝐴) = 13 =the number of edges.

5) For each of the following degree sequences find if there exists a graph.
In each case either draw a graph or explain why no graph exists.

a) 4,4,4,3,2
b) 5,5,4,3,2,1
c) 3,3,3,3,2
d) 3,3,3,3,3,3
e) 5,4,3,2,1,1
Solution
a) Sum of the degrees of all the vertices = 17 which is an odd number.
This is impossible.
Handshaking: Sum of degree of all vertices = 2 e
Hence no graph exists with the given degree sequence.
b) 5,5,4,3,2,1
There are 6 vertices. Hence a vertex of degree 5 in the graph must be
adjacent to all other vertices.
As there are two vertices each of degree 5 all other vertices should be of
degree at least 2. But the given degree sequence contains a 1.
Hence no graph is possible with the given degree sequence.
c) 3,3,3,3,2

A simple graph with the given degree sequence is possible.

The vertices B, C, D, E are of degree 3 while the vertex A is of degree 2.

d) 3,3,3,3,3,3
A simple graph with the given description is possible.

e)

Only a multigraph is possible with the given degree sequence.


The degrees of A, B, C, D, E, F are respectively 5, 2, 4, 3, 1,1
6) Determine which of the following graphs are bipartite and which are
not. If a graph is bipartite, state whether it is completely bipartite.

Solution:
a)

Let us try partitioning of the vertices into two subsets satisfying the
conditions of a bipartite graph.
v1= {A,C,F}
v2 ={B,D,E}
The vertices of 𝑉1 are connected by edges to the vertices of 𝑉2 but the
vertices A, F, C of the subset 𝑉1 are connected by the edges CF
Hence the graph(a) is not a bipartite graph.

b) Taking 𝑉1 = (𝐴, 𝐶)𝑎𝑛𝑑 𝑉2 = (𝐵, 𝐷, 𝐸) the conditions required for a bipartite


graph are satisfied.

v1= {A, C}

v2={B, D, E}
Hence the given graph(b) is bipartite.
Now for a bipartite graph to be completely bipartite, each vertex of the
subset 𝑉1 must be adjacent to every vertex of 𝑉2.
Both A and C are adjacent to each of B, D, E
Hence the graph(b) is a completely bipartite graph.

c) Taking 𝑉1 = (𝐴, 𝐵, 𝐶) and 𝑉2 = (𝐷, 𝐸, 𝐹) it is easily seen that the graph(c) is


a bipartite graph.
But it is not a completely bipartite graph as each vertex of 𝑉1 is not
connected to every vertex of 𝑉2. (i.e.,The vertices A and F as well as C
and D are not connected)

d) Taking 𝑉1 = (𝐴, 𝐶, 𝐸, 𝐺) and 𝑉2 = (𝐵, 𝐷, 𝐹, 𝐻) it is easily seen that the


graph(d) is a bipartite graph.
But it is not a completely bipartite graph as there is no edge between A
and F, between C and H, between E and B and between G and D.

Representation of graphs

Incidence and Adjacency Matrices

Incidence (Matrix): Most useful when information about edges is


more desirable than information about vertices.[Relation with
vertex and the edge]

Adjacency (Matrix/List): Most useful when information about the


vertices is more desirable than information about the edges. []

Incidence matrix

G = (V, E) be an undirected graph. Suppose that v1, v2, v3, …, vn


(totally n vertices ) are the vertices and e1, e2, …, em (totally m
edges ) are the edges of G. Then the incidence matrix with respect
to this ordering of V and E is the nxm matrix
1 𝑤ℎ𝑒𝑛 𝑒𝑑𝑔𝑒 𝑒𝑗 𝑖𝑠 𝑖𝑛𝑐𝑖𝑑𝑒𝑛𝑡 𝑤𝑖𝑡ℎ 𝑣𝑖
MI = [m ij], where 𝑚𝑖𝑗 = {
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
It can also be used to represent,
Multiple edges: By using columns with identical entries, since
these edges are incident with the same pair of vertices
Loops: By using a column with exactly one entry equal to
1, corresponding to the vertex that is incident with the loop.

Example: G = (V, E)

e1 e2
1

e3

Example: What is the incidence matrix M for the following graph G


based on the order of vertices a, b, c, d and edges 1, 2, 3, 4, 5, 6?
Solution:

1 2 3 4 5 6
a
1 a 1 1 0 0 1 0
2 b 1 0 1 0 0 0
M 
b c 0 0 0 1 1 1 
 
d 0 1 1 1 0 0 
d 3
5

4
c

Note : Incidence matrices of directed graphs contain

1) two 1s per column for edges connecting two vertices

2) one 1 per column for loops.


Adjacency matrix (Always a square matrix)

 There is an N x N matrix, where |V| = N , the Adjacency Matrix

A = [aij] of order N

For undirected graph

 For directed graph

Note:

 Adjacency is chosen on the ordering of vertices. Hence, there as are


as many as n! such matrices.
 The adjacency matrix of simple graphs are symmetric (aij = aji) (why?)
A = AT
 When there are relatively few edges in the graph the adjacency matrix
is a sparse matrix

Using sparse matrices to store data that contains a large number of zero-valued
elements can both save a significant amount of memory and speed up the processing of
that data. sparse is an attribute that you can assign to any two-dimensional MATLAB®
matrix that is composed of double or logical elements.

 Directed Multigraphs can be represented by using aij = number of
edges from vi to vj
Example: Undirected Graph G (V, E)

Example: Directed Graph G (V, E)


Example: What is the adjacency matrix AG for the following graph G
based on the order of vertices a, b, c, d ?

Solution: 0 1 1 1
1 0 0 1
AG   
1 0 0 1
 
1 1 1 0

Note: Adjacency matrices of undirected graphs are always symmetric.

Practice Problems

1) Express the following graphs by adjacency matrices.

A B C D E
A
B
C
D
E
a) ----------Ans :

In Simple graph Degree of the vertices can be given by counting no. of ones in each row

d(A) =2 d(B )=3 ,.......

Since all the leading diagonals are zero entries then there is no self loop

A B C D
A
B
C
D
b) ----------------Ans :

Since all the leading diagonals are 1's entries then there is a self loop.

In a simple graph, numberof one's =d(vi)


c) ------------------------Ans :

2) Draw the graphs represented by the following adjacency matrices.


A B

A
B

a) -------------------Ans :

b) -------------------Ans:

c) --------------------Ans :

3) Represent the following graphs by incidence matrices.

a) -----------------Ans:
b) ---------Ans:

c) -------Ans:

4) Draw the graphs represented by the following incidence matrices

a) -----------Ans:

b) ------------Ans:

e3

c) ----------Ans :

**********************************************************************************
Matrix Representation of Graphs
When G is a simple graph with n vertices v1, v2, v3, …. vn, the matrix A (or
1 , 𝑖𝑓 𝑣𝑖 𝑣𝑗 𝑖𝑠 𝑎𝑛 𝑒𝑑𝑔𝑒 𝑜𝑓 𝐺
AG)[aij], where 𝑎𝑖𝑗 = { is called the adjacency matrix
0, 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
of G.

For example, if G is the graph given in the following figure, then the
adjacency matrix A is

V1 V2 V3 V4 V1 V2
V1

V2

V3

V4
V4 V3
G

The following basic properties of an adjacency matrix are obvious:

1. Since a simple graph has no loops, each diagonal entry of A,

viz., 𝑎𝑖𝑗 = 0, for i = 1,2,3, ….n.

2. The adjacency matrix of simple graph is symmetric, viz., 𝑎𝑖𝑗 = 𝑎𝑗𝑖 , since
both of these entries are 1 when 𝑣𝑖 and 𝑣𝑗 are adjacent and both are 0
otherwise. Conversely, given any symmetric zero-one matrix A which
contains only 0’s on its diagonal, there exists a simple graph G whose
adjacency matrix is A.

3. deg(𝑣𝑖 ) is equal to the number of 1’s in the ith row or ith column.

Walk (Both vertices and edges can be repeated)

A walk is a sequence of vertices and edges of a graph.

Here the vertices and edges can be repeated.


Example: V1-V2-V3-V4-V2-V1-V3 is a walk
V1 V2
V4

V3 V5
.
Open walk
A walk is said to be an open walk if the starting and ending vertices are
different i.e. the origin vertex and terminal vertex are different.
Closed walk
A walk is said to be a closed walk if the starting and ending vertices are
identical i.e. if a walk starts and ends at the same vertex, then it is said
to be a closed walk.
In the above diagram:
v1-v2-v3-v4-v5-v3 is an open walk.
v1-v2-v3-v4-v5-v3-v1 is a closed walk.
Trail
Trail is an open walk in which no edge is repeated.Vertex can be repeated.

V1 V2
V4

V5

V3 V7

V6
V9

V8
Here v1-v3-v8-v6-v3-v2 is trail
v1-v3-v8-v6-v3-v2-v1 is a closed trail.

Circuit -closed trail


Traversing a graph such that not an edge is repeated but vertex can be
repeated and it is closed also i.e. it is a closed trail.
Vertex can be repeated.
Edges are not repeated.

V2
V4
V1

V3

V6
V5

Here v1-v2-v4-v3-v6-v5-v3-v1 is a circuit of length =7

Note.
Circuit is a closed trail.
These can have repeated vertices only.

Path

In a graph the sequence of vertices and edges such that no vertex is


repeated and no edge is repeated is called a path.

It is a trail in which neither vertices nor edges are repeated i.e. if we


traverse a graph such that we do not repeat a vertex and nor we repeat
an edge. As path is also a trail, thus it is also an open walk.
Here Vertex not repeated and Edge not

V1 V4
V2

V5

V3 V7

V6
V9

V8
repeated.

v1-v2-v3-v1

v1-v2-v4-v5-v7-v8-v3-v1: length is 7

Cycle -closed path Traversing a graph such that we do not repeat a


vertex nor we repeat a edge but the starting and ending vertex must be
same i.e. we can repeat starting and ending vertex only then we get a
cycle.
Here, Vertex not repeated and Edge not repeated

In the above diagram, v1-v2-v4-v3-v1 is a cycle.

Length The length of a walk, trail, path or cycle is its number of edges.

Isomorphic Graphs: Checking the similarity between the


graphs
Two Graphs G1 and G2 are said to be isomorphic to each other, if there
exists a one-to-one correspondence between the vertex sets which
preserves adjacency of the vertices.

A graph G1 = (V1,E1) is isomorphic to the graph G2 = (V2,E2), if


there is a one to one correspondence between the vertex sets V1 and V2
and between the edge sets E1 and E2 in such a way that if e1 is incident
on u1and v1 in G1, then the corresponding edge e2 in G2 is incident on u2
and v2 which correspond to u1 and v1 respectively. Such a correspondence
is called graph isomorphism.

Main conditions to be considered for isomorphism:

(Necessary conditions)

1. The same number of vertices on both graphs G1 and G2.

2. The same number of edges on both graphs G1 and G2.

3. The corresponding vertices with the same degree on both graphs G1

and G2.

This property is called an invariant with respect to isomorphic graphs.

If these conditions are satisfied in two graphs, we can say that the two
graphs G1 and G2 are isomorphic graphs.

However, these conditions are not sufficient for graph isomorphism.

For better result, consider the following theorems:

(Sufficient Conditions)

Theorem 1:

Two graphs are isomorphic, if and only if their vertices can be labelled

in such a way that the corresponding adjacency matrices are equal.

Theorem2:

If two graphs are isomorphic, they will contain circuits of the same

length k, where 𝑘 > 2.

Example 1:

Examine whether the two graphs are isomorphic.


A 1 B V1 e1 V4
11 11
11
2 4 e2
e4
11
e3
C D V3 V2
3
11 11
G1 G2

Necessary conditions

Soln.

1. The number of vertices in both graphs G1 and G2 are same. i.e., 4

vertices.

2. The number of edges in both graphs G1 and G2 are same. i.e., 4 edges.

3. The corresponding vertices in both graphs G1 and G2 are of same

degree. i.e., degree 2.

Sufficient condition

4. To make strong that two graphs to be isomorphism, let us consider

the adjacency matrix of two graphs:


A 1 B V1 e1 V4
11 11
11
2 4 e2
e4
11
e3
C D V3 V2
3
11 11
G1 G2

A B C D
A 0 1 1 0
B 1 0 0 1
Adjacency matrix of G1 is
1 0 0 1
C
0 
D
 1 1 0

V1 V2 V3 V4

V1
0 1 1 0
V2 1 0 0 1
1 1
Adjacency matrix of G2 is
0 0
0 
V3

V4
 1 1 0

The two adjacency matrices are same. Hence two graphs are
isomorphism.

Example 2:

Examine whether two graphs are isomorphism:

V6 V6 ‘

V1 V2 V3 V4 V1 ‘ V2 ‘ V3 ‘ V4 ‘ V5 ‘
11 11 11
V5
G1 G2
Soln.

1. The number of vertices in both graphs G1 and G2 are same.

i.e., 6 vertices.

2. The number of edges in both graphs G1 and G2 are same. i.e., 5 edges.

3. The corresponding vertices in both graphs G1 and G2 are of same

degree. d(v1)=, -----

i.e., There are 3 vertices namely v1, v5, v6 (v1’, v5’, v6’) each of degree 1;

2 vertices namely v2, v3 (v2’, v4’) each of degree 2;

1 vertex namely v4 (v3’) of degree 3.

Thus, all the three conditions are satisfied but the two graphs G1 and G2
are not isomorphic because the vertices v2 and v3 are adjacent in G1,
whereas the corresponding vertices v2’ and v4’ are not adjacent in G2.

Problems:
1. Determine whether the following pairs of graphs are isomorphic.

Exhibit the isomorphism explicitly or prove that it does not

exist.

Soln.

1. The graphs G1 and G2 both have 5 vertices.


2. The graphs G1 and G2 both have 8 edges.
3. d(u1)=3, d(u2)=4 d(u3)=2 d(u4)= 4, d(u5)=3
d(v1)=3 d(v2)=2, d(v3)=4, d(v4)= 3, d(v5)=4

Thus, the above two graphs agree with respect to the necessary

conditions.

4. Still, we cannot conclude that the two graphs are isomorphic, unless

we prove that their adjacency matrices are the same.

We assume arbitrarily that the vertex 𝑢1 corresponds to 𝑣1 , 𝑢2

corresponds to 𝑣5 and 𝑢3 corresponds to 𝑣2 and find the adjacency

matrices of the two graphs. If this choice of corresponding vertices

does not lead to identical adjacency matrices, we may try another

choice using the adjacency of vertices and degrees as a guide.

Now for the choice of corresponding vertices given above, the

adjacency matrices of the two graphs are given below:


Now the adjacency matrices of G1 and G2 are same, the two graphs are
isomorphic.

b) V1
11

u1 u2
11
V2
V5
11
u5 11
11

u4 u3 V4 V3
11 G1 11 11 G2 11
11 11

Soln.

1. The graphs G1 and G2 both have 5 vertices.


2. The graphs G1 and G2 both have 7 edges.
3. In the above graph G1, the vertex u2 is of degree 2, and all the other

vertices are of degree 3 each. In the other graph G2, 2 vertices v1 and

v3 are of degree 2, 2 vertices v4and v5 are of degree 3 and the vertex

v2 is of degree 4. Though, there are equal number of vertices and

equal number of edges in the two graphs, the degree of vertices are
not invariant. Hence the two graphs are not isomorphic.

2. Determine whether the graphs shown in the following figures are

isomorphic.

A B O P
F 1 S
E
1 T

1
H G V 1
U
D C R Q
G1 G2
11 11
Soln.

1. The graphs G1 and G2both have 8 vertices


2. The graphs G1 and G2both have 10 edges.
3. Also they both have 4 vertices each of degree 2 and 4 vertices each of
degree 3. Thus, the necessary conditions are satisfied in the graphs
G1 and G2.
4. However, the graphs are not isomorphic as analysed below:
Deg(A)=2 in G1.
Hence, A must correspond to either P, Q, T or U, which are of degree 2
each in G2.
Now each of the vertices P,Q,T and U is adjacent to another vertex of
degree 2.
Viz., P is adjacent to Q, Q is adjacent to P etc. But A is not adjacent to
any vertex of degree 2 in G1.
Hence, the two graphs G1 and G2 are not isomorphic.

3.Using cycles, establish the isomorphism of the two graphs.


A B V1 V2

D C V4 V3
G1 G2

4. Let us consider, the cycles of above two graphs:

In graph G1,

cycle of length 3:

G1: A-B-D-A, A-C-D-A

G2: V1-V2-V3-V1, V1-V4-V3-V1

the number of cycles of length 3 is 2.

cycles of length 4:

G1:A-B-D-C-A, G2: V1-V2-V3-V4-V1

Hence two graphs G1and G2 are isomorphism.


4.Examine whether two graphs are isomorphic.

u2 u3

u1 u4

u6 u5
G1

v2 v3

v1
v4

v6 v5
G2

Soln.

1. The two graphs G1 and G2 have 6 vertices each.

2. The two graphs G1 and G2 have 8 edges each.

3. The two graphs G1 and G2 have 4 vertices of degree 3 and 2 vertices of

degree 2.

4. In graph G2, has a circuit of length 3, namely v1-v2-v6-v1, whereas G1

has no circuit of length 3.Hence two graphs are not isomorphism.

5. Examine whether two graphs are isomorphic.


u1 v1

v5
v2
u5 u2

u4 u3 v4 v3
G1 G2

Soln.

1. The two graphs G1 and G2 have 5 vertices each.

2. The two graphs G1 and G2 have 6 edges each.

3. The two graphs G1 and G2 have 2 vertices of degree 3 and 3 vertices of

degree 2.

4. The two graphs G1 and G2 have circuits of length which pass through all
vertices, namely u1-u2-u3-u4-u5-u1 and v5-v3-v2-v1-v4-v5.

In both the circuits, the degree of the ordered vertices are 3,2,3,2,2. The
two graphs are isomorphic as their adjacency matrices are the same.

u1 u2 u3 u4 u5 v5 v3 v2 v1 v4

0
u1
1 1 0 1  0v5 1 1 0 1 
u
12 0 1 0 0 v
1 3 0 1 0 0
𝐴𝐺1 ≡ u
31 1 0 1 0 𝐴𝐺1

≡v 1 2 1 0 1 0

 0 0 1 0 1
  0 0 1 0 1

u v 1
4

u
1
5 0 0 1 0 v
1 4 0 0 1 0

6.Using Circuits, examine whether the following pairs of graphs G1 and

G2 are isomorphic or not.


A v1 v4
a)

B C v2 v3
G1 G2

b)

A D a c

E H e g

F G f h

B C b d
G1 G2

Soln.

a)

1. The two graphs G1 and G2 have 4 vertices each.

2. The two graphs G1 and G2 have 6 edges each.

3. The two graphs G1 and G2 have 4 vertices of degree 3. Hence

conditions for isomorphism are satisfied.

4. Now A-B-D-A, A-C-D-A and A-B-C-A are circuits of length 3 each in G1.

Also A-B-C-D-A, A-B-D-C-A and A-D-B-C-A are the circuits of length 4

each in G1.

Similarly, V1-V2-V4-V1, V1-V3-V4-V1 and V1-V2-V3-V1 are circuits of

length 3 each in G2.

Also V1-V2-V3-V4-V1, V1-V2-V4-V3-V1 and V1-V4-V2-V3-V1 are circuits of

length 4 each in G2.


Hence the two graphs G1 and G2 are isomorphism.

b)

1. The two graphs G1 and G2 have 8 vertices each.

2. The two graphs G1 and G2 have 10 edges each.

3. The two graphs G1 and G2 have 4 vertices each of degree 3 and4

vertices each of degree 2 in G1 and G2.

Hence the necessary conditions for isomorphism are satisfied.

4. Now there is only one circuit of length 4 from A to A, viz., A-B-C-D-A in

G1, but there are two circuits of length 4 each from a to a, namely,

a-b-d-c-a and a-e-g-c-a. Hence the two graphs G1 and G2 are not

isomorphic.

Practice Problems:

1. Examine whether the following pairs of graphs are isomorphic. If not

isomorphic, give the reasons.

u1 V1
a)

V5
u2 u5 V2

u3 u4 V3 V4

G1 G2
A
b) P Q

E B

T R

D C

S
G1 G2

c)

u1 u2 u3 u5 u6 v1 v2 v4 v5 v6
v8
u8

u4 u7 v7
v3
G1 G2

2. Examine whether the following two graphs are isomorphic.

C V8 e12
D 6
11 V7
e8 11
8 7
e6
12 e7
V4 e11
H G V3
2 11 e10
10 11 4 11
e9
e2 V6
3 E 9 5
F V5
e4 11
e3 11 e5
V1
A 1 B e1 V2
11
11
G1 G2
Walk - Path, Cycles- Eulerian graphs -Hamiltonian graphs- Planar
graphs- Euler formula.

Walk

A walk is a sequence of vertices and edges of a graph .

i.e. if we traverse a graph then we get a walk.


Vertex can be repeated
Edges can be repeated

Here 1- 2- 3- 4- 2- 1- 3 is a walk.

Note.
1. Walk can be open or closed.
2. Walk can repeat anything (edges or vertices).

Open walk-A walk is said to be an open walk if the starting and ending
vertices are different i.e. the origin vertex and terminal vertex are
different.
Closed walk-A walk is said to be a closed walk if the starting and ending
vertices are identical i.e. if a walk starts and ends at the same vertex,
then it is said to be a closed walk.
In the above diagram:
1-2-3-4-5-3 is an open walk.
1-2-3-4-5-3-1 is a closed walk.
2. Trail
Trail is an open walk in which no edge is repeated.
Vertex can be repeated

Here 1-3-8-6-3-2 is trail


Also 1-3-8-6-3-2-1 will be a closed trail.

3. Circuit –
Traversing a graph such that not an edge is repeated but vertex can be
repeated and it is closed also i.e. it is a closed trail.
Vertex can be repeated
Edge not repeated

Here 1-2-4-3-6-8-3-1 is a circuit

Note.
Circuit is a closed trail.
These can have repeated vertices only.
4. Path –
It is a trail in which neither vertices nor edges are repeated i.e. if we
traverse a graph such that we do not repeat a vertex and nor we repeat
an edge. As path is also a trail, thus it is also an open walk.
Vertex not repeated
Edge not repeated

5. Cycle –
Traversing a graph such that we do not repeat a vertex nor we repeat a
edge but the starting and ending vertex must be same i.e. we can repeat
starting and ending vertex only then we get a cycle.
Vertex not repeated
Edge not repeated

Here 1-2-4-3-1 is a cycle.


Note.
Cycle is a closed path.
These can not have repeat anything (neither edges nor vertices).

1. Walk : Vertices may repeat. Edges may repeat (Closed or


Open)
2. Trail : Vertices may repeat. Edges cannot repeat (Open)
3. Circuit : Vertices may repeat. Edges cannot repeat (Closed)
4. Path : Vertices cannot repeat. Edges cannot repeat (Open)
5. Cycle : Vertices cannot repeat. Edges cannot repeat
(Closed)

A trail is a walk with no repeated edge.

A path is a walk with no repeated vertex.

Length

The length of a path or cycle is its number of edges.

Examples 1. Find a walk and a path

v1 e4 v4
e8
e6

e3 v5
e1 e5

e7

v2 e2 v3

Walk: v1 e1 v2 e2 v3 e5 v1 e4 v4 e8 v5

Path : v1 e4 v4 e6 v2 e2 v3 e7 v5 : Length = 4
2. Find which of the following vertex sequence are walks and paths.

A B

E
D

a) A-D-E-B-C

Not a path and not a walk, since the edge DE is not in the graph.

b) A-D-B-C-E-A - not a path or walk

c) C-B-D-A-E-C - not a path

d) A-E-B-E -walk, NOT A PATH

e) A-D-B-E - walk, path

3) Find all simple paths from A to F of length 3,4,5 and find the circuits.

B C

A F

D E
E
Path of length 3: 1) A-B-C-F 2) A-D-E-F

Path of length 4: 1) A-B-D-E-F 2)A-D-B-C-F

Path of length 5: 1)A-B-D-E-C-F 2) A-D-B-C-E-F

Circuits : 1) A-B-D-A 2)C-F-E-C 3) B-C-E-D-B

4) A-B-C-E-D-A 5) B-C-F-E-D-B 6) A-B-C-F-E-D-A


4)

Connectedness in undirected graphs

An undirected graph is connected if there is atleast one path between


every pair of distinct vertices of the graph

Disconnected graph: A graph which is not connected is called the


disconnected graph. But it has connected components.

Example

Connected graph - since it is possible to find a path between every pair of


vertices
A
E
F
C

G
D
B

Disconnected graph

A B

C
E
D

Since there is no path between A and D, the graph is disconnected

The connected components are B-A-C and D-E-F.

2) Find all the connected subgraphs of the graph of the following graph G

C D G

A B

F E

Solution.
The connected subgraphss are
a)
C D G

A B

F E

The path from (A-G) is A-B-F-E-D-G


b)

C D G

A B

F E

The path from A-G is A-B-C-F-E-D-G which contains all the vertices of the
original graph.

Result1. If G is connected graph then it has exactly 2 vertices of odd


degree and there is a path joining the 2 vertices.

Result 2. If G is a graph with n vertices and k components then

(𝑛−𝑘)(𝑛−𝑘+1)
Maximum number of edges in G =
2
Example:

If a graph G has 7 vertices and 2 components, then the maximum


(7−2)(7−2+1) 5∗6
number of edges the graph G can have = = = 15
2 2
Connectedness in directed graphs

strongly connected

A digraph is said to be strongly connected if there exists a two way path


between any two vertices.

Unilaterally connected

A digraph is said to be unilaterally connected if there exists a one way


path between any two vertices.

weakly connected

A digraph is said to be weakly connected if there exists atleast a one-way


path between any two vertices if the direction of the edges is disregarded.

Problems:

1. Find which of the following graphs are strongly, weakly and unilaterally
connected.

a)

A B

D C

Strongly connected, since there is a path from each of the possible pair
of vertices, namely (A,B),(A,C),(A,D),(B,C),(B,D),(C,D).

The paths are as follows


(A,B) - A-B; (B,A) - B-D-A
(A,C) - A-C; (C,A) - C-B-D-A
(A,D) - A-B-D; (D,A) - D-A
(B,C) - B-D-C; (C,B) - C-B
(B,D) - B-D; (D,B) - D-C-B
(C,D) - C-B-D; (D,C) - D-C
B)

A D

B C

Unilaterally connected, since there is one way path between the pair of
vertices.

The paths are given below.

(A,B) - A-B; (B,A) - No path from B to A

(A,C) - A-D-C; (C,A) - No path from C to A

(A,D) - A- D; (D,A) - No path from D-A

(B,C) - B-C; (C,B) - No path from C-B

(B,D) - B-D; (D,B) - No path from D-B

(C,D) - C-B-D; (D,C) - No path from D-C

C)

A B

E D

strongly connected, since there is a two way path from all the pairs
vertices

D)
A B

E D

(A,B) -No path ; (B,A) - B-A

(A,C) - No path ; (C,A) - No path

Weakly connected since there is no path between the vertices in directed


graph, but when the direction is not considered then we can able to find
paths between all pair of distinct vertices. Therefore the graph is weakly
connected

Euler trail and circuit


Euler trail
A walk in a graph G is an Eulerian trail if it includes each edge of G
exactly once.
Eulerian circuit
A circuit of a graph G is called an Eulerian circuit if it includes each
edge of G exactly once.
Euler graph
A graph containing an Eulerian circuit is called an Eulerian graph.
Theorem 1.
Necessary and sufficient condition for the existence of Euler
circuit.
A connected graph is an Eulerian graph(ie, contains an Eulerian circuit ) if
and only if the degree of each vertex is even.
Theorem2.
Necessary and sufficient condition for the existence of Euler path
A connected graph contains an Euler trail it has exactly two vertices of
odd degree.
Note: The Euler trail will have the two odd degree vertices as its end
points.
Examples

1) Euler graph

1 b
a d

3
2 4
7

f e
6 c 5

The above graph is an Euler graph as a 1 b 2 c 3 d 4 e 5 c 6 f 7 a


covers all the edges of the graph.

2) Non Euler Graph

Here degree of vertex b and d is 3, an odd degree and violating the Euler
graph condition.

3)
4)

5)

6)
7) Find Euler path and Euler circuit in the following graphs.

a)

B
A

C E
D

b)
B
A

F C

E D

c)

C
A

D
E

d) Konigsberg problem graph

Konigsberg bridge problem


Hamiltonian path and Hamiltonian circuit
Hamiltonian Path in an undirected graph is a path that visits each vertex
exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian
Path such that there is an edge (in graph) from the last vertex to the first
vertex of the Hamiltonian Path.

Hamiltonian graph - A connected graph G is called Hamiltonian graph if


there is a cycle which includes every vertex of G exactly once and the
cycle is called Hamiltonian cycle. Hamiltonian walk in graph G is a walk
that passes through each vertex exactly once.

Dirac's Theorem - If G is a simple graph with n vertices, where n ≥ 3 If


deg(v) ≥ {n}/{2} for each vertex v, then the graph G is Hamiltonian
graph.

Ore's Theorem - If G is a simple graph with n vertices, where n ≥ 2 if deg(x) +


deg(y) ≥ n for each pair of non-adjacent vertices x and y, then the graph G is
Hamiltonian graph.
Examples
1)

In above example, sum of degree of a and c vertices is 6 and is greater than total vertices, 5 using
Ore's theorem, it is an Hamiltonian Graph.
Also a 1 b 2 c 4 e 7 d 8 a is a closed path containing all the vertices of G exactly once.
Non-Hamiltonian Graph

There is no closed path which contains all the vertices exactly once.
3)
A
C
E

B D
F

The Hamiltonian circuit is A-B-C-D-E-F-A


4)

No Hamiltonian path and circuit exists.


5) Check which of the following graphs are Eulerian and Hamiltonian

1)

C D
Eulerian graph since the Euler circuit C-A - B - D-C-E-B-F-C exits.

Non Hamiltonian, since no Hamiltonian path exists

2)

B C

A E

Non Eulerian graph, Since there are 4 vertices (A,B) having degree 3 .

Hamiltonian graph, since there is a Hamiltonian circuit A-B-C-D-E-A


which includes all the vertices

6)
Planar graph representation
A graph G is said to be planar if there exists some geometric
representation of the graph, which can be drawn on a plane such that no
two of its edges intersect . That is, the edges never cross over.

Non planar graph

A graph that cannot be drawn on a plane without cross over between the
edges is called a non planar graph.
Example.

1) Planar graph with 3 vertices (K3- complete graph)

2) Planar graph with 4 vertices (K4 - complete graph of 4 vertices)

A
B
A B

C D C D
Original graph planar representation

3)

original graph
planar graph
Non-Planar graph -problems

4) K5 - complete graph with 5 vertices

K5 -Kuratowski's First graph - Non planar graph of minimum number of


vertices

A
A

B C
B C

D E

D E crossing

Original graph non planar representation

5) K3,3 - complete Bipartite graph of 6 vertices

K3,3 -Kuratowski's second graph - Non planar graph of minimum


number of edges

A B B
C
A C

E F
E D
D F
cross
Original graph non planar representation
3)

Non Planar graph

A B

F
C

E D crossing

Region or face- region can be defined for a planar graph

Bounded Region: A region is a closed portion bounded by the edges of a


planar graph.

Unbounded region

The portion that lies outside the graph is referred as the unbounded
region.
Region in planar graphs

A planar representation of a graph splits the plane into regions including


an unbounded region

Example. 6 regions

R4
R2

R3
R1
R5

R6

Euler's formula

Let G be a connected planar simple graph with V vertices , E edges and


with f regions of its planar representation.

The number of regions f = E - V +2

Example

1) A connected graph with 20 vertices, each of degree 3. Into how many

regions does a planar representation of this graph ?

Sol. Given V = 20,

Since each vertex is of degree 3,

it is understood that 3*V = 3*20 =60


By the theorem

sum of degree of all vertices = 2 [number of edges]

[handshaking theorem]

60 = 2E implies E = 30 edges

Therefore by Euler's formula

f = E - V +2

= 30 - 20 +2

f= 12 regions

2) Verify Euler's formula for the following graph.

R1

R2

v=5, E=5 , f=2

Regions f =2, V = 5, E = 5 Euler's formula f = E - V +2

LHS =2, and RHS = 5 -5 +2 =2. Hence proved

3) Can 5 houses can be connected to two utilities without cross over?

Answer

utilities

utilities
1. Verify Euler’s formula for the following graphs:
(a)

(b)

2. Can the following graphs be drawn as planar graphs? If so, verify Euler’s formula
(a)

(b)

(c)
Shortest path Algorithm
DIJKSTRA’S ALGORITHM

Introduction

To find the length (or weight) of the shortest path between two vertices , say, ‘a’
and ‘z’ in a weighted graph, the algorithm assigns numerical labels to the vertices
of the graph by an iterative procedure.

At any stage of iteration, some vertices are labelled temporarily (that are not
bracketed) and others will have permanent labels (that are bracketed). The label
of the vertex V is denoted by L(V).

Procedure:

1.Iteration 0: Let V0 denote the set of all vertices of the graph.


i) Starting vertex is assigned the permanent label (0)
ii) other vertices with temporary label (∞) each.
Let V1= V0-{v0*}, v0* is the starting vertex which has been assigned a
permanent label.

2.Iteration1:Let V1 be the set of all vertices v1 which are same as v0 excluding v0*.
For elements of V1 that are adjacent to v0*, the temporary lebels are revised using
L(v1)=L(v0*)+W(v0*v1)
L(v0*)=0, W(v0*v1) is weight of the edge v0*v1. For other elements of V1,
previous temporary labels are maintained.
Let v1* be the vertex among the v1‘s for which L(v1) is minimum. If there is a tie
for choice of v1*, it is broken arbitrarily.
Now L(v1*)is given a permanent label.
Let V2= V1-{v1*}={v2}

3.Iteration i: For elements of Vi, that are adjacent to vi-1* , the temporary labels are
revised using L(vi)=L(vi-1*)+W(vi-1*vi) and for other elements of vi, previous
temporary labels are not altered.

** The procedure is stopped when final vertex Z is assigned a permanent label even
though some vertices might not have been assigned permanent labels.
*The permanent label of Z is the length of the shortest path from a to Z.
Problems:
1. Find the shortest path from the vertex A to F using Dijkstra’s Algorithm.

Iteratio Iteration Details Remarks


n
Number

0 V0 : A B C D E F A gets permanent label,


L(A*)=0 is bracketed
L(V0): (0)
1 V1 : A* B C D E F B and C are adjacent vertices to A*
L(V1): - (2) 3 ∞ L(B)= L(A*)+W(A*B)=0+2=2; L(C)= L(A*)+ W(A*C)=0+3=3
Min{L(B),L(C)}=min{2,3} implies L(B)=2;
Thus, L(B*)=2 is bracketed.
2 V2 : A* B* C D E F D and E are adjacent vertices to B*
L(V2): - - (3) 7 4 L(D)= L(B*)+ L(B*D)=2+5=7; L(E)= L(B*)+ L(B*E)=2+2=4
Min{L(D),L(E),L(C)}=min{7,4,3}=L(C)=3
Thus, L(C*)=3 is bracketed.

3 V3 : A* B* C* D E F E is adjacent vertex to C*
L(V3): - - - 7 (4) L(E)= L(C*)+ L(C*E)=3+5=8, Previous L(E)=4 [from B*]
Min{L(E), Pre.L(E)}=Min{8,4}=4
Thus, L(E*)=4 is bracketed from B*
4 V 4 : A* B* C* D E* F D and F are adjacent vertices to E*
L(V4): - - - (5) - 8 L(D)= L(E*)+ L(E*D)=4+1=5; L(F)= L(E*)+ L(E*F)=4+4=8
Previous L(D)=7
Min{L(D), Pre.L(D), L(F)}=Min{5,7,8}=L(D)=5
Thus, L(D*)=5 is bracketed.
5 V5 : A* B* C* D* E* F F is the only vertex adjacent to D*
L(V5): - - - - - (7) L(F)= L(D*)+ L(D*F)=5+2=7
Min{L(F), prev L(F)}= Min{7,8}= L(F)=7
L(F*)=7.
Since L(F*)=7, the length of the shortest path from A to F = 7
To find shortest path:

FF* from D*,

D  D* from E*

EE* from B*

BB* from A* in Iteration1.

Shortest path is A – B – E – D – F and the length is 7

2.Using Dijkstra’s Algorithm, find the shortest path between the vertex A and H
in the Weighted Graph.

6
A

Iterat Iteration Details Remarks


ion
Numb
er

0 V0 : A B C D E F G H a is permanently labeled as a*
L(V0): (0) L(a*)=0
1 V1 : A* B C D E F G H b and f are adjacent to a*
L(V1): - 2 (1) L(b)=2, L(f)=1
Min(L(b),L(f))=Min(2,1)= L(f)=1
L(f*) =1 is bracketed
2 V2 : A* B C D E F* G H g and d are adjacent to f*
L(V2): - (2) 4 - 7 L(g)=L(f*)+L(f*g)=1+6,=7
L(d)= L(f*)+L(f*d)=1+3 =4
Min{L(g),L(d),L(b)}=Min{7,4,2}= L(b)=2
L(b*)=2 is bracketed

3 V3 : A* B* C D E F* G H d,e,c are adjacent to b*


L(V3): - - (4) 4 6 - 7 L(d)=L(b*)+L(b*d)=2+2=4
L(e)=L(b*)+L(b*e)=2+4=6
L(c)= L(b*)+L(b*c)=2+2=4
Min{L(d), preL(d),L(e),L(c),L(g)}=
Min{4,4,6,4,7}= L(d), L(c)=4
[from b* and f*]
L(c*)=4 is bracketed.
4 V4 : A* B* C* D E F* G H e and h are adjacent vertices to c*
L(V4): - - - 6 - 7 (5) L(e)=L(c*)+L(c*e)=4+3=7
4
L(h)=L(c*)+L(c*h)=4+1=5
Min{L(e),L(h),L(d),L(e),L(g)}=Min{7,5,4,6,7}
=L(d)=4
L(d*)=4 is bracketed.

e is adjacent to d*
L(e)=L(d*)+L(d*e)=4+4=8
Min{L(e),
preL(e),L(g)}=Min{8,7,7}=L(e)=L(g)=7
Logically in previous step L(h)=5

We can conclude L(h*)=5

Shortest path is A – B – C – H ;Length of the Shortest path is : A – B – C


– H = 2+2+1=5

Iterat Iteration Details Remarks


ion
Numb
er

0 V0 : A B C D E F G H B and F are adjacent to A*


L(V0): (0) L(B)= L(A*)+ W(A*B)=2
L(F)= L(A*)+ W(A*F)=1
L(F*)=1 is bracketed
1 V1 : A* B C D E F G H D and G are adjacent to F*
L(V1): - 2 (1) L(D)= L(F*)+ W(F*D)=1+3=4
L(G)= L(F*)+ W(F*G)=1+6=7
Min{L(D),L(G),L(B)}=L(B)=2
Thus, L(B*)=2 is bracketed.
2 V2 : A* B C D E F* G H C, D and E are adjacent to B*
L(V2): - (2) 4 - 7 L(C)= L(B*)+ W(B*C)=2+2=4 TIE
L(D)= L(B*)+ W(B*D)=2+2=4
L(E)= L(B*)+ W(B*E)=2+4=6
Min{L(C),L(D),L(E)}=L(C)=4
Thus, L(C*)=4 is bracketed.
3 V3 : A* B* C D E F* G H E and H are adjacent to C*
L(V3): - - (4) 4 6 - 7 L(E)= L(C*)+ W(C*E)=4+3=7
L(H)= L(C*)+ W(C*H)=4+1=5
Previous L(E)=6
Min{L(E),Pre.L(E),L(H)}=5
Thus, L(H*)=5 is bracketed.
4 V4 : A* B* C* D E F* G H Thus H is reached from C.
L(V4): - - - 6 - ∞ (5) Thus L(H*)=5
Shortest path is A – B – C – H
Length of the Shortest path is : A – B – C – H = 2+2+1=5

3)
Use Dijkstra’s Algorithm to find the shortest path between the vertex A and F in
the given Weighted Graph.

B 6 D
1 2
5 3
A 2 F

4
7
C
1 E
Sol:
Iteration Iteration Details Remarks
Number

0 V0 : A B C D E F A gets permanent label


L(V0): (0) L(A*)=0 is bracketed
1 V1 : A* B C D E F B and C are adjacent to A*
L(V1): - (1) 4 ∞ L(B)= L(A*)+ W(A*B)=0+1=1
L(C)= L(A*)+ W(A*C)=0+4=4
Min{L(B),L(C)}=L(B)=1
Thus, L(B*)=1 is bracketed.
2 V2 : A* B* C D E F E, C and D are adjacent to B*
L(V2): - - (3) 7 6 L(E)= L(B*)+ W(B*D)=1+5=6
L(C)= L(B*)+ W(B*C)=1+2=3
L(D)=L(B*)+W(B*D)=1+6=7
Pre L(C)=4
Min{L(E),L(C),L(D),PreL(C)}
=Min{6,3,7,4}=L(C)=3 (i.e.,from B*)
Thus, L(C*)=3 is bracketed.
3 V3 : A* B* C* D E F E is adjacent to C*
L(V3): - - - 7 (4) L(E)= L(C*)+ W(C*E)=3+1=4
Previous L(E)=6 (i.e., from B*)
Min{L(E),Pre.L(E)}=Min{4,6}=4
Thus, L(E*)=4 from C* is bracketed.
4 V4 : A* B* C* D E* F D and F are adjacent to E*
L(V4): - - - (7) - 11 L(D)= L(E*)+ W(E*D)=4+3=7
L(F)= L(E*)+ W(E*F)=4+7=11
Previous L(D)=7 (i.e.,from B*)
Min{L(D),L(F),Pre.L(D)}=L(D)=7
Thus, L(D*)=7 from E* is bracketed.
5 V5 : A* B* C* D* E* F F is the only vertex adjacent to D*
L(V5): - - - - - (9) L(F)= L(D*)+ W(D*F)=7+2=9
L(F*)=9.

Shortest Path: A – B – C – E – D – F

Length of the Shortest path = 1+2+1+3+2=9


4)
Use Dijkstra’s Algorithm to find the length of the shortest path between the
vertex a and z in the given Weighted Graph.

b 5 d
4 6
a 8 2
1 f

2
3
c
10 e

Sol:
Iterati Iteration Details Remarks
on
Numb
er

0 V0 : a b c d e f a gets permanent label


L(V0): (0) ∞ L(a*)=0 is bracketed
1 V1 : a* b c d e f b and c are adjacent to a*
L(V1): - 4 (2) ∞ ∞ L(b)= L(a*)+ W(a*b)=0+4=4
L(c)= L(a*)+ W(a*c)=0+2=2
Min{L(b),L(c)}=L(c)=2
Thus, L(c*)=2 is bracketed.
2 V2 : a* b c* d e f b, d and e are adjacent to c*
L(V2): - (3) - 10 12 L(b)= L(c*)+ W(c*b)=2+1=3
L(d)= L(c*)+ W(c*d)=2+8=10
L(e)=L(c*)+W(c*e)=2+10=12
Pre L(b)=4
Min{L(b),L(d),L(e),PreL(b)}
=Min{3,10,12,4}=L(b)=3(i.e.,from c*)
Thus,L(b*)=3 is bracketed (from c*)

3 V3 : a* b* c* d e f d is adjacent to b*
L(V3): - - - (8) 12 L(d)= L(b*)+ W(b*d)=3+5=8
Pre L(d)=10 (i.e., from c*)
Min{L(d),Pre.L(d)}=Min{8,10}=8
Thus, L(d*)=8 (from b*) is bracketed.
4 V4 : a* b* c* d* e f e and f are adjacent to d*
L(V4): - - - - (10) L(e)= L(d*)+ W(d*e)=8+2=10
14 L(f)= L(d*)+ W(d*f)=8+6=14
Previous L(e)=12 (i.e.,from c*)
Min{L(e),L(f),Pre.L(e)}=L(e)=10
Thus, L(e*)=10 (from d*) is bracketed.
5 V5 : a* b* c* d* e* f f is the only vertex adjacent to e*
L(V5): - - - - - L(f)= L(e*)+ W(e*f)=10+3=13
(13) Pre.L(f)=14 (from d*)
Min{L(f),Pre.L(f)}=Min{13,14}=L(f)
L(f*)=13 (from e*) is bracketed

Shortest path : a – c – b – d – e – f

Length of the path: 2+1+5+2+3=13

5)

6)
7)

8)

Iterati Iteration Details Remarks


on
Numb
er

0 V0 : a b c d e f g a gets permanent label


L(V0): (0) ∞ L(a*)=0 is bracketed
1 V1 : a* b c d e f g b and c are adjacent to a*
L(V1): - 5 (3) ∞ ∞ L(b)= L(a*)+ W(a*b)=0+5=5
L(c)= L(a*)+ W(a*c)=0+3=3
Min{L(b),L(c)}=L(c)=3
Thus, L(c*)=3 is bracketed.
2 V2 : a* b c* d e f g e, f are adjacent to c*
L(V2): - 5 - (5) 15 L(e)= L(c*)+ W(c*e)=3+2=5
L(f)= L(c*)+ W(c*f)=3+12=15

Min{L(b),L(e),L(f)}
=Min{5,5,15}=L(e) [from c*] or L(b)=5(i.e., from
a*)
Thus, L(e*)=5 is bracketed (from c*)

Suppose L(b*)=5 is brackted

3 V3 : a* b c* d e* f g b, d ,f are adjacent vertices to e*


L(V3): - (5) - 10 - 14 d adjacent to b*

L(b)= L(e*)+ W(e*b)=5+3=8


L(d)= L(e*)+ W(e*d) =5+ 5=10
L(f)= L(e*)+ W(e*f)=5+9=14

L(d)=L(b*)+L(b*d)=5+5=10

Min{L(b), L(d), L(f), prevL(f),L(d)}


=Min{8, 10,14,15, 10}=
Thus, L(d*)=10 (from e*) is bracketed.
Or
L(d)=10 [from b*]
4 V4 : a* b* c* d e* f g g is adjacent to d*
L(V4): - - - - - 14 (12) L(g)= L(d*)+ W(d*g)=10+2=12=L(g)=12[from e*]
L(g)=L(d*)+ W(d*g)=10+2=12 [from b*]

Thus, L(g*)=12 (from b*or e*) is bracketed.


5 V5 : a* b* c* d* e* f g* f is adjacent to g*
L(V5): - - - - - (13) - L(F)=L(g*)+W(g*f)=12+1=13
L(F)=13 [from g*]

L(F)=13 shortest path

f: f from g*

g*: g* from d*

d*: d* from b* or d* from e*

b*: b* from a*

or

e*: e* from c*
c*:c* from a*

Shortest Path : a-b-d-g-f or a-c-e-d-g-f

Length: 14 or 13

You might also like