To understand
why the powers of \(\mathbf{M}\) give the multi-step adjacency matrices, consider the 2-step matrix:

The element in row 2 column 4 of \(\mathbf{M}^2\) shows there are
two 2-step walks from B to D.
This value comes from the multiplication
row 2 \(\times\)
column 4 as follows:
- \(1 \times 1 = 1\) walk from B to A \(\times\) 1 walk from A to D
- \(0 \times 0 = 0\) walks from B to B \(\times\) 0 walks from B to D
- \(1 \times 1 = 1\) walk from B to C \(\times\) 1 walk from C to D
- \(0 \times 0 = 0\) walks from B to D \(\times\) 0 walks from D to D
- \(0 \times 1 = 0\) walks from B to E \(\times\) 1 walk from E to D
Adding these terms gives the two 2-step walks from B to D. The walks are \(\text{B} \rightarrow \text{A} \rightarrow \text{D}\) and \(\text{B} \rightarrow \text{C} \rightarrow \text{D}\).