Graph Part 3
Graph Part 3
Representation of Graphs
There are two principal ways to represent a graph G with the matrix, i.e., adjacency matrix and
incidence matrix representation.
If there exists an edge between vertex vi and vj, where i is a row and j is a column then the value of
aij=1.
https://www.javatpoint.com/representation-of-graphs 2/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
Solution: Since graph G consist of four vertices. Therefore, the adjacency matrix wills a 4 x 4 matrix.
The adjacency matrix is as follows in fig:
There is a row for every vertex and a column for every edge in the incident matrix.
The number of ones in an incidence matrix of the undirected graph (without loops) is equal to the
sum of the degrees of all the vertices in a graph.
Example: Consider the undirected graph G as shown in fig. Find its incidence matrix MI.
https://www.javatpoint.com/representation-of-graphs 3/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
Solution: The undirected graph consists of four vertices and five edges. Therefore, the incidence
matrix is an 4 x 5 matrix, which is shown in Fig:
1. Adjacency Matrix Representation: If a directed graph G consists of n vertices then the adjacency
matrix of a graph is an n x n matrix A = [aij] and defined by
If there exists an edge between vertex Vi and Vj, with Vi as initial vertex and Vj as a final vertex, then
the value of aij=1.
If there is no edge between vertex Vi and Vj, then the value of aij=0.
https://www.javatpoint.com/representation-of-graphs 4/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
The number of ones in the adjacency matrix of a directed graph is equal to the number of edges.
Example: Consider the directed graph shown in fig. Determine its adjacency matrix MA.
Solution: Since the directed graph G consists of five vertices. Therefore, the adjacency matrix will be a
5 x 5 matrix. The adjacency matrix of the directed graphs is as follows:
https://www.javatpoint.com/representation-of-graphs 5/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
2. Incidence Matrix Representation: If a directed graph G consists of n vertices and m edges, then
the incidence matrix is an n x m matrix C = [cij] and defined by
The number of ones in an incidence matrix is equal to the number of edges in the graph.
Example: Consider the directed graph G as shown in fig. Find its incidence matrix MI.
Solution: The directed graph consists of four vertices and five edges. Therefore, the incidence matrix
is a 4 x 5 matrix which is show in fig:
https://www.javatpoint.com/representation-of-graphs 6/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
(c)Representation of Multigraph:
If there exist one or more than one edges between vertex vi and vj then aij=N, where is the number of
edges between vi and vj.
Example: Consider the multigraph shown in Fig, Determine its adjacency matrix.
https://www.javatpoint.com/representation-of-graphs 7/12
1/7/23, 12:35 PM Representation of Graphs - javatpoint
Solution: Since the multigraph consist of five vertices. Therefore the adjacency matrix will be an 5 x 5
matrix. The adjacency matrix of the multigraph is as follows:
← Prev Next →
https://www.javatpoint.com/representation-of-graphs 8/12