Source: Decision<OptimalLinearArrangement> (decision variant: graph G, bound K)
Target: Consecutive Ones Matrix Augmentation (decision)
Motivation: Establishes NP-completeness of CONSECUTIVE ONES MATRIX AUGMENTATION via polynomial-time reduction from OPTIMAL LINEAR ARRANGEMENT (GT42). The reduction encodes a vertex-ordering problem as a matrix-augmentation problem: given the vertex-edge incidence matrix of the graph, a linear arrangement with total edge length at most K corresponds to a column permutation under which at most K − |E| zero-to-one flips achieve the consecutive ones property.
Reference: Garey & Johnson, Computers and Intractability, problem SR16 (p. 229); transformation from OPTIMAL LINEAR ARRANGEMENT (GT42, p. 200).
Decision-vs-Decision Framing
Both endpoints of this reduction are decision problems with Value = Or:
- Source is
Decision<OptimalLinearArrangement>: a graph G = (V, E) plus a decision bound k. It is YES iff G admits a linear arrangement f : V → {1, …, |V|} (a bijection) with total edge length sum_{{u,v} in E} |f(u) − f(v)| ≤ k.
- Target is
ConsecutiveOnesMatrixAugmentation: a binary matrix A plus a nonnegative bound bound. It is YES iff some column permutation of A plus at most bound zero-to-one flips yields the consecutive ones property (every row's 1's are contiguous).
The base OptimalLinearArrangement model in the codebase is the optimization variant (Value = Min<usize>, no bound). This reduction is stated against the decision variant Decision<OptimalLinearArrangement>, which carries the bound k. See the Prerequisite section below.
Prerequisite
Decision<OptimalLinearArrangement> is not yet registered in the codebase. The implementation PR for this rule must add it first, following the precedents at src/models/graph/minimum_vertex_cover.rs and src/models/graph/minimum_dominating_set.rs:
impl ... DecisionProblemMeta for OptimalLinearArrangement<SimpleGraph> with const DECISION_NAME = "DecisionOptimalLinearArrangement";
- Inherent getters on
Decision<OptimalLinearArrangement<SimpleGraph>>:
num_vertices() -> usize (delegates to inner().num_vertices())
num_edges() -> usize (delegates to inner().num_edges())
k() -> usize (the decision bound, (*self.bound()).try_into().unwrap_or(0))
register_decision_variant!(OptimalLinearArrangement<SimpleGraph>, "DecisionOptimalLinearArrangement", ..., size_getters: [("num_vertices", num_vertices), ("num_edges", num_edges)]).
The reduction impl ReduceTo<ConsecutiveOnesMatrixAugmentation> for Decision<OptimalLinearArrangement<SimpleGraph>> then references the getters num_vertices, num_edges, and k.
GJ Source Entry
[SR16] CONSECUTIVE ONES MATRIX AUGMENTATION
INSTANCE: An m x n matrix A of 0's and 1's and a positive integer K.
QUESTION: Is there a matrix A', obtained from A by changing K or fewer 0 entries to 1's, such that A' has the consecutive ones property?
Reference: [Booth, 1975], [Papadimitriou, 1976a]. Transformation from OPTIMAL LINEAR ARRANGEMENT.
Comment: Variant in which we ask instead that A' have the circular ones property is also NP-complete.
Reduction Algorithm
Summary:
Given a Decision<OptimalLinearArrangement> instance (G = (V, E), k), construct a ConsecutiveOnesMatrixAugmentation instance as follows.
Let n = |V| (num_vertices) and m = |E| (num_edges). We build the edge-vertex incidence matrix of G.
-
Matrix construction: Construct the m x n binary matrix A where rows correspond to edges and columns to vertices. For edge e_i = {u, v}, set A[i][u] = 1 and A[i][v] = 1, and all other entries in row i to 0. Each row has exactly two 1's.
-
Bound: Set the target bound = k − m, where k is the source decision bound and m = num_edges. (Handling of k < m and m = 0 is covered under Edge Inputs below.)
-
Intuition: A column permutation is exactly a vertex ordering f : V → {1, …, n}. In row i for edge {u, v}, the two 1's land at positions f(u) and f(v). Making this row consecutive requires filling all 0's strictly between them: |f(u) − f(v)| − 1 flips. Summed over all rows, the augmentation cost under permutation f is sum_{{u,v} in E} (|f(u) − f(v)| − 1) = (sum_{{u,v} in E} |f(u) − f(v)|) − m. This matches the model's per-row cost last − first + 1 − one_count (with one_count = 2, that is |f(u) − f(v)| − 1).
-
Correctness (forward / YES → YES): If G has an arrangement f with sum_{{u,v} in E} |f(u) − f(v)| ≤ k, then using f as the column permutation and filling gaps within each row requires sum |f(u) − f(v)| − m ≤ k − m = bound flips. So the target is YES.
-
Correctness (reverse / YES → YES): If A can be augmented to C1P with at most bound flips, the C1P column permutation defines a vertex ordering f. Each edge row needs |f(u) − f(v)| − 1 flips, so total edge length is flips + m ≤ bound + m = k. So the source decision is YES.
Hence Decision<OptimalLinearArrangement>(G, k) is YES iff ConsecutiveOnesMatrixAugmentation(A, k − m) is YES.
Time complexity of reduction: O(n * m) to construct the incidence matrix.
Edge Inputs
The target model try_new (see src/models/algebraic/consecutive_ones_matrix_augmentation.rs) requires all rows to have equal length and bound ≥ 0; it does not reject a 0-column or 0-row matrix per se, but a 0-row matrix loses the column/vertex identity (num_cols is read from the first row, so a 0 × n matrix reports num_cols = 0). Two degenerate inputs must be handled explicitly:
-
Edgeless graph (m = 0). The incidence matrix would be 0 × n, collapsing to a 0-column matrix that erases the vertex arrangement. Since with no edges the total edge length is 0 for every arrangement, the source decision is YES iff k ≥ 0 (always true for the decision bound). Emit a sentinel 1×1 matrix [[false]] with bound = max(0, k): this matrix already has C1P (cost 0 ≤ bound), so the target is trivially YES, preserving the source value. (A 1×1 all-zero matrix is the smallest instance accepted by try_new that keeps num_cols ≥ 1.)
-
Negative target bound (k < m). try_new rejects bound < 0. When k < m the source decision is NO (every arrangement costs at least m, since each of the m edges contributes at least 1). Encode a trivially-NO target. Note that ConsecutiveOnesMatrixAugmentation permutes columns, so a single row (or any matrix whose rows can be made simultaneously consecutive by some column permutation) is YES at bound = 0 — a naive [[true, false, true]] would be wrongly accepted with 0 flips after permuting its columns. Instead emit the 3×3 cyclic-overlap matrix [[true, true, false], [false, true, true], [true, false, true]] with bound = 0. Under every of the 6 column permutations the three rows cannot all be made consecutive at once: at least one row's two 1's straddle a 0, so the minimum augmentation cost is 1 > 0 for all permutations. This is a genuine NO at bound = 0, matching the source. The implementation should map any k < m instance to this fixed NO instance.
Note: isolated vertices (degree-0 vertices in a graph with m ≥ 1) are harmless — they simply produce an all-zero column, which is still a valid column and preserves the vertex/column correspondence.
Size Overhead
Symbols (all are real getters on the source Decision<OptimalLinearArrangement>):
num_vertices = |V|
num_edges = |E|
k = the source decision bound
| Target metric (code name) |
Polynomial (using source getters) |
num_rows |
num_edges |
num_cols |
num_vertices |
bound |
k - num_edges |
Derivation: The incidence matrix has one row per edge (num_rows = num_edges) and one column per vertex (num_cols = num_vertices). The augmentation bound is the source decision bound minus the number of edges (bound = k − num_edges), reflecting the baseline cost of 1 flip per edge in any arrangement. (For the degenerate-input sentinels above the actual constructed sizes are the fixed 1×1 / 1×3 matrices; the overhead expressions describe the generic m ≥ 1, k ≥ m case used for asymptotic scaling.)
Validation Method
- Closed-loop test: build a
Decision<OptimalLinearArrangement> instance (G, k), reduce to ConsecutiveOnesMatrixAugmentation, solve the target with BruteForce (decision Or), extract the witness column permutation + flips, reconstruct the vertex arrangement on the source, and confirm the source decision value (Or) agrees.
- YES case: path graph
P_6 with k = 5. Incidence matrix is 5 × 6, bound = 5 − 5 = 0; the path incidence matrix already has C1P → YES on both sides.
- NO case: the same graph with
k = 4 (< m) routes to the fixed 3×3 cyclic-overlap NO sentinel ([[true, true, false], [false, true, true], [true, false, true]], bound = 0, min cost 1 over all column permutations); source decision is NO (every arrangement costs ≥ 5) → NO on both sides.
- Edgeless case:
G = ({0,1,2}, ∅), any k. Target is the [[false]] sentinel → YES, matching the always-YES source.
Example
Source instance (Decision<OptimalLinearArrangement>):
Graph G with 6 vertices {0,1,2,3,4,5} and 7 edges:
- Edges:
e0={0,1}, e1={1,2}, e2={2,3}, e3={3,4}, e4={4,5}, e5={0,3}, e6={2,5}
- Decision bound
k = 11
Constructed target instance (ConsecutiveOnesMatrixAugmentation):
Matrix A (7 × 6), edge-vertex incidence matrix:
v0 v1 v2 v3 v4 v5
e0: [ 1, 1, 0, 0, 0, 0 ] (edge {0,1})
e1: [ 0, 1, 1, 0, 0, 0 ] (edge {1,2})
e2: [ 0, 0, 1, 1, 0, 0 ] (edge {2,3})
e3: [ 0, 0, 0, 1, 1, 0 ] (edge {3,4})
e4: [ 0, 0, 0, 0, 1, 1 ] (edge {4,5})
e5: [ 1, 0, 0, 1, 0, 0 ] (edge {0,3})
e6: [ 0, 0, 1, 0, 0, 1 ] (edge {2,5})
Target bound = k − m = 11 − 7 = 4.
Solution mapping (YES):
- Column permutation (arrangement):
f(0)=1, f(1)=2, f(2)=3, f(3)=4, f(4)=5, f(5)=6 (identity ordering v0,…,v5).
- Rows
e0–e4 already have consecutive 1's (adjacent vertices) → 0 flips each.
- Row
e5 (edge {0,3}): 1's at columns 0 and 3, fill positions 1,2 → 2 flips.
- Row
e6 (edge {2,5}): 1's at columns 2 and 5, fill positions 3,4 → 2 flips.
- Total flips:
0+0+0+0+0+2+2 = 4 = bound. Target YES.
Verification:
- Total edge length:
|1−2|+|2−3|+|3−4|+|4−5|+|5−6|+|1−4|+|3−6| = 1+1+1+1+1+3+3 = 11 = k. Source decision YES (≤ 11).
- Total flips
= 11 − 7 = 4 = bound. Consistent.
NO sub-case (same graph, k = 10): bound = 10 − 7 = 3. The minimum augmentation cost over all column permutations equals optimal_OLA − m = 11 − 7 = 4 > 3 (the optimal arrangement cost for this graph is 11, brute-force verified), so the target is NO. Correspondingly the source has no arrangement of total length ≤ 10 → source decision NO. Both sides agree.
References
- [Booth, 1975]: [
Booth1975] K. S. Booth (1975). "{PQ} Tree Algorithms". University of California, Berkeley. (Published form: K. S. Booth, "Approximation of the Consecutive Ones Matrix Augmentation Problem," SIAM J. Comput. 14(1):214 (1987), DOI 10.1137/0214052.)
- [Papadimitriou, 1976a]: [
Papadimitriou1976a] Christos H. Papadimitriou (1976). "The {NP}-completeness of the bandwidth minimization problem". Computing 16, pp. 263-270. (Companion reference cited by G&J for SR16; the C1MA construction itself is Booth's.)
- [Garey, Johnson, and Stockmeyer, 1976]: [
Garey1976g] M. R. Garey and D. S. Johnson and L. Stockmeyer (1976). "Some simplified {NP}-complete graph problems". Theoretical Computer Science 1, pp. 237-267.
Source: Decision<OptimalLinearArrangement> (decision variant: graph G, bound K)
Target: Consecutive Ones Matrix Augmentation (decision)
Motivation: Establishes NP-completeness of CONSECUTIVE ONES MATRIX AUGMENTATION via polynomial-time reduction from OPTIMAL LINEAR ARRANGEMENT (GT42). The reduction encodes a vertex-ordering problem as a matrix-augmentation problem: given the vertex-edge incidence matrix of the graph, a linear arrangement with total edge length at most
Kcorresponds to a column permutation under which at mostK − |E|zero-to-one flips achieve the consecutive ones property.Reference: Garey & Johnson, Computers and Intractability, problem SR16 (p. 229); transformation from OPTIMAL LINEAR ARRANGEMENT (GT42, p. 200).
Decision-vs-Decision Framing
Both endpoints of this reduction are decision problems with
Value = Or:Decision<OptimalLinearArrangement>: a graphG = (V, E)plus a decision boundk. It is YES iffGadmits a linear arrangementf : V → {1, …, |V|}(a bijection) with total edge lengthsum_{{u,v} in E} |f(u) − f(v)| ≤ k.ConsecutiveOnesMatrixAugmentation: a binary matrixAplus a nonnegative boundbound. It is YES iff some column permutation ofAplus at mostboundzero-to-one flips yields the consecutive ones property (every row's 1's are contiguous).The base
OptimalLinearArrangementmodel in the codebase is the optimization variant (Value = Min<usize>, no bound). This reduction is stated against the decision variantDecision<OptimalLinearArrangement>, which carries the boundk. See the Prerequisite section below.Prerequisite
Decision<OptimalLinearArrangement>is not yet registered in the codebase. The implementation PR for this rule must add it first, following the precedents atsrc/models/graph/minimum_vertex_cover.rsandsrc/models/graph/minimum_dominating_set.rs:impl ... DecisionProblemMeta for OptimalLinearArrangement<SimpleGraph>withconst DECISION_NAME = "DecisionOptimalLinearArrangement";Decision<OptimalLinearArrangement<SimpleGraph>>:num_vertices() -> usize(delegates toinner().num_vertices())num_edges() -> usize(delegates toinner().num_edges())k() -> usize(the decision bound,(*self.bound()).try_into().unwrap_or(0))register_decision_variant!(OptimalLinearArrangement<SimpleGraph>, "DecisionOptimalLinearArrangement", ..., size_getters: [("num_vertices", num_vertices), ("num_edges", num_edges)]).The reduction
impl ReduceTo<ConsecutiveOnesMatrixAugmentation> for Decision<OptimalLinearArrangement<SimpleGraph>>then references the gettersnum_vertices,num_edges, andk.GJ Source Entry
Reduction Algorithm
Summary:
Given a
Decision<OptimalLinearArrangement>instance(G = (V, E), k), construct aConsecutiveOnesMatrixAugmentationinstance as follows.Let
n = |V|(num_vertices) andm = |E|(num_edges). We build the edge-vertex incidence matrix ofG.Matrix construction: Construct the
m x nbinary matrixAwhere rows correspond to edges and columns to vertices. For edgee_i = {u, v}, setA[i][u] = 1andA[i][v] = 1, and all other entries in rowito0. Each row has exactly two 1's.Bound: Set the target
bound = k − m, wherekis the source decision bound andm = num_edges. (Handling ofk < mandm = 0is covered under Edge Inputs below.)Intuition: A column permutation is exactly a vertex ordering
f : V → {1, …, n}. In rowifor edge{u, v}, the two 1's land at positionsf(u)andf(v). Making this row consecutive requires filling all 0's strictly between them:|f(u) − f(v)| − 1flips. Summed over all rows, the augmentation cost under permutationfissum_{{u,v} in E} (|f(u) − f(v)| − 1) = (sum_{{u,v} in E} |f(u) − f(v)|) − m. This matches the model's per-row costlast − first + 1 − one_count(withone_count = 2, that is|f(u) − f(v)| − 1).Correctness (forward / YES → YES): If
Ghas an arrangementfwithsum_{{u,v} in E} |f(u) − f(v)| ≤ k, then usingfas the column permutation and filling gaps within each row requiressum |f(u) − f(v)| − m ≤ k − m = boundflips. So the target is YES.Correctness (reverse / YES → YES): If
Acan be augmented to C1P with at mostboundflips, the C1P column permutation defines a vertex orderingf. Each edge row needs|f(u) − f(v)| − 1flips, so total edge length isflips + m ≤ bound + m = k. So the source decision is YES.Hence
Decision<OptimalLinearArrangement>(G, k)is YES iffConsecutiveOnesMatrixAugmentation(A, k − m)is YES.Time complexity of reduction:
O(n * m)to construct the incidence matrix.Edge Inputs
The target model
try_new(seesrc/models/algebraic/consecutive_ones_matrix_augmentation.rs) requires all rows to have equal length andbound ≥ 0; it does not reject a 0-column or 0-row matrix per se, but a 0-row matrix loses the column/vertex identity (num_colsis read from the first row, so a0 × nmatrix reportsnum_cols = 0). Two degenerate inputs must be handled explicitly:Edgeless graph (
m = 0). The incidence matrix would be0 × n, collapsing to a0-column matrix that erases the vertex arrangement. Since with no edges the total edge length is0for every arrangement, the source decision is YES iffk ≥ 0(always true for the decision bound). Emit a sentinel 1×1 matrix[[false]]withbound = max(0, k): this matrix already has C1P (cost 0 ≤ bound), so the target is trivially YES, preserving the source value. (A 1×1 all-zero matrix is the smallest instance accepted bytry_newthat keepsnum_cols ≥ 1.)Negative target bound (
k < m).try_newrejectsbound < 0. Whenk < mthe source decision is NO (every arrangement costs at leastm, since each of themedges contributes at least 1). Encode a trivially-NO target. Note thatConsecutiveOnesMatrixAugmentationpermutes columns, so a single row (or any matrix whose rows can be made simultaneously consecutive by some column permutation) is YES atbound = 0— a naive[[true, false, true]]would be wrongly accepted with 0 flips after permuting its columns. Instead emit the 3×3 cyclic-overlap matrix[[true, true, false], [false, true, true], [true, false, true]]withbound = 0. Under every of the 6 column permutations the three rows cannot all be made consecutive at once: at least one row's two 1's straddle a 0, so the minimum augmentation cost is1 > 0for all permutations. This is a genuine NO atbound = 0, matching the source. The implementation should map anyk < minstance to this fixed NO instance.Note: isolated vertices (degree-0 vertices in a graph with
m ≥ 1) are harmless — they simply produce an all-zero column, which is still a valid column and preserves the vertex/column correspondence.Size Overhead
Symbols (all are real getters on the source
Decision<OptimalLinearArrangement>):num_vertices=|V|num_edges=|E|k= the source decision boundnum_rowsnum_edgesnum_colsnum_verticesboundk - num_edgesDerivation: The incidence matrix has one row per edge (
num_rows = num_edges) and one column per vertex (num_cols = num_vertices). The augmentation bound is the source decision bound minus the number of edges (bound = k − num_edges), reflecting the baseline cost of 1 flip per edge in any arrangement. (For the degenerate-input sentinels above the actual constructed sizes are the fixed 1×1 / 1×3 matrices; the overhead expressions describe the genericm ≥ 1,k ≥ mcase used for asymptotic scaling.)Validation Method
Decision<OptimalLinearArrangement>instance(G, k), reduce toConsecutiveOnesMatrixAugmentation, solve the target withBruteForce(decisionOr), extract the witness column permutation + flips, reconstruct the vertex arrangement on the source, and confirm the source decision value (Or) agrees.P_6withk = 5. Incidence matrix is5 × 6,bound = 5 − 5 = 0; the path incidence matrix already has C1P → YES on both sides.k = 4(< m) routes to the fixed 3×3 cyclic-overlap NO sentinel ([[true, true, false], [false, true, true], [true, false, true]],bound = 0, min cost 1 over all column permutations); source decision is NO (every arrangement costs ≥ 5) → NO on both sides.G = ({0,1,2}, ∅), anyk. Target is the[[false]]sentinel → YES, matching the always-YES source.Example
Source instance (
Decision<OptimalLinearArrangement>):Graph
Gwith 6 vertices{0,1,2,3,4,5}and 7 edges:e0={0,1}, e1={1,2}, e2={2,3}, e3={3,4}, e4={4,5}, e5={0,3}, e6={2,5}k = 11Constructed target instance (
ConsecutiveOnesMatrixAugmentation):Matrix
A(7 × 6), edge-vertex incidence matrix:Target
bound = k − m = 11 − 7 = 4.Solution mapping (YES):
f(0)=1, f(1)=2, f(2)=3, f(3)=4, f(4)=5, f(5)=6(identity orderingv0,…,v5).e0–e4already have consecutive 1's (adjacent vertices) → 0 flips each.e5(edge{0,3}): 1's at columns 0 and 3, fill positions 1,2 → 2 flips.e6(edge{2,5}): 1's at columns 2 and 5, fill positions 3,4 → 2 flips.0+0+0+0+0+2+2 = 4 = bound. Target YES.Verification:
|1−2|+|2−3|+|3−4|+|4−5|+|5−6|+|1−4|+|3−6| = 1+1+1+1+1+3+3 = 11 = k. Source decision YES (≤ 11).= 11 − 7 = 4 = bound. Consistent.NO sub-case (same graph,
k = 10):bound = 10 − 7 = 3. The minimum augmentation cost over all column permutations equalsoptimal_OLA − m = 11 − 7 = 4 > 3(the optimal arrangement cost for this graph is 11, brute-force verified), so the target is NO. Correspondingly the source has no arrangement of total length ≤ 10 → source decision NO. Both sides agree.References
Booth1975] K. S. Booth (1975). "{PQ} Tree Algorithms". University of California, Berkeley. (Published form: K. S. Booth, "Approximation of the Consecutive Ones Matrix Augmentation Problem," SIAM J. Comput. 14(1):214 (1987), DOI 10.1137/0214052.)Papadimitriou1976a] Christos H. Papadimitriou (1976). "The {NP}-completeness of the bandwidth minimization problem". Computing 16, pp. 263-270. (Companion reference cited by G&J for SR16; the C1MA construction itself is Booth's.)Garey1976g] M. R. Garey and D. S. Johnson and L. Stockmeyer (1976). "Some simplified {NP}-complete graph problems". Theoretical Computer Science 1, pp. 237-267.