Multiplying an Adjacency Matrix by Itself
Consider adjacency matrix with nodes. We know that if there is a path between and , , if not . Now consider all possible nodes to choose a path . We see that for to be a possible node and .
Now observe the definition of multiplication of matrices. We know:
For each path , each term summed only equals one when and are both , or when path exists. Therefore, the number of paths of length between and is .
Taking an Adjacency Matrix to
Now consider a matrix where there are paths of length between and . Have be the adjacency matrix for the graph models. Now say we want all paths of length that look like . We know the number of paths of length is . Similarly, we know there are paths that satisfy . Therefore, the number of paths that satisfy is:
Choosing any node gives the number of paths of length satisfying :
Since obviously is the amount of paths of length between and , by induction, the amount of paths of length between and is: