In graph theory, the adjacency matrix [1][2] of a graph is a square matrix indexed by the vertex set, whose entries record which pairs of vertices are adjacent. Together with the incidence matrix, it is one of the standard matrix graph representations.

Definition


Definition 1 (Adjacency matrix)

Let be a graph with vertex set . An adjacency matrix of is an square matrix , with rows and columns indexed by , such that

and if and are adjacent. The concrete nonzero value depends on the class of graph under consideration.

Corollary 1 (Walk count)

For every , the entry of equals the number of walks of length from to in .

Variants


Each of the following variants specializes Definition 1 to a class of graphs by fixing what the nonzero entries record.

Undirected graph


Definition 2 (Adjacency matrix of an undirected graph)

For a simple undirected graph with vertex set and edge set , the adjacency matrix is the square binary matrix given by

Properties


Lemma 1 (Symmetry)

The adjacency matrix of a simple undirected graph is symmetric.

Examples


Example 1 (Cycle graph )

For the cycle graph given by with and , the adjacency matrix is

By Corollary 1, the entries of count walks of length :

For instance, counts the two walks of length from back to itself, and , while reflects that no walk of length joins and .

Directed graph


Definition 3 (Adjacency matrix of a directed graph)

For a directed graph with vertex set , the adjacency matrix is the square matrix given by

Properties


Lemma 2 (Asymmetry)

The adjacency matrix of a directed graph need not be symmetric.

Examples


Example 2 (Directed cycle graph)

For with and , the adjacency matrix is

which is not symmetric, in agreement with Lemma 2. By Corollary 1, the entries of count walks of length :

For instance, counts the unique walk of length from to , namely , while reflects that there is no walk of length from back to itself.

Bipartite graph


Definition 4 (Adjacency matrix of a bipartite graph)

Let be a bipartite graph with vertex set such that , where and , so . Let be the vertices of listed with first and second, so for and for . The adjacency matrix of is the square matrix , with rows and columns indexed by , given by

Properties


The bipartite vertex ordering forces the top-left and bottom-right blocks of to vanish, since no edge joins two vertices within or within .

Lemma 3 (Bipartite block structure)

With rows and columns ordered as followed by , the adjacency matrix of a bipartite graph has the block form

where is the matrix with if and otherwise.

Examples


Example 3 (Complete bipartite graph )

For the complete bipartite graph with , , and , ordering rows and columns as , the adjacency matrix is

References

  1. [1]

    “Adjacency matrix”, Wikipedia, Available: https://en.wikipedia.org/wiki/Adjacency_matrix, Accessed: 2026-07-15 ↩

  2. [2]

    “Adjacency Matrix”, Wolfram MathWorld, Available: https://mathworld.wolfram.com/AdjacencyMatrix.html, Accessed: 2026-07-15 ↩