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 .
Proof of Corollary 1
We proceed by induction on .
Base case (): By Definition 1, , which is nonzero exactly when and are adjacent, that is, exactly when the edge between them forms a walk of length from to .
Inductive step: assume counts the walks of length from to , for every . By matrix multiplication,
Every walk of length from to consists of a walk of length from to some vertex adjacent to , followed by the edge from to . Summing over every adjacent to therefore counts exactly the walks of length from to .
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.
Proof of Lemma 1
By Definition 2, iff and . Since , this condition is symmetric in and , so iff , and likewise iff . Hence for all , so .
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.
Proof of Lemma 2
By Definition 3, iff , while iff . A directed edge does not require the reverse edge , so it is possible to have while . Hence in general.
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.
Proof of Lemma 3
By definition of a bipartite graph, no edge joins two vertices of or two vertices of . By Definition 4, this means whenever or , so the top-left and bottom-right blocks of are zero. For , iff , which is exactly the entry , so the top-right block equals . By Lemma 1, is symmetric, so the bottom-left block equals .
Examples
Example 3 (Complete bipartite graph )
For the complete bipartite graph with , , and , ordering rows and columns as , the adjacency matrix is
References
- [1]
“Adjacency matrix”, Wikipedia, Available: https://en.wikipedia.org/wiki/Adjacency_matrix, Accessed: 2026-07-15 ↩
- [2]
“Adjacency Matrix”, Wolfram MathWorld, Available: https://mathworld.wolfram.com/AdjacencyMatrix.html, Accessed: 2026-07-15 ↩