Home
JEE Maths
Adjacency Matrix

Adjacency Matrix

Let aij denote the number of edges (Vi, Vj) then A = [aij]m×m is called adjacency matrix of G if

1.0Definition of Adjacency Matrix

In graph theory, an adjacency matrix is a square matrix that represents a finite graph. The elements of this matrix indicate whether pairs of vertices in the graph are connected by an edge. For a graph with n vertices, the adjacency matrix is an n × n matrix where the element Aij is:

  • 1 if an edge exists between vertex i and vertex j;
  • 0 if no edge exists between vertex i and vertex j.

This matrix representation provides a powerful tool for analyzing and manipulating graph structures, making it essential for studying various types of graphs, including undirected and directed graphs.

2.0Adjacency Matrix for Undirected Graphs

In an undirected graph, the edges are not directional, meaning the edge between two vertices is bidirectional. Consequently, the adjacency matrix for an undirected graph is symmetric. If there is an edge between vertices i and j, then both Aij and Aji will be 1.

Example: 

Consider an undirected graph with 4 vertices V = {A, B, C, D} and the following edges:

Adjacency Matrix for undirected graph

The adjacency matrix for this graph is:

Here, the matrix is symmetric about the diagonal, indicating the undirected nature of the graph.

3.0Adjacency Matrix for Directed Graphs

In a directed graph, the edges have a specific direction, meaning they go from one vertex to another and not necessarily in both directions. The adjacency matrix of a directed graph does not need to be symmetric.

Example: 

Consider a directed graph with 4 vertices V = {A, B, C, D} and the following directed edges:

Adjacency Matrix for directed graphs

The adjacency matrix for this graph is:

This matrix is not symmetric, which reflects the directed nature of the graph.

4.0Properties of Adjacency Matrices

  1. Symmetry: The adjacency matrix of an undirected graph is always symmetric.
  2. Diagonal Elements: In a simple graph, the diagonal elements of the adjacency matrix are 0, as there are no self-loops (no vertex is connected to itself)
  3. Sparsity: For large graphs, adjacency matrices are typically sparse, meaning most elements are 0, as the number of edges is usually much smaller than the number of possible connections.
  4. Degree of Vertices: For an undirected graph, the degree of a vertex can be calculated by summing the values in its corresponding row (or column, due to symmetry). For directed graphs, the out-degree is the sum of the row, and the in-degree is the sum of the column.

5.0Solved Examples on Adjacency Matrix

Example 1: Consider the undirected graph G as shown below. Find the Adjacency matrix.

Example question on adjacency matrix

Solutions:

Example 2: Find the Adjacency matrix of graph G.

Adjacency matrix directed graph questions

Solutions:


Example 3: Consider the undirected graph G as shown below. Find the Adjacency matrix.

Adjacency matrix for undirected graph

Solutions:


Example 4: Find the Adjacency matrix of the graph.

Example question of adjacency matrix directed graph

Solutions:


Example 5: Plot a graph given by the following adjacency matrix

Solutions:

Solution for adjacency matrix


Example 6: Write down the Adjacency matrix of graph G.

Sample practice question on adjacency matrix

Solutions:

6.0Practice Questions on Adjacency Matrix

  1. Construct the adjacency matrix for a directed graph with vertices V = {A, B, C, D}. 

Practice question on adjacency matrix

  1. Given the adjacency matrix below, determine whether the graph is directed or undirected:
  2. For a graph with vertices V = {P, Q, R, S} and the adjacency matrix:List all the edges of the graph and state whether it is directed or undirected.
  3. Construct the adjacency matrix for a directed graph with vertices V = {A, B, C, D, E}. 

Adjacency matrix's sample practice questions


Frequently Asked Questions

An adjacency matrix is a square matrix used to represent a graph. Each element indicates whether a pair of vertices is adjacent (connected by an edge) or not.

To construct an adjacency matrix, assign a 1 to the matrix element Aij if there's an edge between vertex i and vertex j; otherwise, assign a 0.

In an undirected graph, the adjacency matrix is symmetric, while in a directed graph, it is generally not symmetric, as it reflects the direction of edges.

Yes, an adjacency matrix can represent weighted graphs. Instead of using 1s and 0s, the matrix elements Aij are the weights of the edges. If there is an edge between vertices i and j; otherwise, assign a 0.

In a simple graph, diagonal elements are 0, indicating no self-loops. In other types of graphs, a non-zero diagonal element may represent a self-loop, where a vertex is connected to itself.

Adjacency matrices are commonly used in algorithms for graph traversal, finding the shortest path, detecting cycles, and more, due to their straightforward representation of vertex connections.

Join ALLEN!

(Session 2025 - 26)


Choose class
Choose your goal
Preferred Mode
Choose State