Matrix Representation of Graphs

Matrix Representation of Graphs

In this post, you will learn how to represent a graph in matrix form. By using this concept we can easily create implementation of adjacency matrix.

If there is an edge between two vertices then we will represent it with 1 and if there is no edge then with 0.


Adjacency Matrix Representation of Graphs


For Undirected Graph:

Matrix Representation of Graphs


12345
101001
210100
301010
400101
510010

Directed Graphs:
Matrix Representation of Graphs


12345
100001
210000
301000
400100
500010

Load comments