Using Adjacency Matrices to Detect Paths Between Cities. Graphs can represent connections between cities. An adjacency matrix $A$ encodes these connections:
$a_{i,j} = 1$ if there is a direct road from city $i$ to city $j$, and $0$ otherwise.
Matrix multiplication reveals paths of longer lengths:
- $A^2$ tells us whether there is a path of length 2.
- $A^k$ tells us whether there is a path of length $k$.
If $(A^k)_{i,j} > 0$, then there exists a path of length $k$ from city $i$ to city $j$.