Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I heard that adjacency matrix can be used to calculate the number of k-length paths in a graph. Can't this be used as a way to calculate the number of hamiltonian paths?

share|cite|improve this question
More specifically, the adjacency matrix can be used to calculate the number of ways of reaching vertex $i$ from $j$ in $k$ steps. This of course does not guarantee non-repeating vertices. – EuYu Aug 23 '12 at 1:07
up vote 5 down vote accepted

The adjacency matrix does not calculate the number of $k$-length paths in a graph. It calculates the number of $k$-length walks from one vertex to another. (More specifically, the entries of the $n$th power of the adjacency matrix encodes the number of walks). To see the difference between paths and walks, consider any two adjacent vertices not part of a cycle. Then there is exact one path between the two vertices i.e. the edge between them, but there exists an infinite number of walks between them. For example $v_1 \rightarrow v_2 \rightarrow v_1 \rightarrow v_2$ is a walk from $v_1$ to $v_2$ of length $3$. Specifically, paths do not allow repetition of vertices while walks do, therefore this does not in general aid in the computation of Hamiltonian paths or indeed, paths of arbitrary lengths.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.