4

Let $G=(V,E)$ be a graph, and $A$ be its adjacency matrix. Define $n = |V|$.

Given $A$ and a natural number $m \le n$, I'm interested in the following problem:

How many simple cycles of length $m$ exist in $G$?

By simple cycle, I mean no repeated vertices along the cycle is allowed (other than the starting and ending vertices, which coincide).

The problem is NP-hard. However, I'm not asking its complexity; I'm merely interested in whether there is a closed-form expression for computing it. (Thus, computing the expression can be NP-hard.)

Sadeq Dousti
  • 3,291
  • This is indeed NP-hard: when $m = n$, whether the number of simple cycles of length $m$ is nonzero is the Hamiltonian path problem. –  Mar 17 '11 at 18:09
  • @Rahul: I know. I used the word "might" since for $m<n$, it might be easier. – Sadeq Dousti Mar 17 '11 at 18:19
  • 2
    Hi, I asked the same question without noticing yours. Sorry for that, but I got some pretty cool answers (one containing a recursive formula to calculate the number of ways without backtracking). If you are still interested, have a look. And +1 interesting question ;-) – draks ... Aug 02 '12 at 18:04
  • Interesting, in a comment it is stated, that the number of cycles can be computed in polynomial time. So why do you say, that it is NP-hard? For a better flow of reading it would be cool, if could reply directly to Chris there... – draks ... Aug 03 '12 at 18:06
  • @draks: Maybe our questions are different? – Sadeq Dousti Aug 04 '12 at 07:19
  • @draks: Like you, I got the impression that our questions are the same! If you agree that they're not, please tell me to "un-accept" it. You can also delete your answer. Thanks. – Sadeq Dousti Aug 04 '12 at 18:16
  • I'm pretty sure that they are the same. I just wonder about the different complexities given by you and Chri and so I want to hear your opinion... – draks ... Aug 05 '12 at 16:40
  • For the problem I stated here, I'm also pretty sure that it is NP-complete. Take a look at page 4 on this presentation, or its full version. – Sadeq Dousti Aug 07 '12 at 16:46
  • I think the difference is that your cycles are simple, no repeated vertices, while mine are reduced ones, no backtracking. What do you think? – draks ... Nov 06 '12 at 22:18
  • @draks: That's one possible difference. Small changes in problem definition may have drastic effects on its computational complexity. – Sadeq Dousti Nov 07 '12 at 10:30

2 Answers2

1

An answer containing a recursive formula for the number of cycles can be found here.

draks ...
  • 18,449
-1

I think the trace of $A^m$ gives the number of cycles of length $m$ of a graph $G$.