-
Notifications
You must be signed in to change notification settings - Fork 3
[Model] PartitionIntoForests #833
Description
Motivation
PARTITION INTO FORESTS (P25) from Garey & Johnson, A1.1 GT14. A classical NP-complete problem also known as the vertex arboricity decision problem: can the vertices of a graph be partitioned into at most K disjoint sets such that each induces an acyclic subgraph (forest)? NP-complete by transformation from GRAPH 3-COLORABILITY. Remains NP-complete even for K=2 on planar graphs (Hakimi & Schmeichel, 1989). The minimum K is the vertex arboricity a(G), distinct from edge arboricity which is polynomial-time computable (Nash-Williams, 1964).
Associated reduction rules:
- R258: Graph3Colorability → PartitionIntoForests (GJ reference reduction, issue [Rule] GRAPH 3-COLORABILITY to PARTITION INTO FORESTS #843)
Definition
Name: PartitionIntoForests
Canonical name: Partition into Forests (also: Vertex Arboricity)
Reference: Garey & Johnson, Computers and Intractability, A1.1 GT14
Mathematical definition:
INSTANCE: Graph G = (V, E), positive integer K ≤ |V|.
QUESTION: Can the vertices of G be partitioned into k ≤ K disjoint sets V₁, V₂, …, Vₖ such that, for 1 ≤ i ≤ k, the subgraph induced by Vᵢ contains no circuits?
This is a satisfaction (feasibility) problem: Value = Or.
Variables
- Count: n = |V| (one variable per vertex)
- Per-variable domain: K (values 0, 1, …, K−1, assigning each vertex to one of K forest classes)
- Meaning: config[v] = c means vertex v is assigned to forest class c. A satisfying assignment requires that for each c ∈ {0, …, K−1}, the induced subgraph G[{v : config[v] = c}] is acyclic (a forest).
dims() returns [K; n].
Schema (data type)
Type name: PartitionIntoForests
Variants: G — graph type (e.g., SimpleGraph)
| Field | Type | Description | Getter |
|---|---|---|---|
graph |
G |
The undirected graph G = (V, E) | num_vertices(), num_edges() |
num_forests |
usize |
The bound K on the number of forest partitions | num_forests() |
Problem type: Satisfaction (feasibility)
Value type: Or
Complexity
- Decision complexity: NP-complete (Garey & Johnson; transformation from GRAPH 3-COLORABILITY). Remains NP-complete for K = 2 on planar graphs (Hakimi & Schmeichel, 1989).
- Best known exact algorithm: Brute-force over all K^n vertex colorings, checking acyclicity of each induced subgraph via DFS. Time O(K^n · (n + m)).
- Complexity string for
declare_variants!:"num_forests^num_vertices" - Special cases:
- K = 1: Polynomial — equivalent to checking if G is a forest (acyclic), solvable by DFS in O(n + m).
- K ≥ ⌈Δ/2⌉ + 1 where Δ is max degree: always YES (greedy argument).
- References:
- [Hakimi & Schmeichel, 1989] S. L. Hakimi and E. F. Schmeichel, "A Note on the Vertex Arboricity of a Graph", SIAM J. Discrete Math. 2(1), pp. 64–67.
- [Nash-Williams, 1964] C. St. J. A. Nash-Williams, "Decomposition of finite graphs into forests", J. London Math. Soc. 39(1), p. 12.
Extra Remark
Full book text:
INSTANCE: Graph G = (V,E), positive integer K ≤ |V|.
QUESTION: Can the vertices of G be partitioned into k ≤ K disjoint sets V_1, V_2, . . . , V_k such that, for 1 ≤ i ≤ k, the subgraph induced by V_i contains no circuits?
Reference: [Garey and Johnson, ——]. Transformation from GRAPH 3-COLORABILITY.
How to solve
- It can be solved by (existing) bruteforce. Enumerate all K^n vertex assignments; for each, check acyclicity of each induced subgraph.
- It can be solved by reducing to integer programming. (Acyclicity is a global structural constraint that does not admit a compact linear encoding without exponentially many subtour-elimination constraints.)
- Other: For K=1, check acyclicity in O(n+m). For general K, backtracking with incremental acyclicity checking via union-find.
Example Instance
Positive example (YES, K=2):
Graph G with 6 vertices {0, 1, 2, 3, 4, 5}, K = 2, and 7 edges:
Edges: {0,1}, {1,2}, {2,0}, {2,3}, {3,4}, {4,5}, {5,3}
The graph contains two triangles {0,1,2} and {3,4,5} connected by edge {2,3}.
Vertex arboricity is 2 (cannot be 1 since G has cycles).
Satisfying partition: V₀ = {0, 3}, V₁ = {1, 2, 4, 5}
- G[V₀] = {0, 3}: no edges between 0 and 3 → isolated vertices → forest ✓
- G[V₁] = {1, 2, 4, 5}: edges {1,2}, {4,5} → two isolated edges → forest ✓
Config: [0, 1, 1, 0, 1, 1]
Verification of other partitions:
| Config | V₀ | V₁ | G[V₀] acyclic? | G[V₁] acyclic? | Valid? |
|---|---|---|---|---|---|
| [0,1,1,0,1,1] | {0,3} | {1,2,4,5} | ✓ (no edges) | ✓ (two edges) | Yes |
| [0,0,1,1,1,0] | {0,1,5} | {2,3,4} | ✓ ({0,1} only) | ✓ ({2,3},{3,4}) | Yes |
| [0,0,0,1,1,1] | {0,1,2} | {3,4,5} | ✗ (triangle) | ✗ (triangle) | No |
Out of 64 assignments, 18 are valid 2-forest partitions and 46 are not — good coverage for testing.
Negative example (NO, K=1):
Graph G with 4 vertices {0,1,2,3}, K = 1, edges: {0,1}, {1,2}, {2,3}, {3,0} (cycle C₄).
Cannot partition into 1 forest since G itself has a cycle. Answer: Or(false).
Expected outcome: Or(true) for the primary example.
Reduction Rule Crossref
- R258: KColoring (Graph 3-Colorability) → PartitionIntoForests (issue [Rule] GRAPH 3-COLORABILITY to PARTITION INTO FORESTS #843)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status