Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|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

1 Answer 1

up vote 3 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|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.