Walks and Adjacency Matrices
A network records which transitions are possible. Its adjacency matrix records those transitions numerically, and matrix powers combine them across several steps. The key interpretation is precise: an entry of the \(k\)th power counts walks of exactly \(k\) edges between two vertices. This works for directed and undirected networks, provided that the matrix entries represent edge counts and that parallel edges are treated as distinct choices.
Consider a finite network with vertices labelled \(1,\dots,n\). In a directed network, an edge from \(i\) to \(j\) is oriented from \(i\) toward \(j\). For an undirected network, each edge can be traversed in either direction. A loop is an edge from a vertex to itself. If parallel edges are present, they are distinct edges with the same endpoints.
For a network in which we count walks, define the adjacency matrix \(\mathbf{A}=[a_{ij}]\in\mathbb{R}^{n\times n}\) by letting \(a_{ij}\) be the number of directed edges from \(i\) to \(j\). In an undirected network, count edges joining \(i\) and \(j\); the resulting matrix is symmetric. In particular, \(a_{ii}\) counts loops at \(i\). With no parallel edges, each entry is either \(0\) or \(1\). The row index is the starting vertex and the column index is the destination.
Here the entries must be edge counts, not arbitrary edge weights. If an adjacency matrix instead stores general numerical weights, its powers combine products of weights along walks; the entries are then weighted totals, not necessarily numbers of walks. For a counting matrix with parallel edges, each available edge is one separate choice, as the definition above requires.
Why a Matrix Product Adds One Step
The multiplication rule explains the walk-count interpretation. The \((i,j)\) entry of a product \(\mathbf{B}\mathbf{C}\) is \(\sum_{r=1}^n b_{ir}c_{rj}\). For adjacency matrices, the intermediate index \(r\) specifies the vertex reached after the first step. There are \(a_{ir}\) choices of edge for that first step and, when the entries of \(\mathbf{A}^{k}\) count length-\(k\) walks, \((\mathbf{A}^{k})_{rj}\) choices for the remaining steps. Multiplying counts the combinations through \(r\), and summing includes every possible intermediate vertex.
Proof. We use induction on \(k\). For \(k=0\), \(\mathbf{A}^{0}=\mathbf{I}_n\), whose \((i,j)\) entry is \(1\) if \(i=j\) and \(0\) otherwise. These are exactly the numbers of length-\(0\) walks by the definition. For \(k=1\), \((\mathbf{A})_{ij}=a_{ij}\), which is the number of available edges from \(i\) to \(j\), so it counts length-\(1\) walks, including separate choices among parallel edges.
Now suppose for some \(k\geq 1\) that \((\mathbf{A}^{k})_{rj}\) counts length-\(k\) walks from \(r\) to \(j\), for every pair of vertices \(r,j\). By matrix multiplication,
For each \(r\), a walk counted by the product \(a_{ir}(\mathbf{A}^{k})_{rj}\) is formed by choosing one of the \(a_{ir}\) edges from \(i\) to \(r\), then choosing one of the length-\(k\) walks from \(r\) to \(j\). This gives a walk of length \(k+1\) from \(i\) to \(j\). Conversely, every length-\((k+1)\) walk from \(i\) to \(j\) has a uniquely specified first edge and a uniquely specified remaining length-\(k\) walk. Its first edge ends at exactly one vertex \(r\), so it is counted in exactly one term of the sum. Thus the sum counts every such walk exactly once, proving the claim for \(k+1\). The induction proves the theorem for all \(k\geq 0\). \(\square\)
Worked Counts in Directed Networks
Worked Example: Parallel Edges Give Distinct Walks
Consider three vertices with two distinct edges from \(1\) to \(2\), one edge from \(2\) to \(3\), one edge from \(1\) to \(3\), and one edge from \(3\) to \(1\). Find the number of length-\(2\) walks from \(1\) to \(3\).
With rows as starting vertices and columns as destinations, the adjacency matrix is
To compute \(\mathbf{A}^2\), write its rows as combinations of the rows of \(\mathbf{A}\). The first row of \(\mathbf{A}\) has two edges to vertex \(2\) and one to vertex \(3\), so the first row of \(\mathbf{A}^2\) is twice row \(2\) of \(\mathbf{A}\), plus row \(3\) of \(\mathbf{A}\). The other rows are obtained in the same way:
Therefore \((\mathbf{A}^2)_{13}=2\). Both walks go from \(1\) to \(2\) and then from \(2\) to \(3\), but they differ in which of the two parallel edges from \(1\) to \(2\) they use. The direct edge from \(1\) to \(3\) does not create a length-\(2\) walk to \(3\), because no edge from \(3\) to \(3\) is present.
Check: multiplying row \(1\) of \(\mathbf{A}\) by column \(3\) of \(\mathbf{A}\) gives \(0\cdot1+2\cdot1+1\cdot0=2\), matching the two edge-distinguished walks. If walks were defined only as vertex sequences, both would have the single sequence \((1,2,3)\); that definition would fail to match the matrix entry.
Worked Example: A Directed Network and Three Steps
Suppose a directed network has edges \(1\to2\), \(1\to3\), \(2\to3\), and \(3\to1\). Find all length-\(3\) walk counts.
Its adjacency matrix and its rows are
In \(\mathbf{A}^2=\mathbf{A}\mathbf{A}\), row \(1\) is \(r_2+r_3\), row \(2\) is \(r_3\), and row \(3\) is \(r_1\). Hence
For \(\mathbf{A}^3=\mathbf{A}^2\mathbf{A}\), row \(1\) is \(r_1+r_3=(1,1,1)\), row \(2\) is \(r_1=(0,1,1)\), and row \(3\) is \(r_2+r_3=(1,0,1)\). Therefore
For instance, \((\mathbf{A}^3)_{12}=1\): there is exactly one length-\(3\) walk from \(1\) to \(2\), namely \(1\to3\to1\to2\). The entry \((\mathbf{A}^3)_{33}=1\) counts \(3\to1\to2\to3\).
Check: row \(1\) of \(\mathbf{A}^2\) is \((1,0,1)\). Multiplying it by column \(2\) of \(\mathbf{A}\), which is \((1,0,0)^{\top}\), gives \(1\cdot1+0\cdot0+1\cdot0=1\), confirming the \((1,2)\) entry of \(\mathbf{A}^3\).
Undirected Networks and Total Counts
For an undirected network, each edge can be traversed in either direction. Its adjacency matrix is symmetric: \(a_{ij}=a_{ji}\). Matrix powers still count walks by the same theorem; symmetry adds a useful relation between walks in opposite directions.
Proof. Reversing the order of the vertices and traversed edges in any length-\(k\) walk from \(i\) to \(j\) gives a length-\(k\) walk from \(j\) to \(i\). Because every edge in an undirected network can be traversed in either direction, the reversed sequence is allowed. Reversing again recovers the original walk, so this correspondence is a bijection. It preserves distinct choices of parallel edges, since the same chosen edges are used in reverse order. The two sets of walks therefore have the same number of elements. By the walk-counting theorem, those numbers are \((\mathbf{A}^{k})_{ij}\) and \((\mathbf{A}^{k})_{ji}\), respectively. For \(k=0\), the equality also follows from the identity matrix. \(\square\)
Worked Example: Walks on a Three-Vertex Path
Take the undirected path with edges joining \(1\) to \(2\) and \(2\) to \(3\). Calculate the number of length-\(3\) walks from \(1\) to \(2\).
The adjacency matrix has rows \(r_1=(0,1,0)\), \(r_2=(1,0,1)\), and \(r_3=(0,1,0)\). Multiplying \(\mathbf{A}\) by itself, row \(1\) of \(\mathbf{A}^2\) is \(r_2\), row \(2\) is \(r_1+r_3\), and row \(3\) is \(r_2\):
Now multiply \(\mathbf{A}^2\mathbf{A}\). Row \(1\) is row \(1\) of \(\mathbf{A}\) plus row \(3\) of \(\mathbf{A}\), giving \((0,2,0)\). Row \(2\) is twice row \(2\) of \(\mathbf{A}\), giving \((2,0,2)\). Row \(3\) is again \((0,2,0)\). Thus
There are two length-\(3\) walks from \(1\) to \(2\): \(1\to2\to1\to2\) and \(1\to2\to3\to2\). The entry \((\mathbf{A}^3)_{12}=2\) agrees with this count, and the symmetric entry \((\mathbf{A}^3)_{21}=2\) agrees with the proposition.
Check: row \(1\) of \(\mathbf{A}^2\) is \((1,0,1)\). Its product with column \(2\) of \(\mathbf{A}\), \((1,0,1)^{\top}\), is \(1\cdot1+0\cdot0+1\cdot1=2\), as required.
Proof. For each destination \(j\), the walk-counting theorem says that \((\mathbf{A}^k)_{ij}\) counts walks from \(i\) to \(j\). Walks from \(i\) have exactly one destination, so adding these counts over \(j=1,\dots,n\) counts each walk starting at \(i\) exactly once. Adding that row sum over all starting vertices counts every walk in the network exactly once, since each walk has exactly one starting vertex. \(\square\)
Exact Length, Not “At Most”
The power \(\mathbf{A}^k\) counts walks of exactly \(k\) steps. It does not include shorter walks automatically. For example, the identity matrix \(\mathbf{A}^0\) counts only the length-\(0\) walks; it does not count the length-\(1\) walks recorded by \(\mathbf{A}\). If a question asks for walks of lengths from \(0\) through \(k\), the relevant matrix is the sum \(\mathbf{I}_n+\mathbf{A}+\cdots+\mathbf{A}^k\): each power contributes the counts for its own exact length.
A common error is to read the adjacency entry \(a_{ij}=2\) for two parallel edges as one walk because there is only one vertex sequence \((i,j)\). That calculation uses a definition that forgets which edge was traversed. Under the edge-choice definition, there are two length-\(1\) walks, one for each edge, and the matrix entry correctly equals \(2\). A separate error is to interpret \((\mathbf{A}^2)_{ij}\) as the number of walks of length at most \(2\). It counts only length \(2\); shorter lengths must be added as separate powers.
These interpretations are useful whenever a question asks how many ways a network can be traversed in a fixed number of steps. The matrix power combines all possible intermediate vertices without requiring the walks to be listed individually. For small networks, direct multiplication makes the count visible; for larger powers, the same rule applies, with each entry retaining its exact meaning.
Check Your Understanding
Use the edge-choice definition of a walk and the row-source, column-destination convention in each question.
- A directed network has three parallel edges from \(1\) to \(2\) and two edges from \(2\) to \(3\). How many length-\(2\) walks go from \(1\) to \(3\)?
- For an adjacency matrix \(\mathbf{A}\), what does \((\mathbf{A}^0)_{ij}\) count when \(i=j\), and when \(i\ne j\)?
- Why does the matrix product sum over intermediate vertices when counting length-\((k+1)\) walks?
- In the undirected three-vertex path example, how many length-\(2\) walks go from \(1\) to \(3\)? Read the answer from \(\mathbf{A}^2\) and describe the walk.
- If a problem asks for walks of lengths \(1\), \(2\), or \(3\), which matrix expression combines those counts?