 Theoretical Computer Science

# Is counting simple cycles in \$P\$ for graphs of bounded tree width?

Motivation: Determining if a graph has a Hamiltonian cycle is $$NP$$-hard in general. However, determining if there is a Hamiltonian cycle is in polynomial time on graphs of bounded tree width, either via some algorithm involving separators + dynamic programming, or by expressing the existence of a Hamiltonian cycle in a form that fits into Courcelle's theorem.

Counting the number of Eulerian circuits on undirected graphs is $$\# P$$ complete, but according to this paper it is in $$P$$ on graphs with bounded tree width.

Counting the number of Hamiltonian cycles is $$\#P$$ complete, but according to theorem 4.3 of this paper, counting Hamiltonian cycles is in $$P$$ for graphs of bounded tree width.

Counting simple cycles is $$\# P$$ hard in general...

Question: Is counting the number of simple cycles in $$P$$ on graphs of bounded tree width?

Notes:

• My inclination is to look at the separators + dynamic programming algorithms to see if one of them can be modified, but I'm pretty sure that if one can be straightforwardly modified to count simple cycles, then someone has done that already.

• I do not see a way to express 'simple cycle' in $$MSOL_2$$ (the best I can do is express disjoint unions of simple cycles). I'm not sure if there is a version of Courcelle's theorem for counting the set of solutions to a monadic second order logic formula -- I just got a surface level understanding of this theorem from wikipedia.

• I found a simple dynamic programming style algorithm to count simple cycles on series parallel graph, but it does not generalize to bounded tree width graphs. I assume that this is well known and in the literature somewhere. (Here is the algorithm: Initialize all edge weights $$w_a$$ to be $$1$$. Initialize $$S = 0$$. Every time you replace 2 parallel edges with weights $$w_e$$ and $$w_f$$, with a new edge called $$ef$$, set $$w_{ef} := w_e + w_f$$ and $$S := S + w_e w_f$$. Every time you replace to series edges $$e$$ and $$f$$ with a new edge called $$ef$$, set $$w_{ef} := w_e w_f$$. Apply replacements until you have $$K_2$$. The value of $$S$$ at the end is the number of simple cycles, and the weight of the edge at the end is the number of simple $$s$$-$$t$$ paths.) ## Solution

A simple cycle is a connected set where every vertex has degree 2. Then you have a formula SC(X) stating X (a set of edges) is a simple cycle. You can see many versions of Courcelle's theorem for listing and counting. You can refer to this book or this paper