DMGT_CO5_Matrix Representation of Graphs
DMGT_CO5_Matrix Representation of Graphs
Dr.E.Prasad
Asst Professor, Dept of Mathematics
VIT Bhopal
Module Title
Module-5. Matrix representation of graphs
Syllabus
Part-1
Graph Matrices
Let G be a graph with n vertices, m edges and without self-loops. The incidence matrix A of
G is an nXm matrix A = [𝑎𝑖𝑗 ] whose n rows correspond to the n vertices and the m columns
correspond to m edges such that
Ans:
Example2:
Exercise2:
Let G be a graph with n vertices, m edges and without self-loops. The incidence matrix of
G is an nXm matrix B= [𝑏𝑖𝑗 ] whose n rows correspond to the n vertices and the m columns
correspond to m edges such that
Example3
Ans(a)
Exercise2
Example5
Exercise3
*Theorem1:
If A is an Incidence matrix of the directed graph G then the number of trees = 𝐴𝐴𝑇
Example6:Find the incidence matrix of the following graphs and also find its number of tree
Sol:
Properties1:
A complete incidence matrix [A]ij a graph has some properties by which one can
identify whether the given matrix is a complete incidence matrix or not. These
properties are:
1. The sum of values of [A]ij of any column is equal to zero.
2. For a closed loop system, the determinant of [A]ij is always zero.
3. The rank of the complete incidence matrix [A]ij is n-1 where n=number of nodes in
the graph.
Sol :
Example8
Example8
Ans:
Example 9
Ans:
Definition 6
Example 10
Ans:
Properties:https://www.geneseo.edu/~aguilar/public/notes/Graph-Theory-HTML/ch2-the-
adjacency-matrix.html
7. Adjacency Matrix-Undirected
The adjacency matrix is symmetric, which will be true for the adjacency matrix of any undirected
graph
Example 12
Example 13
Example 14
8. Adjacency Matrix-directed
An adjacency matrix for a directed graph will not necessarily be symmetric, because an arc
from ni to nj does not imply an arc from nj and ni
Example 15
Example 16
Example 17
Definition. We say that a graph G is k-colorable if we can assign the colors1 {1, . . . k} to the
vertices in V (G), in such a way that every vertex gets exactly one color and no edge in E(G)
has both of its endpoints colored the same color. We call such a coloring a proper coloring,
though sometimes where it’s clear what we mean we’ll just call it a coloring. Alternately,
such graphs are sometimes called k-partite.
For a fixed graph G, if k is the smallest number such that G admits a k-coloring, we say that
the chromatic number of G is k, and write χ(G) = k.
https://www.gatevidyalay.com/graph-coloring-algorithm-how-to-find-chromatic-
number/
1.Complete Graph (Kn): The complete graph on n vertices has chromatic number n. To see that
it is at least n, simply paint each of the vertices {v1, . . . vn} of V (Kn) a different color (say, vi is
painted i;) then every edge trivially has two endpoints of different colors. To see that this is
necessary, take any proper coloring of Kn, and look at any vertex vi : because it’s connected to
every other vertex, it cannot be the same color as any other vertex (and therefore must have a
2. Bipartite graphs: By definition, every bipartite graph with at least one edge has chromatic
number 2.
The chromatic number of a graph G is the smallest number of colors needed to color the
vertices of so that no two adjacent vertices share the same color
The chromatic number of a graph G is most commonly denoted ꭓ (G), but occasionally
also γ(G)
Empty graphs have chromatic number 1, while non-empty bipartite graphs have chromatic
number 2
Directed Graphs
Connectivity in digraphs
Reference
1. https://www.lkouniv.ac.in/site/writereaddata/siteContent/202004160614287266anshu_s
ingh_engg_Graph_traversal.pdf
2. https://resources.mpi-
inf.mpg.de/departments/d1/teaching/ws14/AlgoDat/materials/components.pdf
3. https://www.sfu.ca/~arashr/parminder.pdf
4. https://www.javatpoint.com/bfs-vs-dfs
“Dijkstra’s Algorithm”
For
shortest path
-Undirected Graph
1. Ans. From A to F is 14
Ans. From S to B is 15
2.
Ans: From 0 to 8 is 11
3.
Ans: v1 to v6 is 80
4.
5.
Ans
6.
Ans
Ans:11
7.
8.
Ans.20
9.
Ans:14
10. Ans: 11
11.
Ans: 11
12.
Ans: 14
“Dijkstra’s Algorithm”
For
shortest path
-Directed Graph
1.
Ans. From S to B is 9
2.
Ans. From a to h is 161
3.
Ans. From A to E is 18
4. Ans. From 1 to 6 is 9
5.
Ans. From A to E is 18
“ Floyd- Warshall ”
For
shortest path Algorithm
(OR)
Robert Floyd and Stephen Warshall
Example1: Using Floyd Warshall Algorithm, find the shortest path distance between
every pair of vertices.
Ans:
Example2: Using Floyd Warshall Algorithm, find the shortest path distance between
every pair of vertices.
Ans:
Example3: Using Floyd Warshall Algorithm, find the shortest path distance between
every pair of vertices.
Ans:
Example4: Using Floyd Warshall Algorithm, find the shortest path distance between
every pair of vertices.
Example5: Using Floyd Warshall Algorithm, find the shortest path distance between
every pair of vertices.
Ans:
Example8:
Example6:
Example7: