Unit-5 Graph Notes
Unit-5 Graph Notes
GTU SYLLABUS
WEIGHTAGE : 27%
Graph: Introduction, definition, examples; Nodes, edges, adjacent nodes, directed and
DMGT (BE04000261) Page | 1
Semester: IV (2025-26)
Trees: Definition, branch nodes, leaf (terminal) nodes, root, examples; Different
representations of a tree, examples; Binary tree, m-ary tree, Full (or complete) binary
tree, examples; Converting any m-ary tree to a binary tree, examples; Representation
of a binary tree: Linked-list; Tree traversal: Pre-order, in-order, post-order traversal,
examples, algorithms; Applications of List structures and graphs
TOPIC:1 GRAPHS
SHORT QUESTIONS
1 Define: Graph 1
Solution
Example:
DMGT (BE04000261) Page | 2
Semester: IV (2025-26)
𝑉 = {𝑣1 , 𝑣2 , 𝑣3 }
𝐸 = {𝑒1 , 𝑒2 , 𝑒3 }
𝐺≠∅
2 Define Adjacent Vertices and Adjacent Edges 2
Solution
𝐵 and 𝐶 are not adjacent vertices 𝐴𝐶 and𝐵𝐷 are not adjacent edges
3 Define: Directed graph, Non-Directed graph and Mixed graph 3
Solution:
Directed Non-Directed/Undirected Mixed Graph
graph(Digraph)(Jul-2022) graph
Definition: A graph G in Definition: A graph G in Definition: If some edge of
which each edge has a which each edge has a a graph G are directed and
directionis called a directed Nodirectionis called a non- some are undirected then G
directed graph.
graph. (Digraph) is said to be a mixed graph
Solution
(2)Simple Directed graph (2)Multi Directed graph (2) Psuedo Directed graph
Example: Example:
Example:
Order ( G ) = 4 Size ( G ) = 6
14 Define k-regular graph with example. 3
Solution:
DMGT (BE04000261) Page | 7
Semester: IV (2025-26)
(3) 4-Regular graph with 5 vertices (4) K3 (2-Regular graph with 3 vertices)
(4) K1 (0-Regular graph with 1 vertex) (4) K2 (1-Regular graph with 2 vertices)
(2)Directed Edges:
In a directed graph G an edge ‘e’ which has direction from ‘u’ to ‘v’ is called directed edge of
graph G.
G 0 1
2 How many nodes are necessary to construct a graph with exactly 8 edges in which each 3
node is of degree 2? (Sep-2021)
Solution:
Given that |𝐸 |= 8
2 |𝐸 | = 2 × 8
|𝐸 |= 8
3 Draw a simple graph with 4 nodes and 7 edges if possible. If not give reason. 3
Solution:Let G be a simple graph with order 4 and size 7
i.e. |𝑉 |= 4= n = no, of vertex and |𝐸 |= 7 = no. of edges (Max. no. of edges in G)
By theorem, Maximum number of edges in a simple graph with n vertices
𝑛(𝑛 − 1) (4)(4 − 1)
= = = 6
2 2
Maximum number of edges G can have is 6
It is given that number of edges in G is 7
|𝐸 |= 7 <6 ,Which is [Link],Simple graph with order 4 and Size 7 does not exist.
(2)Degree of a vertex:The number of edges incident to a vertex v is called the degree of the
vertex and is denoted by deg(v)
(3)Complete Graph: A simple Graph G in which every pair of distinct vertices are adjacent is called
a complete graph.
V3 V4
3 Regular graph with 4 vertices is not bipartite as
V1 is joined with V3 and V2 is joined with V4
6 Draw two complete bipartite graphs, which are not regular. 3
Solution:
A complete bipartite graph 𝑲𝒎 ,𝒏 is not regular if 𝒎 ≠ 𝒏
(1) 𝐾3 ,4
7 A graph G has 15 edges, 3 vertices of degree 4 and other vertices of degree 3. Find the 3
number of vertices in G.
Solution:
For the graph,∑ 𝑑(𝑉𝑖 ) = 2|𝐸 |
⇒ 4 + 4 + 4 + 3 × 𝑥 = 2 × 15
⇒ 12 + 3 × 𝑥 = 30
⇒ 3 × 𝑥 = 30 − 12 = 18
18
⇒𝑥= =6
3
8 Prove that there are always an even number of vertices of odd degree in a graph 3
So, the second term on RHS i.e. ∑𝑣∈𝑉2 deg(𝑣) must be even.
But Since all the terms in this sum are odd so there must be an even number of such terms.
Hence we conclude that there are an even number of vertices of odd degree
Self-Loop(Sling): An edge e of a graph G that joins a node u to itself is called a loop. A loop is
an edge e = (u, v).
Pendent Vertex:
A vertex of a graph with degree one is called a pendent vertex( or end vertex)
SELF LOOP
⇒ 2 + 2 + 2 + 2 + 2 = 2 |𝐸 |
⇒ 2 |𝐸 | = 2 × 5⇒ |𝐸 | = 5
Number of edges in G = 5
12 Determine the number of edges in a graph with 6 nodes, 2 of degree 4 and 4 of degree 2. Draw two 3
such graphs.
DMGT (BE04000261) Page | 13
Semester: IV (2025-26)
⇒ 2 + 2 + 2 + 2 + 4 + 4 = 2 |𝐸 |
⇒ 2 |𝐸 | = 16⇒ |𝐸 | = 8
Number of edges in G = 8
𝑟×𝑛 3×5
|𝐸 | = = = 15/2 which is not possible.
2 2
Let G = (V, E) be a directed graph with n nodes 𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 ,…and ‘e’ number of edges
Any directed edge in G contributes ‘ 1 ‘out degree and ‘ 1 ‘in degree.
Also, a self-loop contributes two degrees (1 out degree and 1 in degree)
Once an edge is count for in degree it will not count for out degree.
When we are adding the in degree of nodes , each edge is counted exactly once.
Hence, total of in degrees of all nodes is same as the number of edges.
𝒊. 𝒆. ∑ 𝒅𝒆𝒈− (𝒗) = 𝒆
𝒗∈𝑽
17 How many edges does a graph have if it has vertices of degree 4, 3, 3, 2, 2? Draw such a 7
graph.
Solution=V(G)= {𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 , 𝑣5 }
𝑑(𝑉1 ) = 4
𝑑(𝑉2 ) = 3
𝑑(𝑉3 ) = 3 and |𝐸 | = 7
𝑑(𝑉4 ) = 2
𝑑(𝑉5 ) = 2
|𝐸 | =?
∑ 𝑑 (𝑉𝑖 ) = 2|𝐸 |
∑ 𝑑( 𝑉𝑖 ) = 4+3+3+2+2 = 14 = 2|𝐸 |
⇒ 2(7) = 2|𝐸 | ⇒ |𝐸 | = 7
18 How many edges are there in a graph with 10 vertices each of degree six? 3
⇒ 6 × 10 = 2 |𝐸 |
⇒ 2 |𝐸 | = 60 ⇒ |𝐸 | = 30
Number of edges in G = 30
19 Is it possible to construct a graph with 12 nodes such that 2 of the nodes are 3
DMGT (BE04000261) Page | 15
Semester: IV (2025-26)
⇒ (3 × 2) + (10 × 4) = 2 |𝐸 |
⇒ 2 |𝐸 | = 46⇒ |𝐸 | = 23
Number of edges in G = 23
Yes, it is possible to construct a graph with 12 nodes such that two of its vertices have degree 3
and the remaining vertices have degree 4
20 Is it possible to draw a 3-regular graph with 5 vertices? 3
Solution:
Number of vertices n = 5, r= 3
Sum of the degrees of the vertices = 5 * 3 = 15, which is not divisible by 2.
Therefore, it is not possible to draw a 3-regular with 5 vertices.
Note: A graph with n vertices is r-regular if either r or n or both are even.
21 Let G be a simple graph with 12 edges. If G has 6 vertices of degree 3 and the 7
rest of the vertices have degree less than 3, then find the
(a) Minimum number of vertices and
(b) Maximum number of vertices.
Solution:Number of edges e = 12
Suppose the total number of vertices in G is p.
Given that 6 vertices have degree 3.
Hence, the sum of degrees =3 *6 = 18.
The rest (p — 6) vertices have degree less than 3.
i.e., their degree liesinclusively between 0 and 2.
Here, to find the minimum number of vertices,
(p — 6) vertices must havemaximumdegree [i.e., 2 ]
Therefore, applying the handshaking theorem, we get
18 + 2 𝑝 - 6 = 2𝑒
18 + 2𝑝 - 12 = 24
2𝑝 + 6 = 24
2𝑝 = 18 ⇒𝑝 = 9
Minimum number of vertices = 9
To calculate the maximum number of vertices,
(p — 6) vertices must havemaximumdegree [i.e., 1]
Sum of degrees = 18 + 𝑝 - 6 = 2𝑒 = 24
𝑝 + 12 = 24⇒𝑝 = 12
Maximum number of vertices = 12
22 Show that the graph C6 is bipartite. 3
Solution:In this graph, the two distinct sets of vertices are shown in distinct colours.
Hence,C6 is bipartite.
Solution:
(a)Directed Graph / Digraph:
A graph in which every edge is directed is called a directed graph (Digraph)
Simple Path:The path is called simple one if no edge is repeated in the path,
Elementary Path:The path is called elementary one if no vertex is repeated in the path,
Simple Path:
1−2−3
1−4−3
1−2−4−3
Elementary Path:
1 − 2 − 3 ⇒ Length of path = 2
1 − 4 − 3 ⇒ Length of path = 2
1 − 2 − 4 − 3 ⇒ Length of path = 3
A vertex V of a simple digraph is said to be reachable from the vertex u of the same digraph, if
there exists a path from u to v.
Example:
𝑃1 = (〈1,2〉, 〈2,1〉)
𝑃2 = (〈3,4〉, 〈4,3〉)
(d)Connected Graph: A graph G is connected if every pair of vertices are joined by a path
otherwise the graph is disconnected.
Connected graph
Solution:
i) Isolated vertex :A vertex of a graph with degree zero is called an isolated vertex
ii) Null graph:A graph containing only isolated nodes is called a null graph
Isolated vertices are 𝑣4 𝑎𝑛𝑑 𝑣7
27 Define the terms: Simple Graph, Multi - Graph, Weighted Graph, Degree of a vertex, in 7
degree and out degree of a vertex. Illustrate each with an example.
Solution: Discussed Earlier
28 Define Cyclic graph, Null graph and Strongly connected graph. 3
Solution:
(1)Cyclic graph: A graph containing at least one cycle in it is called as a cyclic graph.
Examples-1
.
(2)Null Graph(Empty Graph):A graph containing only isolated nodes is called a null graph.
(3)Strongly Connected Graph:A directed graph is said to be strongly connected if for every
two vertices a and b in G there is a path from a to b and b to a.
Knhas nvertices.
𝑲𝟑 𝐾2,2
𝐾3 3 𝑛(𝑛 − 1)
=3
2
𝐾2,2 4 𝑚×𝑛 = 2×2 = 4
Solution:
A self-loop contributes two degrees ( One out degree and One in degree)
The sum of in degree and out degree is called the total degree of a vertex
Solution:
Graph G is bipartitebecause its vertex set is the union of two disjoint sets,
{a, b, d}and {c, e, f, g},
and each edge connects a vertex in one of these subsets to a vertex in the other subset.
(Note that for G to be bipartite it is not necessary that every vertex in {a, b, d} be
adjacent to every vertex in {c, e, f, g}. For instance, b and g are not adjacent.)
Graph H is not bipartitebecause its vertex set cannot be partitioned into two subsets
sothat edges do not connect two vertices from the same subset.
We can verify this byconsidering the vertices a, b, and f
Solution:
Cener of a graph = 1
MATRIX REPRESENTATION OF GRAPHS
DESCRIPTIVE QUESTIONS
1 Define adjacency matrix and path matrix of a graph. Find out adjacency matrix for the 4
graph given in figure(Dec–2022)
Solution:
The adjacency matrix A = [𝑎𝑖𝑗 ]for a graph G with n vertices is an n × n matrix defined by
= 0 otherwise
For Pseudo/Multi Graph
𝑎𝑖𝑗 = 𝑘 ,k is vertex 𝑉𝑖 is adjacent to 𝑉𝑗
= 0 otherwise
For Directed Graph:
𝑎𝑖𝑗 = 1 If edge beginning at vertex 𝑉𝑖 end at 𝑉𝑗
= 0 otherwise
The Path matrix P = [𝑝𝑖𝑗 ]for a directed graph G with n vertices is an n × n matrix defined by
𝑝𝑖𝑗 = 1 If there exists a path from 𝑝𝑖 to 𝑝𝑗
= 0 otherwise
Solution:
Let G be a non-directed graph with n vertices and m edges. The incidence matrix of graph G is
M = [𝑚𝑖𝑗 ] of order n× mand is defined by
Let G be a directed graph with n vertices and m edges. The incidence matrix of graph G is M =
[𝑚𝑖𝑗 ] of order n× mand is defined by
𝑎 𝑏 𝑐 𝑑 𝑒 𝑓 𝑔 ℎ
𝑣1 0 0 0 1 0 1 0 0
𝑣2 0 0 0 0 1 1 1 1
𝑣
𝑀 = 𝑣3 0 0 0 0 0 0 0 1
4
𝑣5 1 1 1 0 1 0 0 0
𝑣6 0 0 1 1 0 0 1 0
[1 1 0 0 0 0 0 0]
𝟏 𝟏 𝟏 𝟐
[𝟏 𝟎 𝟎 𝟎]
𝟏 𝟎 𝟎 𝟐
𝟐 𝟎 𝟐 𝟐
Solution:
4 Draw di-graph and find in-degree and out-degree of each vertex from the given 7
adjacency matrix. Use adjacency matrix, find total no. of path of length 1 and 2 between
each vertex.
𝟏 𝟏 𝟏
𝐀 = [𝟏 𝟏 𝟏 ]
𝟏 𝟏 𝟏
𝒂 3 3 6
𝒃 3 3 6
𝒄 3 3 6
Path of Length 1
(𝟏)𝒗𝟏 − 𝒗𝟐 (𝟐)𝒗𝟐 − 𝒗𝟏 (𝟑)𝒗𝟏 − 𝒗𝟑 (𝟒)𝒗𝟑 − 𝒗𝟏 (𝟓)𝒗𝟑 − 𝒗𝟐 (𝟔)𝒗𝟐 − 𝒗𝟑
Path of Length 2
(𝟏)𝒗𝟏 − 𝒗𝟐 − 𝒗𝟏 (𝟐)𝒗𝟐 − 𝒗𝟏 − 𝒗𝟐 (𝟑)𝒗𝟏 − 𝒗𝟑 − 𝒗𝟏 (𝟒)𝒗𝟑 − 𝒗𝟏 − 𝒗𝟑
(𝟓)𝒗𝟑 − 𝒗𝟐 − 𝒗𝟑 (𝟔)𝒗𝟐 − 𝒗𝟑 − 𝒗𝟐
5 Define adjacency matrix of a digraph. Obtain the adjacency matrix A of the given 7
digraph. Find the elementary paths of lengths 1 and 2 from v1 to v4 .
Solution:
Adjacency Matrix of directed Graph:
The adjacency matrix A = [𝑎𝑖𝑗 ]for a directed graph G with n vertices is an n × n matrix defined by
= 0 otherwise
0 1 0 1
0 0 1 1
A=
0 1 0 1
0 1 0 0
The adjacency matrix A = [𝑎𝑖𝑗 ]for a graph G with n vertices is an n × n matrix defined by
= 0 otherwise
For Pseudo/Multi Graph
= 0 otherwise
For Directed Graph:
= 0 otherwise
The Path matrix P = [𝑝𝑖𝑗 ]for a directed graph G with n vertices is an n × n matrix defined by
= 0 otherwise
0 0 0 1
1 0 0 0
A=
1 1 0 1
0 1 1 0
= 0 otherwise
. The War shall Algorithm is often used to compute the path matrix.
1 1 1 1
1 1 1 1
P=
1 1 1 1
1 1 1 1
7 Define adjacency matrix of a graph and obtain the adjacency matrix (A) for the following 4
graph. State the in degree and out degree of all the vertices.
Solution:
The adjacency matrix A = [𝑎𝑖𝑗 ]for a graph G with n vertices is an n × n matrix defined by
= 0 otherwise
For Pseudo/Multi Graph
= 0 otherwise
For Directed Graph:
= 0 otherwise
0 0 0 1
1 0 0 0
A=
1 1 0 1
0 1 1 0
In Graph G
8 Define adjacency matrix and find the same for (Feb–2021) (Feb–2021) 4
Solution:
Adjacency Matrix of a Graph:
The adjacency matrix A = [𝑎𝑖𝑗 ]for a graph G with n vertices is an n × n matrix defined by
= 0 otherwise
For Pseudo/Multi Graph
= 0 otherwise
For Directed Graph:
= 0 otherwise
(2)The adjacency matrix of simple graph G
0 1 1 1 0
1 0 1 0 0
A = 1 1 0 1 0
1 0 1 0 1
0 0 0 1 0
𝟎 𝟏 𝟏 𝟎
[𝟏 𝟎 𝟎 𝟏]
𝟏 𝟎 𝟎 𝟏
𝟎 𝟏 𝟏 𝟎
Solution:
𝑎 𝑏 𝑐 𝑑
𝒂 𝟎 𝟑 𝟎 𝟐
𝑨=𝒃 𝟑
𝒄 [𝟎
𝟎 𝟏 𝟏]
𝟏 𝟏 𝟐
𝒅 𝟐 𝟏 𝟐 𝟎
+ 0 1
0 0 1
1 1 1
× 0 1
0 0 0
1 0 1
Solution:
The incidence matrix is
ISOMORPHIC GRAPHS
1 Define Isomorphic graph with example 3
Solution: Two graphs G1 and G2 are said to be isomorphic if −
Their number of vertices are same.
Their number of edges are same.
If𝑮𝟏 has n vertices of degree k then 𝑮𝟐 has n vertices of degree k.
Adjacency is preserved.
Example:
(1)|V(G)| = |V(H)| = 5
(2)|E(G)| = |E(H)| = 5
In graph G In graph H
d(y) = 2
d(a) = 2
d(b) = 2 d(v) = 2
d(c) = 2 d(x) = 2
d(d) = 2 d(z) = 2
d(e) = 2 d(w) = 2
2 Define Isomorphic graphs. What are the necessary conditions for two graphs to be 4
isomorphic? Are they sufficient also? Justify your answer
Solution:
Two graphs G1 and G2 are said to be isomorphic if −
Their number of vertices are same.
Their number of edges are same.
If𝑮𝟏 has n vertices of degree k then 𝑮𝟐 has n vertices of degree k.
Adjacency is preserved.
3 Give an abstract definition of graph. When are two simple graphs said to be isomorphic? 7
Give an example of two simple digraphs having 4 nodes and 4 edges which are not
isomorphic
Solution: Graph:
Let V be the non-empty set of point and E be the set of lines between points, then
An example of two simple digraphs having 4 nodes and 4 edges which are not isomorphic
Graph G1 Graph G2
To check Isomorphism:
(1) |V(G1)| = |V(G2)| = 4
(2) |E(G1)| = |E(G2)| = 4
(3) To checkAdjacency:
In Graph G1
In Graph G2
In graph 𝑮𝟏
In graph 𝑮𝟐
4 Define isomorphic graphs. State whether the following graphs are isomorphic or not. 4
Notation: G1 ≡ G2
To check Isomorphism:
(1) |V(G1)| = |V(G2) |= 5
(2) |E(G1)| = |E(G2)| = 6
(3) To check Adjacency:
In Graph 𝑮𝟏 In Graph 𝑮𝟐
𝒅(𝒖𝟏 ) = 𝟐 𝒅(𝒗𝟏 ) = 𝟐
𝒅(𝒖𝟐 ) = 𝟐
𝒅(𝒗𝟐 ) = 𝟒
𝒅(𝒖𝟑 ) = 𝟑
𝒅(𝒗𝟑 ) = 𝟑
𝒅(𝒖𝟒 ) = 𝟑
𝒅(𝒗𝟒 ) = 𝟏
𝒅(𝒖𝟓 ) = 𝟐
𝒅(𝒗𝟓 ) = 𝟐
In graph 𝑮𝟏
No. of vertices having 3 degree=2
No. of vertices having 2 degree=3
In graph 𝑮𝟐
No. of vertices having 4 degree=1
No. of vertices having 3 degree=1
No. of vertices having 2 degree=2
No. of vertices having 1 degree=1
Adjacency is not preserved,
5 Define isomorphic graphs. State whether the following digraphs are Isomorphic or not. 7
Justify your answer.
In Graph G2
Vertex In degree Out degree
𝑢1 is correspondent to 𝑣1
𝑢2 is correspondent to 𝑣2
𝑢3 is correspondent to 𝑣3
𝑢4 is correspondent to 𝑣4
𝑢5 is correspondent to 𝑣5
𝑢6 is correspondent to 𝑣6
Adjacency is preserved
6 Define Isomorphic Graphs. Verify the following graphs are Isomorphic or not (Justify). 7
6 Define isomorphism of graphs and find whether K 6 and K3,3graphsare isomorphic or not. 5
Solution:
Two graphs G1 and G2 are said to be isomorphic if −
Their number of vertices are same. . i.e. |V(G1)| = |V(G2)|
Their number of edges are same. i.e. |E(G1)| = |E(G2)|
An equal number of vertices with given degree
Adjacency is preserved
Notation: G1 ≡ G2
To check Isomorphism
𝑛(𝑛−1)
𝐾𝑛 has exactly edges
2
6(6−1) 30
∴ 𝐾6 = = = 15
2 2
𝐾6 have 15 edges
𝐾𝑚 ,𝑛 has mn edges
∴ No. of edges = 3 × 3= 9
|E(G1)| ≠ |E(G2)|
Solution:
In Graph 𝑮𝟏 In Graph 𝑮𝟐
𝒅(𝒙) = 𝟑 𝒅(𝒚) = 𝟑
𝒅(𝒖) = 𝟏
𝒅(𝒘) = 𝟏
𝒅(𝒗) = 𝟏
In graph 𝑮𝟏
We have a vertex 𝒙 of degree 3 , there are two pendent vertices u and v adjacent to x in
𝑮𝟏
But in graph 𝑮𝟐 ,
8 Define isomorphic graphs. State whether the following graphs are isomorphic or 4
not.
Solution:
The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there exists a
Oneto-one and onto function f from V1 to V2 with the property that
aand b are adjacent in G1 ifand only if f (a) and f (b) are adjacent in G2, for all a ,bin V1. Such
a function f is calledanisomorphism
∗ Two simple graphs that are not isomorphic are called nonisomorphic.
1)|V(𝑮𝟏 )| = |V(𝑮𝟐 )| = 8
(2)|E(𝑮𝟏 )| = |E(𝑮𝟐 )| = 10
(3)To check Adjacency:
In Graph 𝑮𝟏 In Graph 𝑮𝟐
𝒅(𝒂) = 𝟑 𝒅 ( 𝟏) = 𝟑
𝒅(𝒃) = 𝟐 𝒅 ( 𝟐) = 𝟐
𝒅(𝒄) = 𝟑 𝒅 ( 𝟑) = 𝟑
𝒅(𝒅) = 𝟐 𝒅 ( 𝟒) = 𝟐
𝒅(𝒆) = 𝟑 𝒅 ( 𝟓) = 𝟑
𝒅(𝒇) = 𝟐 𝒅 ( 𝟔) = 𝟐
𝒅 ( 𝒈) = 𝟑 𝒅 ( 𝟕) = 𝟑
𝒅(𝒉) = 𝟐 𝒅 ( 𝟖) = 𝟐
In graph 𝑮𝟏
No. of vertices having 3 degrees=4
No. of vertices having 2 degrees=4
In graph 𝑮𝟐
No. of vertices having 3 degrees=4
No. of vertices having 2 degrees=4
(4)The function f with
f (a) = 1, f (b) = 2, f (c) =3, f(d) = 4 ,
f (e) = 5, f (f) = 6, f (g) =7, f(h) = 8
is a one to-one correspondence between 𝑮𝟏 and 𝑮𝟐
These correspondence preserves adjacency
So, G1 and G2 are isomorphic.
9 Are the following graphs isomorphic? Justify your answer. 4
Solution:
1)|V(E)| = |V(F)| = 6
(2)|E(E)| = |E(F)| = 8
(3) The degree sequence of E is 2 − 3 − 3 − 2 − 3 − 3 − 2
The degree sequence of F is 2 − 3 − 3 − 2 − 3 − 3 − 2
(4)Graph E contain 2 cycle of length 3→ 𝑣1 − 𝑣2 − 𝑣6 𝑎𝑛𝑑 𝑣3 − 𝑣4 − 𝑣5
But graph F does not contain any cycle of length 3
So, E is not isomorphic to F
Solution:
1)|V(G)| = |V(H)| = 4
(2)|E(G)| = |E(H)| = 8
(3) The degree sequence of G is 2 − 2 − 2 − 2
The degree sequence of H is 2 − 2 − 2 − 2
(4)Graph G contain 1 cycle of length 4→ 𝑢1 − 𝑢2 − 𝑢3 − 𝑢4
And graph H also contain 1 cycle of length 4→ 𝑣1 − 𝑣4 − 𝑣2 − 𝑣3
So, G is isomorphic to H
Solution:
1)|V(G)| = |V(H)| = 6
(2)|E(G)| = |E(H)| = 7
(3) To check Adjacency:
In Graph G In Graph H
𝒅(𝒖𝟏 ) = 𝟐 𝒅(𝒗𝟏 ) = 𝟐
𝒅(𝒖𝟐 ) = 𝟑
𝒅(𝒗𝟐 ) = 𝟐
𝒅(𝒖𝟑 ) = 𝟐
𝒅(𝒗𝟑 ) = 𝟑
𝒅(𝒖𝟒 ) = 𝟑
𝒅(𝒗𝟒 ) = 𝟐
𝒅(𝒖𝟓 ) = 𝟐
𝒅(𝒗𝟓 ) = 𝟑
𝒅(𝒖𝟔 ) = 𝟐
𝒅(𝒗𝟔 ) = 𝟐
In graph G
No. of vertices having 3 degree=2
No. of vertices having 2 degree=4
In graph 𝑯
No. of vertices having 3 degree=2
No. of vertices having 2 degree=4
f (u4) = v5,
f (u5) = v1, and
f (u6) = v2.
We now have a one-to-one correspondence between the vertex set of G and the vertex set of H,
namely,
f (u1) = v6,
f (u2) = v3,
f (u3) = v4,
f (u4) = v5,
f (u5) = v1,
f (u6) = v2.
To see whether f preserves edges, we examine the adjacency matrix of G,
and the adjacency matrix of H with the rows and columns labelled by the images of the
corresponding vertices in G
Because AG = AH,
(Feb–2024)
Solution: To check Isomorphism:
|V(G1)| = |V(G2)| = 6
|E(G1)| = |E(G2)| = 9
To checkAdjacency:
In Graph H
Vertex In degree Out degree
𝒂 𝑑𝑒𝑔+ (𝒂) = 𝟎 𝑑𝑒𝑔− (𝒂) = 𝟑
𝒃 𝑑𝑒𝑔+ (𝒃) = 𝟑 𝑑𝑒𝑔− (𝒃) = 𝟎
𝒄 𝑑𝑒𝑔+ (𝒄) = 𝟎 𝑑𝑒𝑔− (𝒄) = 𝟑
𝒅 𝑑𝑒𝑔+ (𝒅) = 𝟑 𝑑𝑒𝑔− (𝒅) = 𝟎
𝒆 𝑑𝑒𝑔+ (𝒆) = 𝟎 𝑑𝑒𝑔− (𝒆) = 𝟑
𝒇 𝑑𝑒𝑔+ (𝒇) = 𝟑 𝑑𝑒𝑔− (𝒇) = 𝟎
In Graph G
Vertex In degree Out degree
𝒗𝟏 𝑑𝑒𝑔+ (𝒗𝟏 ) = 𝟎 𝑑𝑒𝑔− (𝒗𝟏 ) = 𝟑
𝒗𝟐 𝑑𝑒𝑔+ (𝒗𝟐 ) = 𝟑 𝑑𝑒𝑔− (𝒗𝟐 ) = 𝟎
𝒗𝟑 𝑑𝑒𝑔+ (𝒗𝟑 ) = 𝟎 𝑑𝑒𝑔− (𝒗𝟑 ) = 𝟑
𝒗𝟒 𝑑𝑒𝑔+ (𝒗𝟒 ) = 𝟑 𝑑𝑒𝑔− (𝒗𝟒 ) = 𝟎
13 Define isomorphic graphs. Determine whether the following graphs are isomorphic or 7
not.
(Jul–2023)
Solution:
1)|V(G)| = |V(H)| = 5
(2)|E(G)| = |E(H)| = 6
(3)To check Adjacency:
In Graph G In Graph H
𝒅(𝒂) = 𝟑 𝒅 ( 𝟏) = 𝟑
𝒅(𝒃) = 𝟐
𝒅 ( 𝟐) = 𝟐
𝒅(𝒄) = 𝟑
𝒅 ( 𝟑) = 𝟑
𝒅(𝒅) = 𝟑
𝒅 ( 𝟒) = 𝟑
𝒅(𝒆) = 𝟏
𝒅 ( 𝟓) = 𝟏
𝑽𝟏 = {𝒂, 𝒃, 𝒄, 𝒅, 𝒆}and
𝑉2 = {1, 2, 3, 4, 5}
Define 𝑓: 𝑉1 → 𝑉2 by
𝑓(𝑎) = 1,
𝑓(𝑏) = 2,
𝑓(𝑐 ) = 3,
𝑓(𝑑) = 4 and
𝑓(𝑒) = 5
Then, f is one-one correspondence.
0 1 1 1 0
1 0 1 0 1
𝐴𝐺 = 1 1 0 1 0 = 𝐴𝐻
1 0 1 0 1
[0 0 0 1 0]
It follows that 𝐺 ≅ 𝐻
14 Define isomorphic graphs. Determine whether the following graphs are isomorphic or not. 7
.
Solution:
Isomorphic graphs: Two graphs G1 and G2 are said to be isomorphic if −
Their number of vertices are same. . i.e. |V(G1)| = |V(G2)|
Their number of edges are same. i.e. |E(G1)| = |E(G2)|
An equal number of vertices with given degree
Adjacency is preserved
Notation: G1 ≡ G2
1)|V(G)| = |V(H)| = 5
(2)|E(G)| = |E(H)| = 5
(3)To check Adjacency:
In Graph 𝑮𝟏 In Graph 𝑮𝟐
𝒅 ( 𝟏) = 𝟐 𝒅 ( 𝟏) = 𝟐
𝒅 ( 𝟐) = 𝟐
𝒅 ( 𝟐) = 𝟐
𝒅 ( 𝟑) = 𝟐
𝒅 ( 𝟑) = 𝟐
𝒅 ( 𝟒) = 𝟐
𝒅 ( 𝟒) = 𝟐
𝒅 ( 𝟓) = 𝟐
𝒅 ( 𝟓) = 𝟐
So, G1 ≡ G2
15 Define isomorphic graphs. Check whether the following graphs are isomorphic? 7
(Jul–2023)
Solution:
To check Isomorphism:
|V(G1)| = |V(G2)| = 6
DMGT (BE04000261) Page | 47
Semester: IV (2025-26)
|E(G1)| = |E(G2)| = 9
To checkAdjacency:
In Graph G
Vertex In degree Out degree
In Graph H
Vertex In degree Out degree
𝑎 is correspondent to 1
𝑏 is correspondent to 2
𝑐 is correspondent to 3
𝑑 is correspondent to 4
𝑒 is correspondent to 5
𝑓 is correspondent to 6
Adjacency is preserved
SUB GRAPHS
SHORT QUESTIONS
1 Define sub graph. 1
Solution:
Sub graph:
If G = (V,E) and H = ( V1 , E1 ) are two graphs such that V1 ⊆ V and E1 E then H is called a
sub graph of G.
Examples: (1)
(2)
(2) Null graph obtained by deleting all edges of G is also a sub graph of G
(3) A single edge along with end vertices is also a sub graph of G
Solution:
DESCRIPTIVE QUESTIONS
1 Explain converse (reverse) of a digraph with an example. 3
Solution:
Converse ( reversal/Directional dual) of a digraph:
Solution:
Sub graph: If G = (V,E) and H = ( V1 , E1 ) are two graphs such that V1 ⊆ V and E1 E
then H is called a sub graph of G.
3 Define vertex disjoint and edge disjoint sub graphs by drawing the relevant graphs. 4
Solution:
(i) Edge- disjoint sub graph and (ii) Vertex -disjoint sub graph.
Let G be a graph and 𝐺1and 𝐺2 be two sub graphs of G. Then 𝐺1and 𝐺2 are called edge disjoint
if they have no edge in common
– Let G be a graph and𝐺1 and 𝐺2 be two sub graphs of G. Then𝐺1 and 𝐺2 are called vertex-
disjoint sub graph of G if they have no vertex in common.
Figure
(Complement of H in G is denoted by H )
Note :
Suppose a graph G has n number of vertices (i.e., |V| = n)
and m number of edges (i.e., |E|=n)
G –e G – a
7 Draw some sub graph of the graph 3
Solution:
PATH
A path in a graph is a sequence of vertices such that from each of its vertices there is an
edge to the next vertex in the sequence.
Clearly, vertices as well as edges may be repeated in a path.
A path from u to w is a sequence of edges
𝑢, 𝑣1 ,1, 𝑣2 … . , 𝑣𝑘-1, 𝑤connecting u with w.
A path may be termed as walkalso.
SHORT QUESTIONS
1 Define Cyclic graph 1
Solution:
(1)Cyclic graph: A graph containing at least one cycle in it is called as a cyclic graph.
Examples-1
Example-2
Here,
This graph contains two cycles in it.
Therefore, it is a cyclic graph.
DESCRIPTIVE QUESTIONS
DMGT (BE04000261) Page | 56
Semester: IV (2025-26)
1 Define a path in graph. Define length of the path. What is difference between a simple 3
path and an elementary path?
Solution:
(1) Path:
(1) Length of shortest circuit (if any) in G is called Girth of G, denoted by g(G)
A Simple Path:The path is called simple one if no edge is repeated in the path,
An Elementary Path:The path is called elementary one if no vertex is repeated in the path,
Simple Path:
1−2−3
1−4−3
1−2−4−3
Elementary Path:
1 − 2 − 3 ⇒ Length of path = 2
1 − 4 − 3 ⇒ Length of path = 2
1 − 2 − 4 − 3 ⇒ Length of path = 3
Path:
𝑣1 − 𝑣2 − 𝑣3 − 𝑣4 − 𝑣5 is a path.
𝑣1 − 𝑣3 − 𝑣4 − 𝑣5 is a path.
Note:
Circuit: (Cycle)
A closed path begin and ends at same vertex is called a circuit or elementary circuit
Simple Circuit:
A circuit is said to be simple circuit if it does not include same edge twice
Elementary Circuit:
A circuit is said to be Elementary circuit if it does not include same vertex twice except the end
vertex.
Circuit:
𝑣6 − 𝑣4 − 𝑣5 − 𝑣6
𝑣1 − 𝑣2 − 𝑣3 − 𝑣4 − 𝑣1
Example: 2
Note:
(1) Length of shortest circuit (if any) in G is called Girth of G, denoted by g(G).
TOPIC:2 REACHABILITY
DESCRIPTIVE QUESTIONS
1 Define Reachable set of a node𝐯. Find the reachable sets of (1) node 𝐯𝟏 and (2) node 𝐯𝟖 for 4
the digraph given in following Figure
Solution: Reachable set:A vertex V of a simple digraph is said to be reachable from the vertex
u of the same digraph, if there exists a path from u to v.
The set of vertices which are reachable from a given vertex v is said to be the reachable set of
V.
It is denoted by R(v).
𝑅(𝑣8 ) = {𝑣8 , 𝑣7 , 𝑣6 }
DMGT (BE04000261) Page | 59
Semester: IV (2025-26)
2 Define node base of a simple digraph. Find reachability set of all nodes for the following 7
diagraph.
Solution: Node Base: In a digraph G =< V,E> a subset X V is called a node base if reachable set
of X is V and no proper subset of X has this property
𝑅(𝑣6 ) = {𝑣6 }
𝑅(𝑣7 ) = {𝑣7 , 𝑣6 }
𝑅(𝑣8 ) = {𝑣8 , 𝑣7 , 𝑣6 }
𝑅(𝑣9 ) = {𝑣9 }
𝑅(𝑣10 ) = {𝑣10 }
5 Find the shortest path matrix between each pair of vertices for a digraph using 7
Solution:
6 Find the shortest path matrix between each pair of vertices for a digraph using 7
Warshall’s Algorithm.
Solution: As above
The most familiar examples are the straight lines in Euclidean geometry.
On a sphere, the images of geodesics are the great circles.
The shortest path from point A to point B on a sphere is given by the shorter arc of the great
circle passing through A and B.
PROCEDURE OF WARSHAL’S ALGORITHM TO FIND PATH MATRIX
8 Use Warshall’s algorithm to obtain path matrix from the adjacency matrix of 4
Solution:
0 0 0 1 0
1 0 0 0 0
𝐴=𝑃= 0 1 0 0 0
0 1 1 0 0
[0 0 1 0 0]
0 0 0 1 0
1 0 0 1 0
𝑃(𝑣1 ) = 0 1 0 0 0
0 1 1 0 0
[0 0 1 0 0]
0 0 0 1 0
1 0 0 1 0
𝑃(𝑣2 ) = 1 1 0 1 0
1 1 1 1 0
[0 0 1 0 0]
0 0 0 1 0
1 0 0 1 0
𝑃(𝑣3 ) = 1 1 0 1 0
1 1 1 1 0
[1 1 1 1 0]
1 1 1 1 0
1 1 1 1 0
𝑃(𝑣4 ) = 1 1 1 1 0
1 1 1 1 0
[1 1 1 1 0]
1 1 1 1 0
1 1 1 1 0
𝑃(𝑣5 ) = 1 1 1 1 0
1 1 1 1 0
[1 1 1 1 0]
9 Find the shortest distance matrix between each pair of vertices for a given 7
digraph using Warshall’s Algorithm.
Solution: R S T U
𝑅 7 5 ∞ ∞
𝐷0 = 𝑆 [∞7 0 ∞ 2]
𝑇 ∞ 0 ∞
𝑈 4 ∞ 1 0
TOPIC: 3 CONNECTEDNESS
SHORT QUESTIONS
1 Define connected graph 1
Solution:
An undirected graph is called connected if there is a path between every pair of distinct
vertices of the graph.
An undirected graph that is not connected is called disconnected.
DMGT (BE04000261) Page | 67
Semester: IV (2025-26)
An undirected graph is called connected if there is a path between every pair of distinct
vertices of the graph. An undirected graph that is not connected is called disconnected.
We say that we disconnect a graph when we remove vertices or edges, or both, to produce
a disconnected sub graph.
DESCRIPTIVE QUESTIONS
1 Define a unilateral component and strong component. Write unilateral and strong and 7
weak components of the Graph given in following figure.
Solution:
2 Find all the in degrees and out degrees of the nodes of the graph given in 7
following figure. Give all the elementary cycles of this graph. List all the nodes which are
DMGT (BE04000261) Page | 68
Semester: IV (2025-26)
Solution:
In Graph
Elementary Cycle:
𝒗𝟏 − 𝒗𝟐 − 𝒗𝟒 − 𝒗𝟏
𝒗𝟏 − 𝒗𝟐 − 𝒗𝟑 − 𝒗𝟒 − 𝒗𝟏
List of all the nodes which are reachable from another node of the diagraph
Strongly connectedA directed graph is said to be strongly connected it every two vertices and
b in G there is a path from a to b and b to a.
Disconnected graph: A directed graph which is neither strongly connected nor weekly
connected is known as disconnected graph.
Define cut vertex. List out all the cut vertices of the graph given in figure 3
DMGT (BE04000261) Page | 72
Semester: IV (2025-26)
Solution:
Let G' be a connected graph. A vertex V ∈ G is called a cut vertex of G,
if 'G-V' (Delete 'V' from 'G') is a disconnected graph.
Removing a cut vertex from a graph breaks it in to two or more graphs.
6 Find the cut vertices and cut edges in the graph G 1 shown in Figure 7
7 Are the directed graphs G and H shown in Figure strongly connected? Are they weakly 4
connected?
8 Determine whether the graphs G and H shown in Figure are isomorphic using the 7
concept of paths and circuits.
9 How many paths of length four are there from a tod in the simple graph G in Figure? 7
11 Check given graph in the following figure is weakly connected, unilaterally connected and 7
strongly connected graphs? Why ?
12 Check given graph in the following figure is weakly connected, unilaterally connected and 7
strongly connected graphs? Why ?
TOPIC: 4 TREE
SHORT QUESTIONS
1 Define Binary Tree 1
Solution:
An m-ary tree is known as binary tree if every branch node has at most 2
2 Define Tree 1
Solution:
Therefore
𝑚 + 𝑛 − 1 = 𝑚𝑛
⟹ (𝑚 − 1) (𝑛 − 1) = 0
⟹ 𝑚 = 1 𝑜𝑟 𝑛=1
Solution:
𝑥 + 𝑦 = 10
𝑛
2𝑒 = ∑ 𝑑(𝑣𝑖 )
𝑖=1
⟹ 2 × 9 = 𝑥 + 3𝑦
⟹ 18 = 𝑥 + 3𝑦
⟹ 𝑥 =6 𝑎𝑛𝑑 𝑦 = 4
Then, 𝑒 = 10
Hence,
𝑛
2𝑒 = ∑ 𝑑(𝑣𝑖 )
𝑖=1
20 = 𝑥 + 3𝑦
3 What is the total number of nodes in a full binary tree with 20 leaves? 3
Solution:
𝑛 = 𝑚𝑖 + 1
𝑚 = 2
Hence, 𝑛 = 2𝑖 + 1
Total number of nodes in a tree are the sum branch nodes and leaves.
Hence,
𝑛 = 𝑖 + 20
𝑖 = 𝑛 − 20
𝑛 = 2(𝑛 − 20) + 1
𝑛 = 39
Hence total number of nodes in a full binary tree with 20 leaves are 3
4 Construct binary search tree for the following data 7
10,3,15,22,6,45,65,23,78,34,5
Solution:
5 Create a Binary Search Tree for the following data and do in-order, Preorder and Post-order traversal of 7
the tree.
50, 60, 25, 40, 30, 70, 35, 10, 55, 65, 5
Solution:
6 Create a Binary Search Tree for the following data and do in-order, Preorder and Post-order traversal of 7
the tree.
Solution:
8 Define Binary tree. Obtain Binary tree representation for the following
9 Form a binary search tree for the data 16, 24, 7, 5, 8, 20, 40, 3. 4
Solution:
Solution:
M‐ary Tree:
An m-array tree can be described as a generalization of a tree in which each and every node has
m or less children (i.e. at most m-children)
Binary Tree:
A tree which in which each node has at most two children.
23
6 7 8 4
5
DMGT (BE04000261) Page | 78
Semester: IV (2025-26)
9 10
11
SOLUTION:
Subtree:
Degree of node: No. of children to a Nodes called Degree of Node in tree graph
Pre-order: 1, 2, 3, 4, 5
Post Order: 2, 5, 4, 3, 1
In order: 2, 1 , 4, 5, 3
13 Find a post order and preorder traversal of a following tree. 4
Pre-order: A, B, D, E, F, C, G
Post Order: D, F, E, B, G, C, A
In order: D, B, F, E, A, C, G
14 Define the inorder, postorder and preorder traversal for the following tree. 4
SOLUTION:
Pre-order:
A type of tree traversal that follows the Root-Left-Right policy where:
DMGT (BE04000261) Page | 80
Semester: IV (2025-26)
POST-order:
A type of tree traversal which follows the Left-Right-Root policy such that for each
node:
In order:
A type of tree traversal technique which follows the Left-Root-Right pattern, such
that:
In order: 9, 5, 1, 7, 2, 12, 8, 4, 3, 11
16 Define: (1) A leaf (2) A branch node of a directed tree. (3) A binary tree 7
(4) A complete binary tree.
Also write the order of nodes for the following tree, if it is
traversed in
(1) Pre order (2) in order (3) post order
SOLUTION:
In ABOVE tree
Pre-order: A, B, C, D, E, F, G, H
Post Order: C, D, B, H, G, F, E, A.
In order: C, B, D, A, E, G, H, F.
17 Explain Post order traversal. Given the postorder and inorder traversal of a binary tree, draw 7
the unique binary tree.
Postorder: d e c f b h I g a
Inorder: d c e b f a h g i. (Dec-2022)
SOLUTION:
A type of tree traversal which follows the Left-Right-Root policy such that for
each node:
The left subtree is traversed first.
Then the right subtree is traversed
Finally, the root node of the subtree is traversed.
Post order: d e c f b h i g a
In order: d c e b f a h g i.
bg
c f h i
d e
18 Obtain the binary tree equivalent to the tree given in the following figure. 78
SOLUTION:V0
V1(ROOT)V7
V2 V3 V8 V12
V4V9 V10
V5 V6V11
In ABOVE tree
Pre-order: a, b, d, h, e, i, j, c, f, g, k.
Post Order: h, d, i, j, e, b, f, k, g, c, a.
In order: d, h, b, i, e, j, a, f, c, g,