Counting simple directed cycles: #CYCLE #
SharpCycle G is the number of simple directed cycles of a graph G (Cslib.Complexity.Graph),
read as a directed graph through its arcs (u, v) ∈ G.edges exactly as DirHamCycle reads it.
A simple cycle is a Cycle ℕ, a list up to rotation, that is nonempty, has no repeated vertices,
contains only declared vertices, and whose consecutive vertices, read cyclically, are joined by
arcs (Cslib.Complexity.Graph.IsSimpleCycle). In particular a self-loop is a cycle of length one.
Arora and Barak, Theorem 9.4 (web draft of 2007-01-08, §9.1, printed p. 173 /
PDF p. 189) shows that computing #CYCLE is as hard as deciding whether a digraph has a
Hamiltonian cycle. The reduction (Cslib.Complexity.SharpCycle.reduce)
replaces every arc (u, v) by a gadget of m layers of two nodes, complete between consecutive
layers, from u to v. It has 2 ^ m paths from u to v. A simple cycle of the gadget graph
is a simple cycle of G with a path chosen through the gadget of each of its arcs, so a cycle of
length k of G gives 2 ^ (m * k) cycles. With n distinct vertices and
m = n * n + n + 3, G has fewer than 2 ^ m simple cycles, so a Hamiltonian cycle alone gives
2 ^ (m * n) cycles and without one the total stays below 2 ^ (m * n)
(Cslib.Complexity.SharpCycle.mem_DirHamCycle_iff). The draft takes m = n log n + 1; any
polynomial m with 2 ^ m above the number of cycles of G works. The extra two layers
give a factor-four gap, which also rules out a polynomial-time factor-two approximation
(Chapter 9, Exercise 5, printed p. 185 / PDF p. 201).
The original vertex v becomes 2 * v (Cslib.Complexity.SharpCycle.origNode) and the gadget
nodes are odd (Cslib.Complexity.SharpCycle.gadgetNode), so the two kinds never collide. Every
simple cycle of the gadget graph passes through an original vertex, since the layer index grows
along arcs between gadget nodes. Starting there, it decomposes into arcs of G and their gadget
paths, and the arcs form a simple cycle of G. Conversely, every simple cycle of G and every
choice of bits gives a simple cycle of the gadget graph, and different bits give different cycles.
FP for a natural-valued function is read as polynomial-time computability with binary output
(ComputableInPolyTime SharpCycle encGraph encNat), with graphs in the encoding encGraph of
DirHamCycle.
Main definitions #
Cslib.Complexity.Graph.IsSimpleCycle: simple directed cycles.Cslib.Complexity.SharpCycle: the number of simple directed cycles.Cslib.Complexity.SharpCycle.nodeCodec,Cslib.Complexity.SharpCycle.gadgetGraph,Cslib.Complexity.SharpCycle.layers,Cslib.Complexity.SharpCycle.reduce: the gadget graph withn * n + n + 3layers.
Main results #
Cslib.Complexity.SharpCycle.finite_setOf_isSimpleCycle: a graph has finitely many simple cycles.Cslib.Complexity.SharpCycle.two_pow_le_of_mem_DirHamCycle,Cslib.Complexity.SharpCycle.four_mul_lt_two_pow_of_notMem_DirHamCycle: the counting inequalities.Cslib.Complexity.SharpCycle.mem_DirHamCycle_iff:G ∈ DirHamCycle ↔ 2 ^ (m * n) ≤ SharpCycle (reduce G).Cslib.Complexity.SharpCycle.computableInPolyTime_reduce: the gadget graph is computable in polynomial time.Cslib.Complexity.SharpCycle.DirHamCycle_mem_P: ifSharpCycleis computable in polynomial time with binary output, thenDirHamCycle ∈ P encGraph.Cslib.Complexity.P_eq_NP_of_computableInPolyTime_SharpCycle: Theorem 9.4, ifSharpCycleis computable in polynomial time with binary output (#CYCLE ∈ FP), thenP = NP.Cslib.Complexity.P_eq_NP_of_polyTime_approx_SharpCycle: Chapter 9, Exercise 5, a polynomial-time factor-two approximation also impliesP = NP.
References #
#CYCLE Arora and Barak, Theorem 9.4: the number of simple directed cycles
of G.
Finitely many cycles #
The gadget graph #
The node of the original vertex v in the gadget graph.
Node b of layer j of the gadget of the arc (u, v).
The gadget graph of G with m layers: the original vertices and a gadget for every arc.
The number of layers of the reduction, for n distinct vertices: n * n + n + 3.
The reduction from DirHamCycle to #CYCLE Arora and Barak, Theorem 9.4.
Nodes and arcs of the gadget graph #
The arcs leaving layer j of a gadget enter the next layer, or the end of the arc after the
last layer.
Walks through gadgets #
Decomposing paths of the gadget graph #
Nodes of walks #
Cycles of the gadget graph #
Counting #
A Hamiltonian cycle of G gives 2 ^ (m * n) cycles of the gadget graph.
Without a Hamiltonian cycle, four times the gadget cycle count is below 2 ^ (m * n).
Theorem 9.4, the reduction Arora and Barak, Theorem 9.4: with n
distinct vertices and m = n * n + n + 3 layers, G has a Hamiltonian cycle exactly when the
gadget graph has at least 2 ^ (m * n) simple cycles.
Polynomial time #
The node of an original vertex is computable in polynomial time.
The gadget nodes are computable in polynomial time, from binary arc ends and a unary layer.
The number of layers is computable in polynomial time in unary.
The reduction is polynomial-time.
A factor-two estimate of the cycle count decides Hamiltonicity using the factor-four gap.
The inequalities avoid division: #CYCLE ≤ 2A and A ≤ 2#CYCLE.
Theorem 9.4, decision Arora and Barak, Theorem 9.4: if the number of
simple cycles is computable in polynomial time with binary output, then DirHamCycle ∈ P.
Arora–Barak, Theorem 9.4 Arora and Barak, Theorem 9.4: if #CYCLE, the
number of simple directed cycles, is computable in polynomial time with binary output, then
P = NP, for every encoding.
Arora–Barak, Chapter 9, Exercise 5 (2007-01-08 draft, printed p. 185 / PDF p. 201):
a deterministic polynomial-time factor-1/2 approximation to #CYCLE implies P = NP.
For binary natural output the guarantee #CYCLE/2 ≤ A ≤ 2#CYCLE is written without division.