Consider the following graph with four nodes and four edges.
Its adjacency matrix is:
This matrix is symmetric about the main diagonal because the traffic is two-way; one-way traffic, or directed edges, presents a practically different, but conceptually similar, situation (as do loops--an edge joining a node to itself). This matrix counts the number of 1-step paths joining pairs of nodes.
To count the number of 2-step paths, square the adjacency matrix.
(There is a 2-step path from 1 to 2--from 1 to 4 to 2, but not a 1-step
To see why this counting works, consider the situation more generally.
In the square of the adjacency matrix, the (2,1) entry is generated
by multiplying the second row by the first column
which, notationally is,
a(21)a(11) + a(22)a(21) + a(23)a(31) + a(24)a(41)
This entry counts paths of length 2 from node 2 to node 1, through each of the possible nodes, 1, 2, 3, 4 (read it from the subscripts in the notation above). Diagramatically,
Higher powers of the adjacency matrix, say of power n, count numbers of paths of n-steps.
The definition here of adjacency is very broad and might be interpreted in any of the three ways for spatial units of two dimensions. It is broad because there is no geometric dimension involved--the focus is on pure connection pattern. When spatial units have dimension other than 2, different styles of adjacency exist.
If one alters the way in which matrix multiplication is performed, one gets to a whole host of other conceptual examples. The attached references focus on one way to alter that multiplication.
Hasse, M., "Uber die Behändlung graphentheorischer Probleme unter
Verwendung der Matrizenrechnung," Wiss. Z. Techn.
Univer. Dresden 10(1961), pp. 1313–1316.
Harary, F., Norman, R., and Cartwright, D., Structural Models: An
Introduction to the Theory of Directed Graphs. John
Wiley & Sons, New York, 1965.
Arlinghaus, S., Arlinghaus, W., Harary, F., and Nystuen, J., " Los Angeles 1994: A spatial scientific view," Solstice: An Electronic Journal of Geography and Mathematics V(1994), pp. 42–82.
Arlinghaus, S., Arlinghaus, W., and Nystuen, J., " The Hedetniemi Matrix Sum: A Real-world Application," Solstice: An Electronic Journal of Geography and Mathematics I(1990), pp. 87–97.
Arlinghaus, S., Arlinghaus, W., and Nystuen, J., " The Hedetniemi matrix
sum: An algorithm for shortest path and shortest
distance," Geographical Analysis 22(1990), pp. 351–360.