Adjacency Matrix for Directed and Unweighted graph
Consider an Directed and Unweighted graph G with 4 vertices and 4 edges. For the graph G, the adjacency matrix would look like:
Here’s how to interpret the matrix:
- A[0][1] = 1, there is an edge between vertex 0 and vertex 1.
- A[1][2] = 1, there is an edge between vertex 1 and vertex 2.
- A[2][3] = 1, there is an edge between vertex 2 and vertex 3.
- A[3][1] = 1, there is an edge between vertex 3 and vertex 1.
- A[i][i] = 0, as there are no self loops on the graph.
- All other entries with a value of 0 indicate no edge between the corresponding vertices.
Adjacency Matrix of Directed Graph
Adjacency Matrix of a Directed Graph is a square matrix that represents the graph in a matrix form. In a directed graph, the edges have a direction associated with them, meaning the adjacency matrix will not necessarily be symmetric.
In a directed graph, the edges have a direction associated with them, meaning the adjacency matrix will not necessarily be symmetric. The adjacency matrix A of a directed graph is defined as follows: