Dan Oneata asked a question about counting paths of a given length in comment #67. As Matthew pointed out, this is the question I answered in [comment #60](https://forum.azimuthproject.org/discussion/comment/18946/#Comment_18946). But I answered it indirectly, in a way that would force people to think a lot and learn a lot. Let me be more direct!

Suppose we have a graph and we want to count the number of paths of length \\(n\\) from any node \\(i\\) to any node \\(j\\).

To do this, let \\(U\\) be the **incidence matrix**, where for any two nodes \\(i\\) and \\(j\\), the matrix entry \\(U_{i j} \\) is the number of edges from \\(i\\) to \\(j\\).

Then the number of paths of length \\(n\\) from any node \\(i\\) to any node \\(j\\) is \\( (U^n)_{i j} \\).

For further explorations of this idea see Section 2.5.3 of the book, called "Matrix multiplication in a quantale".

Suppose we have a graph and we want to count the number of paths of length \\(n\\) from any node \\(i\\) to any node \\(j\\).

To do this, let \\(U\\) be the **incidence matrix**, where for any two nodes \\(i\\) and \\(j\\), the matrix entry \\(U_{i j} \\) is the number of edges from \\(i\\) to \\(j\\).

Then the number of paths of length \\(n\\) from any node \\(i\\) to any node \\(j\\) is \\( (U^n)_{i j} \\).

For further explorations of this idea see Section 2.5.3 of the book, called "Matrix multiplication in a quantale".