Module 4
Module 4
Module – 4: Graphs- I
MA1002 – COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Module 4
Graphs I: Definition and terminology (edge, vertex, order, size, degree of
a vertex, Simple graph, degree sequence of a graph, Hand shaking
theorem), Representation of graphs (Undirected graph, Directed graph,
Matrix representation (for undirected and simple graphs)), Null graph,
complete graph, regular graph, cyclic graph, Multigraphs, Bipartite graphs,
Complete bipartite graph, weighted graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Introduction of Graphs The graphs are used to represent a
The term ‘Graph’ is often used problem involving discrete
informally for any representation of arrangements of objects that are
data. Various other forms of graph related to each other, but without
include the Bar graph, Picture taking into consideration their
graph, Pie chart, graph of a function internal properties.
on rectangular coordinates etc. Graphs can be used to determine
Graphs are used to several real- whether a circuit can be implemented
world situations like road map, on a planar board or not,
chemical structure of a molecule, identification of chemical compounds
organization charts, communication with the same molecular formula but
lines etc. different structures, route problems
etc.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Graph Edge
A graph 𝐺 written as 𝐺 ≡ 𝐺 𝑉, 𝐸 ,
𝑒
consists of a set 𝑉, called the set of 𝑢 𝑣
nodes (or points or vertices) of the graph
and a set 𝐸, called the set of lines or arcs
(or edges) such that each edge 𝑒𝜖𝐸 is
associated with ordered or unordered Vertex
pairs of elements of 𝑉.
In other words, each edge say 𝑒 is
associated with a pair of vertices 𝑢, 𝑣 ,
where 𝑢 and 𝑣 are called end vertices of
the edge 𝑒. We may denote this edge as
𝑒 = 𝑢, 𝑣 .
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Any pair of nodes, that is connected by an edge in a graph are called as adjacent
nodes.
If a node is not adjacent to any node, then the node is called as isolated node.
In the following graph, 𝑎 𝑎𝑛𝑑 𝑑, 𝑎 𝑎𝑛𝑑 𝑐, 𝑎 𝑎𝑛𝑑 𝑒, 𝑏 𝑎𝑛𝑑 𝑑, 𝑏 𝑎𝑛𝑑 𝑒, 𝑐 𝑎𝑛𝑑 𝑒 are
adjacent nodes (as they are connected directly) whereas
𝑎 𝑎𝑛𝑑 𝑏, 𝑑 𝑎𝑛𝑑 𝑒, 𝑏 𝑎𝑛𝑑 𝑐 are not adjacent nodes (as they are not connected
directly). The node 𝑓 is an isolated node.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Finite and Infinite Graph
A graph is said to be finite if it has finite number of vertices and edges. A graph
which has finite number of vertices, must have finite number of edges.
If a graph is not a finite graph, then it is an infinite graph.
Order and Size of a Graph
If G is a finite graph, then, 𝑉(𝐺) denotes the number of vertices in the graph
G and is called the order of the graph G.
𝐸(𝐺) denotes the number of edges in the graph G and is called the size of the
graph G.
We shall often refer to a graph of order 𝑛 and size 𝑚 as an 𝑛, 𝑚 graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Undirected Graph
An undirected graph G consists of vertex set V of vertices of G and edge set E of
edges of G such that each edge 𝑒𝜖𝐸 is associated with an unordered pair of
vertices. [i.e the direction of edges are not shown in the graph]
In the adjacent graph, as the directions of edges are
not mentioned, so, it is an undirected graph.
For example, 𝑒1 is an edge in the graph, which joins
the vertices 𝑎 and 𝑒 but the direction is not known
[i.e. whether the edge is from 𝑎 to 𝑒 or 𝑒 to 𝑎]. The
pair of vertices 𝑎, 𝑏 is an unordered pair of
vertices.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Directed Graph
A directed graph or digraph G consists of a set V of vertices and a set E of edges
such that each edge 𝑒𝜖𝐸 is associated with an ordered pair of vertices. [i.e. the
direction of the edges are mentioned in the graph G]
The adjacent graph is a directed graph as the
direction of edges are mentioned.
If 𝑒 = 𝑢, 𝑣 is a directed edge in a digraph, then
1. 𝑢 and 𝑣 are called as initial and terminal
vertices of the edge, respectively.
2. The edge is incident from 𝑢 and incident to 𝑣.
3. 𝑢 and 𝑣 are adjacent to each other.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Degree of a Vertex
The degree of a vertex in an undirected graph is the number of edges incident
with it, except that a loop at a vertex counted twice in the counting of the degree
of the vertex.
The degree of a vertex 𝑣 in a graph G is denoted
by deg G 𝑣 .
Vertex Degree Vertex Degree
𝑣1 deg G 𝑣1 = 4 𝑣4 deg G 𝑣4 = 4
𝑣2 deg G 𝑣2 = 4 𝑣5 deg G 𝑣5 = 1
𝑣3 deg G 𝑣3 = 3 𝑣6 deg G 𝑣6 = 0
If the degree of a vertex in a graph is one, then the
vertex is called as Pendent vertex. e.g. 𝑣5
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
The degree of a vertex in a directed graph has the same concept as in the
undirected graph that it is the number of edges incident with it. But the edge
which incident on the vertex, produced the indegree of the vertex and the edge
incident from the vertex, produced the outdegree of the vertex.
The total of indegree and outdegree of a vertex is the total degree of a vertex in
a directed graph.
The indegree of a vertex 𝑣 and out degree of a vertex 𝑣 in a graph 𝐺 are denoted
by deg 𝐺− 𝑣 and deg 𝐺+ 𝑣 respectively.
A vertex with zero indegree is called as source and the vertex with zero
outdegree is called as sink.
Even and Odd Vertex
A vertex is called even vertex if its degree is even and called odd vertex if its
degree is odd.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Vertex Indegree Outdegree Total
Ex. Find the indegree, outdegree and
Degree
total degree of each vertex in the
following graph. 𝑣1 0 2 2
𝑣2 2 1 3
𝑣3 3 1 4
𝑣4 1 1 2
𝑣5 1 2 3
𝑣6 0 0 0
Total 7 7 14
Even Vertex 𝑣1 , 𝑣3 , 𝑣4
Odd Vertex 𝑣2 , 𝑣5
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Draw the undirected and directed graph 𝐺 𝑉, 𝐸 , where 𝑉 = 𝑎, 𝑏, 𝑐, 𝑑 and
𝐸 = 𝑒1 = 𝑎, 𝑏 , 𝑒2 = 𝑏, 𝑐 , 𝑒3 = 𝑐, 𝑑 , 𝑒4 = 𝑑, 𝑎 , 𝑒5 = 𝑏, 𝑎 , 𝑒6 = 𝑑, 𝑑 .
Also find the degree of each vertex.
Sol. Undirected Graph
Vertex Degree
𝑎 deg G 𝑎 = 3
𝑏 deg G 𝑏 = 3
𝑐 deg G 𝑐 = 2
𝑑 deg G 𝑑 = 4
Even Vertex 𝑐, 𝒅
Odd Vertex 𝑎, 𝑏
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Directed Graph Vertex Indegree Outdegree Total
Degree
𝑎 2 1 3
𝑏 1 2 3
𝑐 1 1 2
𝑑 2 2 4
Total 6 6 12
Even Vertex 𝑐, 𝒅
Odd Vertex 𝑎, 𝑏
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Hand Shaking Theorem
Th. The sum of the degrees of vertices in an undirected graph is even.
Proof: As the degree of a vertex in an undirected graph is the number of edges
incident on it. The sum of degree counts the total number of times an edge is
incident with the vertex.
As for an undirected graph, every edge is incident exactly with two vertices, so
each edge get counted twice. Thus, the sum of degrees equal to twice the
number of edges, which is an even number.
The above theorem holds this rule that, if several people shake hands, the total
number of people shake hands must be even. Due to this theorem is called as
“Hand Shaking Theorem”.
Corollary: In an undirected graph, the total number of odd degree vertices are
even.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Th. The sum of the indegree of all the vertices of a directed graph G is equal to
the sum of outdegree of all the vertices of the graph and is equal to the number
of edges.
Proof: We know that any directed edge 𝑒 = 𝑢, 𝑣 contributes 1 to indegree of 𝑣
and 1 to outdegree of 𝑢. Also, a loop at any vertex 𝑣 contributes 1 to indegree of
𝑣 and 1 to outdegree of 𝑣. So
deg 𝐺− 𝑣 = deg + 𝐺 𝑣 = number of edges
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Self-Loop or Loop in a Graph
An edge of a graph that joins a node
itself is called a loop or self-loop.
Module 4: Graphs - I
Simple Graph Th. A simple graph with atleast two
A graph which has neither self-loop (or vertices has atleast two vertices of
loop) nor multiple edges, is called a same degree.
simple graph. Proof: Let G is a simple graph with
𝑛 ≥ 2 vertices. Then the graph has no
loop and parallel edges. Hence, the
degree of each vertex be less than or
equal to 𝑛 − 1 .
Let us suppose that the degree of all
the vertices of the graph G are
different and possibly
0,1,2,3, … , 𝑛 − 1
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Let 𝑢 be the vertex from the graph G So, the degree of 𝑢 either 1 or 2 or 3 or
with zero degree, i.e. 𝑢 is an isolated … or 𝑛 − 1 .
vertex and not adjacent to any of the Which shows that a simple graph,
vertex of G. containing atleast two vertices, have
Let 𝑣 be any vertex from the graph G atleast two vertices of same degree.
with degree 𝑛 − 1 . Note:
As, G is a simple graph, so none of its The converse of the above theorem is
vertex has loop on it. So, the vertex 𝑣 is not true.
not adjacent to itself.
This means, the vertex is adjacent to
the vertex 𝑢.
Which indicates that the vertex 𝑢 is not
an isolated vertex.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Th. The degree of a vertex of a simple graph G with ‘𝑛’ vertices cannot exceed
𝑛−1 .
Proof: We know that a simple graph don’t have any loop or multiple edges, so
any vertex can’t be adjacent to itself.
If the graph has ‘𝑛’ vertices, then for the simple graph, a vertex can be adjacent
to all the vertices except itself.
i.e. any of the vertex can be adjacent to maximum 𝑛 − 1 vertices.
Therefore, the degree of any vertex in that graph G can’t exceed 𝑛 − 1 .
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Th. The maximum number of edges in a ⇒ 𝑑𝑒𝑔𝐺 𝑣1 + 𝑑𝑒𝑔𝐺 𝑣2 + ⋯
simple graph with ‘𝑛’ vertices be + 𝑑𝑒𝑔𝐺 𝑣𝑛 = 2𝑒 … (1)
𝑛 𝑛−1 Also, we know that the degree of any
2 vertex in a simple graph with ‘𝑛’ number
Proof: Let G is a simple graph with ‘𝑛’ of vertices can’t exceed 𝑛 − 1 .
number of vertices and ‘𝑒’ number of i.e. maximum degree of any vertex in a
edges. simple graph with ‘𝑛’ number of vertices
We know that the total degree of be 𝑛 − 1 .
vertices in the graph G is From (1), we have
𝑛
𝑛 − 1 + 𝑛 − 1 + ⋯ + 𝑛 − 1 = 2𝑒
𝑑𝑒𝑔𝐺 𝑣𝑗 = 2𝑒 ⇒ 𝑛 𝑛 − 1 = 2𝑒
𝑗=1 𝑛 𝑛−1
⇒𝑒=
2
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Degree Sequence of a Graph
For any graph 𝐺(𝑉, 𝐸), we define
𝛿 𝐺 = 𝑚𝑖𝑛 𝑑𝑒𝑔𝐺 𝑣 ; 𝑣𝜖𝑉
∆ 𝐺 = 𝑚𝑎𝑥 𝑑𝑒𝑔𝐺 𝑣 ; 𝑣𝜖𝑉
If 𝑣1 , 𝑣2 , … , 𝑣𝑛 are ‘𝑛’ vertices of the graph G with the respective degrees
𝑑1 , 𝑑2 , … , 𝑑𝑛 , then the sequence
𝛿 𝐺 = 𝑑1 ≤ 𝑑2 ≤ ⋯ ≤ 𝑑𝑛 = ∆ 𝐺
is called the degree sequence of the graph G.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Find the degree sequence of the following graph.
Module 4: Graphs - I
Ex. Determine, which of the following can be a degree sequence of a possible
graph.
(i) 0,2,2,3,4 (ii) 1,1,2,3 (iii) 2,2,4,6 (iv) 2,2,3,4,5,5
(v) 1,3,3,4,5,6,6
Sol. (i) Not possible, as for a graph, total number of odd degree vertices must be
even, but here one vertex is present which is of odd degree. (The total degree of
a graph must be even.)
(ii) Not possible. The reason is same as for (i).
(iii) Graph is possible.
Here, the graph contains n = 4 vertices and one vertex is of degree 4(= 𝑛) and
one vertex is of the degree 6(> 𝑛). Therefore, this graph cannot be a simple
graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
(iv) Graph is possible. Also, a simple graph is possible.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Show that for the degree sequence 1,1,3,3, the simple graph is not possible.
Sol. Let the set of vertices of the given graph is 𝑉 = 𝑎, 𝑏, 𝑐, 𝑑 .
Let 𝑑𝑒𝑔𝐺 𝑎 = 3, 𝑑𝑒𝑔𝐺 𝑏 = 3, 𝑑𝑒𝑔𝐺 𝑐 = 1, 𝑑𝑒𝑔𝐺 𝑑 = 1.
𝑑𝑒𝑔𝐺 𝑎 = 3, it means the vertex 𝑎 is adjacent to three vertices. If the graph is a
simple graph, then the vertex 𝑎 will be adjacent to all the vertices of the graph
except itself and no multiple adjacency is possible. The similar case is for vertex
𝑏. Therefore, the vertex 𝑎 is adjacent to 𝑏, 𝑐, 𝑑 and vertex 𝑏 is adjacent to 𝑎, 𝑐, 𝑑.
It indicates that 𝑑𝑒𝑔𝐺 𝑐 ≥ 2 and 𝑑𝑒𝑔𝐺 𝑑 ≥ 2, which do not meet with the
given degree sequence.
Hence, for the given degree sequence, a simple graph is not possible.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Havel – Hakimi Algorithm
This algorithm help us to find that a given degree sequence represents a simple
graph or not. This algorithm based on the following theorem.
Let 𝑆 = (𝑠, 𝑏1 , 𝑏2 , … , 𝑏𝑠 , 𝑑1 , 𝑑2 , … , 𝑑𝑛 ) be the degree sequence in the non-
increasing order. The sequence is graphic (the graph is a simple graph) if and only
if the sequence 𝑆 ′ = (𝑏1 − 1, 𝑏2 − 1, … , 𝑏𝑠 − 1, 𝑑1 , 𝑑2 , … , 𝑑𝑛 ) is graphic.
Following is the step-by-step process of the algorithm.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
S1: Arrange the given degree sequence in a non-increasing order.
For example, let us write the degree sequence as
𝑆 = (𝑠, 𝑏1 , 𝑏2 , … , 𝑏𝑠 , 𝑑1 , 𝑑2 , … , 𝑑𝑛 )
Where, 𝑠 ≤ 𝑏1 ≤ 𝑏2 ≤ ⋯ ≤ 𝑏𝑠 ≤ 𝑑1 ≤ 𝑑2 ≤ ⋯ ≤ 𝑑𝑛 .
S2: left the first value (𝑠 here) and subtract 1 from next 𝑠 values and write the new
sequence as
𝑆 ′ = (𝑏1 − 1, 𝑏2 − 1, … , 𝑏𝑠 − 1, 𝑑1 , 𝑑2 , … , 𝑑𝑛 )
S3: Write this sequence in non-decreasing order if it is not.
S4: Proceed the steps S2 and S3 until we left with zeros. In this case the degree
sequence is related with a simple graph.
S5: By proceeding with S2 and S3 if we get −1 for any value at any step, then it is
indicating that the given degree sequence is not related to a simple graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Find whether the degree sequence
2,2,2,3,3,5,5 is related to a simple
graph.
Sol. As per Havel Hakimi algorithm, let us
write the given degree sequence in non-
increasing order
𝑆1 = 5𝑎, 5𝑏, 3𝑐, 3𝑑, 2𝑒, 2𝑓, 2𝑔 .
[To understand let us mark these vertices Subtract 1 from the next 5 values
as 𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓, 𝑔 and put like the (the vertices 𝑏, 𝑐, 𝑑, 𝑒, 𝑓 are marked
adjacent figure]
adjacency with the vertex 𝑎 and kept
As per the step S2 of the algorithm, we the value for the vertex 𝑔 as it is (as
will leave the first value (as we have
marked the 5 degree of the vertex 𝑎) and it is not marked for the adjacency
with the vertex 𝑎.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
The new sequence is
𝑆2 = ∗, 4𝑏, 2𝑐, 2𝑑, 1𝑒, 1𝑓, 2𝑔
which is not in the non-decreasing order,
so, let us write in that order as
𝑆2′ = ∗, 4𝑏, 2𝑐, 2𝑑, 2𝑔, 1𝑒, 1𝑓
Now let us do the same process of step
S2 for the sequence 𝑆2′ and get the new
sequence as
𝑆3 = ∗,∗, 1𝑐, 1𝑑, 1𝑔, 0𝑒, 1𝑓
which is not in the non-decreasing order, We can see the position of edges in
so, let us write in that order as the above picture.
𝑆3′ = ∗,∗, 1𝑐, 1𝑑, 1𝑔, 1𝑓, 0𝑒
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Now let us do the same process of step As the condition of the algorithm is
S2 for the sequence 𝑆3′ and get the new satisfied, so the simple graph for the
sequence as given degree sequence is possible.
𝑆4 = ∗,∗,∗, 0𝑑, 1𝑔, 1𝑓, 0𝑒 The graph is like the following graph,
which is not in the non-decreasing and it is a simple graph.
order, so, let us write in that order as
𝑆4′ = ∗,∗,∗, 1𝑔, 1𝑓, 0𝑑, 0𝑒
Now let us do the same process of step
S2 for the sequence 𝑆4′ and get the new
sequence as
𝑆5 = ∗,∗,∗,∗, 0𝑓, 0𝑑, 0𝑒
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Check if the degree following Now applying the algorithm for second
sequence is a graphic. value, we get 𝑆3 = ∗,∗, 3,3,1,0,1 ,
2,2,2,5,5,5,5 which is not in non-increasing order, so
Sol. By using Havel Hakimi algorithm, let us write it in the form as
let us write the given degree sequence 𝑆3′ = ∗,∗, 3,3,1,1,0
in non-increasing order as Now applying the algorithm for third
𝑆1 = 5,5,5,5,2,2,2 value, we get 𝑆4 = ∗,∗,∗, 2,0,0,0 ,
Using the algorithm for first value, we which is in non-increasing order.
get 𝑆2 = ∗, 4,4,4,1,1,2 , which is not Now applying the algorithm for fourth
in non-increasing order, so let us write value, we get 𝑆5 = ∗,∗,∗,∗, −1, −1,0 .
it in the form as Therefore, the given degree sequence
𝑆2′ = ∗, 4,4,4,2,1,1 is not a graphic.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Matrix Representation of Undirected Ex. Represent following graph in matrix
Graphs form
Let 𝐺 𝑉, 𝐸 be a simple undirected
graph on ‘𝑛’ vertices 𝑖 = 1,2,3, … , 𝑛,
then the 𝑛 × 𝑛 matrix 𝐴(𝐺), associated
with the graph G, called adjacency
matrix, is defined as
1 if 𝑖, 𝑗 𝜖𝐸
𝐴 𝐺 = 𝑎𝑖𝑗 ; 𝑎𝑖𝑗 = ቊ
0 Otherwise
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Sol. The set of vertices is 𝑉 = 𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓, 𝑔 and the set of edges
𝐸 = ሼ 𝑎, 𝑏 , 𝑎, 𝑐 , 𝑎, 𝑑 , 𝑎, 𝑔 , 𝑏, 𝑐 , 𝑏, 𝑔 , 𝑐, 𝑑 , 𝑐, 𝑒 ,
𝑐, 𝑔 , 𝑑, 𝑔 , 𝑒, 𝑔 , 𝑔, 𝑓 ሽ
𝒂 𝒃 𝒄 𝒅 𝒆 𝒇 𝒈
𝒂 0 1 1 1 0 0 1
𝒃 1 0 1 0 0 0 1
𝒄 1 1 0 1 1 0 1
𝐴 𝐺 =
𝒅 1 0 1 0 0 0 1
𝒆 0 0 1 0 0 0 1
𝒇 0 0 0 0 0 0 1
𝒈 1 1 1 1 1 1 0
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Write the matrix representation of the following graph
Sol. For the given graph, the vertex set V and edge set E are as
𝑉 = 𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 , 𝑣5 , 𝑣6 , 𝑣7 , 𝑣8
𝐸 = ሼ 𝑣1 , 𝑣1 , 𝑣1 , 𝑣2 , 𝑣1 , 𝑣3 , 𝑣2 , 𝑣3 , 𝑣3 , 𝑣4 , 𝑣4 , 𝑣5 , 𝑣4 , 𝑣6 ,
𝑣5 , 𝑣6 , 𝑣6 , 𝑣8 ሽ
The related matrix of the graph is
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
𝒗𝟏 𝒗𝟐 𝒗𝟑 𝒗𝟒 𝒗𝟓 𝒗𝟔 𝒗𝟕 𝒗𝟖
𝒗𝟏 1 1 1 0 0 0 0 0
𝒗𝟐 1 0 1 0 0 0 0 0
𝒗𝟑 1 1 0 1 0 0 0 0
𝐴 𝐺 = 𝒗𝟒 0 0 1 0 1 1 0 0
𝒗𝟓 0 0 0 1 0 1 0 0
𝒗𝟔 0 0 0 1 1 0 0 1
𝒗𝟕 0 0 0 0 0 0 0 0
𝒗𝟖 0 0 0 0 0 1 0 0
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
1 1 1 0 0 0 0 0
1 0 1 0 0 0 0 0
1 1 0 1 0 0 0 0
𝐴 𝐺 = 0 0 1 0 1 1 0 0
0 0 0 1 0 1 0 0
0 0 0 1 1 0 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Types of Graphs
Null Graph Complete Graph
A graph which contains only isolated A simple graph G is said to be a
node(s), is called a null graph. complete graph if every vertex of the
i.e. the set of edges in a null graph is graph is adjacent to each of the other
empty set. vertices.
Null graph on ‘𝑛’ vertices is denoted by i.e. the graph G contains exactly one
𝑁𝑛 . edge between distinct pair of vertices.
A Complete graph on ‘𝑛’ vertices is
denoted by 𝐾𝑛 .
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Note:
1. In the complete graph 𝐾𝑛 , the degree
of each vertex is 𝑛 − 1 .
2. The total degree of the graph 𝐾𝑛 is
n 𝑛−1 .
𝐾3 𝐾5
3. The exact number of edges in the
n 𝑛−1
graph 𝐾𝑛 are .
2
Some examples of complete graphs are:
𝐾6
𝐾2
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Regular Graph
A graph G is said to be a regular graph
if every vertex of the graph is of same
degree.
Note:
1. Every complete graph is a regular
graph, but its converse is not
necessarily true.
The adjacent graph is a regular graph 2. If in a regular graph, degree of
as each of the vertex is of degree 2, but each vertex is ‘𝑟’, then it is called as
this is not a complete graph. 𝑟-regular graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
3. If 𝐺 is a 𝑟 −regular graph with ‘𝑛’
vertices, then the graph has (𝑛𝑟/2)
number of edges.
Pseudograph
A graph 𝐺(𝑉, 𝐸) is said to be a
pseudograph, if V is nonempty and the
graph has self-loops (or loops) and/or Multigraph
multiple edges. A multigraph is a pseudograph without
loops.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Cycle or Cyclic Graph
A graph is said to be cycle or cyclic graph if it contains vertices and edges in such
a way that they makes a cycle.
The cycle graph on 𝑛 vertices 𝑉 = ሼ𝑣1 , 𝑣2 , … , 𝑣𝑛 ሽ and edges
𝐸 = 𝑣1 , 𝑣2 , 𝑣2 , 𝑣3 , 𝑣3 , 𝑣4 , 𝑣4 , 𝑣5 , … 𝑣𝑛−1 , 𝑣𝑛 , 𝑣𝑛 , 𝑣1 is denoted by
𝐶𝑛 ; 𝑛 ≥ 3.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Bipartite Graph
A graph 𝐺(𝑉, 𝐸) is called a Bipartite graph if the vertex set 𝑉 can be partitioned in
two disjoint subsets 𝑉1 and 𝑉2 such that every edge in 𝐸 connects a vertex of 𝑉1
and a vertex of 𝑉2 .
Module 4: Graphs - I
Ex. Check whether the following two graphs are bipartite.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Sol. Let us redraw the graph 𝐺 𝑉1 , 𝐸1 It can be observed that the vertex set
as 𝑉1 can be partitioned into two sets
′ ′′
𝑉1 = 𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 and 𝑉1 =
𝑦1 , 𝑦2 , 𝑦3 .
No edge in the graph
𝐺 𝑉1 , 𝐸1 connects neither the vertices
of 𝑉1 ′ nor the vertices of 𝑉1 ′′ , but the
′
edges connects the vertices of 𝑉1 and
𝑉1 ′′ .
Therefore, the graph 𝐺 𝑉1 , 𝐸1 is a
bipartite graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Let us redraw the graph 𝐺 𝑉2 , 𝐸2 as It can be observed that the vertex set
𝑉2 can be partitioned into two sets
′ ′′
𝑉2 = 𝑥1 , 𝑥2 , 𝑥3 , 𝑥4 and 𝑉2 =
𝑦1 , 𝑦2 , 𝑦3 , 𝑦4 .
No edge in the graph 𝐺 𝑉2 , 𝐸2
connects neither the vertices of 𝑉2 ′ nor
the vertices of 𝑉2 ′′ , but the edges
′ ′′
connects the vertices of 𝑉2 and 𝑉2 .
Therefore, the graph 𝐺 𝑉2 , 𝐸2 is a
bipartite graph.
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Complete Bipartite Graph This complete bipartite graph 𝐺(𝑉, 𝐸)
A bipartite graph 𝐺(𝑉, 𝐸) is said to be with the two partitioned vertex set 𝑉1
complete bipartite graph if each vertex and 𝑉2 such that 𝑉1 = 𝑚 and 𝑉2 =
of the partitioned vertex set 𝑉1 ( 𝑉1 = 𝑛 is denoted by 𝐾𝑚,𝑛 .
𝑚) is connected with each vertex of Some of the examples of complete
the partitioned vertex set 𝑉2 𝑉2 = 𝑛 . bipartite graphs are
Or, in other words, if for a bipartite
graph 𝐺(𝑉, 𝐸) the partitioned vertex
set 𝑉1 and 𝑉2 are such that 𝑉1 = 𝑚
and 𝑉2 = 𝑛 and there is an edge
between each pair of vertices 𝑣1 𝜖𝑉1
and 𝑣2 𝜖𝑉2 .
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Ex. Show that the graph 𝐾𝑚,𝑚 is Therefore, the degree of each vertex of
regular. the vertex sets 𝑉1 and 𝑉2 is equal and it
Sol. As we know that a graph in which is 𝑚.
the degree of each vertex is same, is Hence, the graph 𝐾𝑚,𝑚 is a regular
called a regular graph. graph.
The complete bipartite graph 𝐾𝑚,𝑚 has
two distinct vertex sets 𝑉1 and 𝑉2 such
that 𝑉1 = 𝑚 and 𝑉2 = 𝑚.
As per the definition of complete
bipartite graph, each vertex of 𝑉1
connected with all the vertices of 𝑉2
and similarly each vertex of 𝑉2
connected with all the vertices of 𝑉1 .
MA1002 - COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Weighted Graph
A graph in which capacities, distances, probabilities etc. are assigned to every
edge, is called a weighted graph. These assigned values are called weights of
edges.
MA1002 – COMPUTATIONAL MATHEMATICS
Module 4: Graphs - I
Summary
In this topic, you learnt: