Adjacency matrix
Definition and Variations
Basic Definition
In graph theory, a graph consists of a set of vertices and a set of edges, where each edge is an unordered pair of distinct vertices from . A simple undirected graph is an unweighted, undirected graph containing no loops (edges connecting a vertex to itself) or multiple edges between the same pair of vertices.[4] The adjacency matrix of a simple undirected graph with vertex set is the square matrix defined by
where if there is an edge between vertices and , and otherwise.[5]
Since the graph is undirected, the adjacency matrix is symmetric, satisfying for all .[5] Additionally, the absence of loops in simple graphs ensures that the diagonal entries are zero, so for all .[5]
To construct the adjacency matrix, label the vertices in order from 1 to , then for each pair of distinct indices and with , check if an edge exists between vertices and ; if so, set , otherwise set , and set all diagonal entries .[6]
Bipartite Graphs
A bipartite graph is one whose vertex set can be partitioned into two disjoint subsets and such that every edge connects a vertex in to a vertex in , with no edges within or within .[7] The adjacency matrix of such a graph, assuming vertices are ordered with those in first followed by those in , is a square matrix featuring zero blocks on the diagonal corresponding to intra-partition connections and nonzero entries only in the off-diagonal blocks representing inter-partition edges.[8] Since the graph is undirected and simple, is symmetric with binary entries (0 or 1), and the upper off-diagonal block is the transpose of the lower one.[8] The submatrix in the upper off-diagonal block, denoted the biadjacency matrix , is a matrix where the entry if the -th vertex in is adjacent to the -th vertex in , and 0 otherwise; for multigraphs, entries count the edges between them.[7] The full adjacency matrix then takes the block form
where denotes the zero matrix.[8] This structure succinctly encodes the bipartition and edge constraints.
For the complete bipartite graph , where every vertex in the -vertex set connects to every vertex in the -vertex set, the biadjacency matrix is the all-ones matrix , making the off-diagonal blocks fully populated with 1s.[8] Thus, the adjacency matrix is
with .[8]
Directed and Weighted Graphs
In directed graphs, the adjacency matrix is defined such that its entry is 1 if there is a directed edge (arc) from vertex to vertex , and 0 otherwise.[9] Unlike the adjacency matrix of an undirected graph, which is symmetric (), the matrix for a directed graph is generally not symmetric, reflecting the potential asymmetry in edge directions ().[10] This representation captures the orientation of edges, making it suitable for modeling relationships with inherent directionality, such as one-way streets or dependencies in a network. For weighted graphs, the adjacency matrix extends to include edge weights, where if there is an edge from vertex to vertex with weight (typically a real number indicating strength, cost, or capacity), and 0 otherwise.[10] This formulation applies to both undirected and directed graphs; in the directed case, weights allow even if both directions exist, enabling the representation of asymmetric influences or flows. The weighted adjacency matrix thus generalizes the binary version, preserving structural information while incorporating quantitative edge attributes. Variations of the adjacency matrix accommodate specialized graph types. In signed graphs, where edges carry positive or negative signs to model agreement or conflict, for a positive edge from to , for a negative edge, and 0 otherwise, with the matrix remaining non-symmetric for directed signed graphs.[11] For multigraphs, which permit multiple edges between the same pair of vertices, equals the number of edges from to (or between them in the undirected case), allowing the matrix to count parallel connections rather than just their presence.[12] These adaptations maintain the core utility of the adjacency matrix while tailoring it to diverse applications in network analysis.Examples
Undirected Simple Graphs
In undirected simple graphs, the adjacency matrix is a symmetric $ n \times n $ matrix with zeros on the main diagonal (reflecting no self-loops) and ones in the off-diagonal positions corresponding to edges between distinct vertices. The complete graph $ K_n $, where every pair of distinct vertices is connected by an edge, has an adjacency matrix consisting of zeros on the diagonal and ones everywhere else; this can be expressed as $ J - I $, where $ J $ is the all-ones matrix and $ I $ is the identity matrix.[13] For example, the adjacency matrix of $ K_3 $ (a triangle) is
The cycle graph $ C_n $, consisting of $ n $ vertices connected in a single cycle, has an adjacency matrix that is circulant, with ones at positions $ (i, i+1) $ and $ (i, i-1) $ for $ i = 1, \dots, n $ (indices modulo $ n $) and zeros elsewhere.[14] For $ n = 4 $, the adjacency matrix of $ C_4 $ (a square) is
The path graph $ P_n $, a connected tree with $ n $ vertices and $ n-1 $ edges forming a linear chain, has an adjacency matrix that is tridiagonal, with ones on the subdiagonal and superdiagonal (corresponding to consecutive vertices) and zeros elsewhere.[15] For $ n = 4 $, this yields
Directed Graphs
In directed graphs, the adjacency matrix is an matrix where the entry if there is a directed edge from vertex to vertex , and otherwise; unlike the undirected case, this matrix is generally asymmetric, reflecting the orientation of edges.[16] This asymmetry captures the one-way nature of directed edges, allowing the matrix to encode precedence or flow in structures like networks or dependencies.[17] A classic example is the directed cycle graph , where vertices are connected in a unidirectional loop. For (a directed triangle), the adjacency matrix has 1s on the superdiagonal and in the bottom-left corner:
This matrix represents edges , , and , forming a cyclic structure. For general , the matrix is a circulant permutation matrix with 1s shifted along the superdiagonal and .[18]
Another illustrative case is the tournament graph, a complete directed graph on vertices where exactly one directed edge exists between every pair of distinct vertices. The adjacency matrix of a 3-vertex tournament is thus a 3x3 matrix with zeros on the diagonal and exactly one 1 in each off-diagonal pair and .[19] For the cyclic tournament (isomorphic to the directed triangle above), the matrix is
featuring a single directed 3-cycle. In contrast, an asymmetric (transitive) tournament, where one vertex dominates the others in a linear hierarchy, has the matrix
with edges , , and , containing no cycles.[19]
The transpose of a directed graph's adjacency matrix represents the graph with all edge directions reversed, swapping rows and columns to invert the orientations while preserving the underlying structure.[16] This property is useful for analyzing reversals in flow or dependency graphs.
Trivial and Special Cases
The trivial graph, consisting of a single isolated vertex with no edges, has an adjacency matrix that is the 1×1 zero matrix . This follows directly from the standard definition, where the absence of any edges results in no off-diagonal entries, and the diagonal is zero since simple graphs prohibit self-loops. For the empty graph, or edgeless graph, with isolated vertices and no edges connecting any pair, the adjacency matrix is the zero matrix, where every entry for all . This structure reflects the complete lack of adjacencies, making the matrix entirely sparse with no 1s anywhere.[20] In disconnected graphs, which consist of multiple connected components, the adjacency matrix can be arranged—by appropriately ordering the vertices—to take a block-diagonal form. Specifically, if the graph has components with sizes , the matrix is a block-diagonal matrix with square blocks along the diagonal, each block being the adjacency matrix of one component, and all off-block entries zero. This permutation highlights the independence of the components.[1] Although simple undirected graphs typically exclude self-loops, allowing loops in more general graph models modifies the adjacency matrix such that the diagonal entry (or the loop's weight) if vertex has a self-loop, deviating from the zero diagonal of loop-free graphs. This convention enables representation of reflexive edges in applications like multigraphs or directed graphs with possible feedback.[5]Mathematical Properties
Spectral Properties
The spectrum of a graph is defined as the multiset of eigenvalues of its adjacency matrix . For an undirected simple graph without loops, is a real symmetric matrix, so its eigenvalues are real numbers and it admits an orthogonal basis of eigenvectors.[21] The eigenvalues (ordered such that ) satisfy the characteristic equation , where is the identity matrix. Since has zero diagonal entries (no loops), its trace is zero, implying that the sum of the eigenvalues equals zero: .[21] The largest eigenvalue , known as the spectral radius , provides key insights into graph structure. For any graph, , where is the maximum vertex degree, with equality if and only if the graph is regular.[22] For a connected graph, the Perron–Frobenius theorem applies to the nonnegative irreducible matrix , ensuring that is a simple eigenvalue with a positive eigenvector (the Perron vector), and for all other eigenvalues .[23] In a -regular graph, with multiplicity equal to the number of connected components.[21] A representative example is the complete graph on vertices, whose adjacency matrix has eigenvalues (with multiplicity 1, corresponding to the all-ones eigenvector) and (with multiplicity ).[21] This spectrum reflects the high connectivity, with the spectral radius matching the regular degree.Isomorphism and Graph Invariants
The adjacency matrix provides a fundamental tool for determining graph isomorphism. Two graphs and with adjacency matrices and , respectively, are isomorphic if and only if there exists a permutation matrix such that .[24] For undirected graphs, where and are symmetric, this relation simplifies to , reflecting the orthogonal nature of permutation matrices.[24] This permutation similarity captures the structural equivalence of the graphs under vertex relabeling, as the matrix entries correspond directly to edge incidences. However, the adjacency matrix itself is not a complete graph invariant due to its dependence on vertex labeling. Isomorphic graphs share the same adjacency matrix up to such a similarity transformation, but distinct labelings of the same graph yield different matrices without applying the permutation.[5] Consequently, direct matrix equality does not imply isomorphism; instead, one must verify the existence of the transforming permutation, which underpins the computational challenge of the graph isomorphism problem.[25] Several properties of the adjacency matrix serve as graph invariants. The total number of 1's in equals twice the number of edges in an undirected simple graph without loops, providing a basic measure of graph density.[24] The row sums of correspond to the degrees of the vertices, yielding the degree sequence as an invariant multiset.[24] More sophisticated invariants include the permanent of , which counts the number of permutation matrices subordinate to and remains unchanged under permutation similarity, useful for enumerating perfect matchings in bipartite cases.[26] Immanants, generalizations of the permanent and determinant via irreducible characters of the symmetric group, offer further invariants that capture cycle index symmetries and have applications in distinguishing non-isomorphic graphs.[26] The spectrum of —its multiset of eigenvalues—is another key invariant preserved under similarity.[24]Matrix Powers and Walk Counting
One of the key applications of the adjacency matrix in graph theory lies in its powers, which provide a means to count walks between vertices. Specifically, if is the adjacency matrix of a graph , then the -entry of , denoted , equals the number of walks of length from vertex to vertex in . This result follows from the structure of matrix multiplication, where each term in the product corresponds to extending a walk by one edge at a time. In undirected graphs, these walks may revisit vertices and edges, and the count for gives the number of closed walks of length based at vertex . Such closed walks offer insights into the graph's local connectivity and periodic structures around . Moreover, the existence of a positive entry in some power (for , where is the number of vertices) indicates the presence of a walk between and , which in connected undirected graphs implies overall connectivity via the union of such powers. For directed graphs, the theorem extends analogously, but the walks must respect edge directions, enabling the enumeration of directed paths and circuits. The adjacency matrix for digraphs is typically not symmetric, yet the power still captures the number of directed walks of length from to . A concrete illustration occurs for : the diagonal entries of equal the degrees of the vertices in undirected graphs, since .[27] More generally, the trace equals the total number of closed walks of length across all vertices, a quantity that relates to cycle enumeration in broader combinatorial contexts by summing contributions from all possible closed structures. To see this in action, consider the path graph on vertices with edges and . Its adjacency matrix is
The second power is
where counts the single walk of length 2, and counts the closed walks and . The off-diagonal entries like and highlight connections to neighbors of neighbors, illustrating how reveals the graph's two-step reachability.[27]