name: Problem
about: Propose a new problem type
title: "[Model] LongestCircuit"
labels: model
assignees: ''
Motivation
LONGEST CIRCUIT (P104) from Garey & Johnson, A2 ND28. A classical NP-complete problem useful for reductions. Asks whether a graph contains a simple circuit whose total edge length meets or exceeds a given bound K. NP-complete even with unit edge lengths (where it reduces to finding a longest simple cycle).
Associated reduction rules:
- As source: None found in the current rule set.
- As target: R49: HAMILTONIAN CIRCUIT -> LONGEST CIRCUIT
Definition
Name: LongestCircuit
Canonical name: LONGEST CIRCUIT (also: Longest Cycle, Maximum Weight Simple Cycle)
Reference: Garey & Johnson, Computers and Intractability, A2 ND28
Mathematical definition:
INSTANCE: Graph G = (V,E), length l(e) ∈ Z^+ for each e ∈ E, positive integer K.
QUESTION: Is there a simple circuit in G of length K or more, i.e., whose edge lengths sum to at least K?
Variables
- Count: |E| binary variables (one per edge), indicating whether the edge is included in the circuit.
- Per-variable domain: {0, 1} -- edge is excluded or included in the circuit.
- Meaning: The variable assignment encodes a subset of edges. A satisfying assignment is a subset S of E such that the subgraph induced by S forms a simple circuit (connected 2-regular subgraph) and the sum of l(e) for e in S is at least K.
Dims
[2; num_edges] — one binary variable per edge indicating inclusion in the circuit.
Schema (data type)
Type name: LongestCircuit
Variants: graph type (G), weight type (W)
| Field |
Type |
Description |
graph |
G |
The undirected graph G = (V, E) |
lengths |
Vec<W> |
Edge length l(e) for each edge (indexed by edge index) |
bound |
W |
The length bound K |
Notes:
- This is a satisfaction (decision) problem:
Metric = bool, implementing SatisfactionProblem.
- For the optimization variant, one would maximize the circuit length (removing the bound K), making it an
OptimizationProblem with Direction::Maximize.
- The unit-weight special case (l(e) = 1 for all e) is equivalent to finding the longest simple cycle by number of edges.
Size fields
| Getter |
Meaning |
num_vertices |
Number of vertices |V| |
num_edges |
Number of edges |E| |
bound |
The length bound K |
Complexity
- Best known exact algorithm: O(n^2 · 2^n) deterministic dynamic programming via Held-Karp adaptation — enumerate subsets, tracking cycle structure. (For the special case of Hamiltonian Cycle detection, Björklund (2014) achieves O*(1.657^n) randomized time.)
- NP-completeness: NP-complete by transformation from HAMILTONIAN CIRCUIT (Garey & Johnson, ND28). Remains NP-complete with unit edge lengths.
- Approximation: No constant-factor approximation is known for the general case.
- Special cases: For claw-free graphs, O*(1.6818^n) time with exponential space, or O*(1.8878^n) with polynomial space (Broersma, Fomin, van 't Hof, and Paulusma, 2013).
- References:
- A. Björklund (2014). "Determinant Sums for Undirected Hamiltonicity." SIAM Journal on Computing, 43(1):280-299.
- H.J. Broersma, F.V. Fomin, P. van 't Hof, D. Paulusma (2013). "Exact Algorithms for Finding Longest Cycles in Claw-Free Graphs." Algorithmica, 65(1):129-145.
Extra Remark
Full book text:
INSTANCE: Graph G = (V,E), length l(e) ∈ Z^+ for each e ∈ E, positive integer K.
QUESTION: Is there a simple circuit in G of length K or more, i.e., whose edge lengths sum to at least K?
Reference: Transformation from HAMILTONIAN CIRCUIT.
Comment: Remains NP-complete if l(e) = 1 for all e ∈ E, as does the corresponding problem for directed circuits in directed graphs. The directed problem with all l(e) = 1 can be solved in polynomial time if G is a "tournament" [Morrow and Goodman, 1976]. The analogous directed and undirected problems, which ask for a simple circuit of length K or less, can be solved in polynomial time (e.g., see [Itai and Rodeh, 1977b]), but are NP-complete if negative lengths are allowed.
How to solve
Example Instance
Instance 1 (YES -- circuit of length >= K exists):
Graph G with 6 vertices {0, 1, 2, 3, 4, 5} and 10 edges:
- Edges with lengths: {0,1}:3, {1,2}:2, {2,3}:4, {3,4}:1, {4,5}:5, {5,0}:2, {0,3}:3, {1,4}:2, {2,5}:1, {3,5}:2
- K = 17
- Simple circuit: 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 0
- Length: 3 + 2 + 4 + 1 + 5 + 2 = 17 >= K = 17
- Answer: YES
Instance 2 (NO -- no circuit of length >= K):
Same graph, K = 20.
- The Hamiltonian circuit above has length 17.
- Alternative circuit: 0 -> 3 -> 2 -> 5 -> 4 -> 1 -> 0: length = 3 + 4 + 1 + 5 + 2 + 3 = 18.
- No simple circuit can have length >= 20 (the maximum over all Hamiltonian circuits is 18).
- Answer: NO
Expected Outcome
- Instance 1 (K = 17): YES — the Hamiltonian circuit 0→1→2→3→4→5→0 has total length 3+2+4+1+5+2 = 17 ≥ K. This is a valid simple circuit (visits each vertex exactly once) and meets the bound.
- Instance 2 (K = 20): NO — brute-force enumeration of all 24 simple circuits in the graph confirms the maximum circuit length is 18 (achieved by the Hamiltonian circuit 0→3→2→5→4→1→0 with length 3+4+1+5+2+3 = 18). Since 18 < 20, no circuit meets the bound.
name: Problem
about: Propose a new problem type
title: "[Model] LongestCircuit"
labels: model
assignees: ''
Motivation
LONGEST CIRCUIT (P104) from Garey & Johnson, A2 ND28. A classical NP-complete problem useful for reductions. Asks whether a graph contains a simple circuit whose total edge length meets or exceeds a given bound K. NP-complete even with unit edge lengths (where it reduces to finding a longest simple cycle).
Associated reduction rules:
Definition
Name:
LongestCircuitCanonical name: LONGEST CIRCUIT (also: Longest Cycle, Maximum Weight Simple Cycle)
Reference: Garey & Johnson, Computers and Intractability, A2 ND28
Mathematical definition:
INSTANCE: Graph G = (V,E), length l(e) ∈ Z^+ for each e ∈ E, positive integer K.
QUESTION: Is there a simple circuit in G of length K or more, i.e., whose edge lengths sum to at least K?
Variables
Dims
[2; num_edges]— one binary variable per edge indicating inclusion in the circuit.Schema (data type)
Type name:
LongestCircuitVariants: graph type (G), weight type (W)
graphGlengthsVec<W>boundWNotes:
Metric = bool, implementingSatisfactionProblem.OptimizationProblemwithDirection::Maximize.Size fields
num_verticesnum_edgesboundComplexity
Extra Remark
Full book text:
INSTANCE: Graph G = (V,E), length l(e) ∈ Z^+ for each e ∈ E, positive integer K.
QUESTION: Is there a simple circuit in G of length K or more, i.e., whose edge lengths sum to at least K?
Reference: Transformation from HAMILTONIAN CIRCUIT.
Comment: Remains NP-complete if l(e) = 1 for all e ∈ E, as does the corresponding problem for directed circuits in directed graphs. The directed problem with all l(e) = 1 can be solved in polynomial time if G is a "tournament" [Morrow and Goodman, 1976]. The analogous directed and undirected problems, which ask for a simple circuit of length K or less, can be solved in polynomial time (e.g., see [Itai and Rodeh, 1977b]), but are NP-complete if negative lengths are allowed.
How to solve
Example Instance
Instance 1 (YES -- circuit of length >= K exists):
Graph G with 6 vertices {0, 1, 2, 3, 4, 5} and 10 edges:
Instance 2 (NO -- no circuit of length >= K):
Same graph, K = 20.
Expected Outcome