Source: MaxCut on SimpleGraph with i32 edge weights, restricted to nonnegative integer weights (w(e) >= 0 for every e in E). The MaxCut/SimpleGraph/One (unit-weight) variant is the special case w(e) == 1 and is automatically covered.
Target: MinimumMatrixCover
Motivation: Establishes a direct, witness-preserving reduction MaxCut -> MinimumMatrixCover. The construction takes the symmetric weighted adjacency matrix of G as the target matrix A, exploiting the well-known identity
sum_{i,j} a_{ij} f(i) f(j) = 2 W - 4 * cut(S), where S = { i : f(i) = +1 } and W = sum_{e in E} w(e). Maximizing the cut is therefore equivalent to minimizing the quadratic form, which is exactly what MinimumMatrixCover solves. This is the canonical NP-hardness witness for MinimumMatrixCover (Garey & Johnson, MS13).
Reference: Garey & Johnson, Computers and Intractability (1979), Appendix A1.2, MS13 — "Transformation from MAXIMUM CUT."
Source and target framing
- Source variant.
MaxCut/SimpleGraph/i32 with the precondition w(e) >= 0 for all edges. (Unit-weight MaxCut/SimpleGraph/One is a strict special case and is covered without preprocessing.)
Value = Max<i32::Sum> (witness-capable).
- The reduction is witness-preserving: an optimal sign assignment
f* for the target maps back to an optimal cut S* = { i : f*(i) = +1 } for the source.
- Target.
MinimumMatrixCover with Value = Min<i64>. Instance is an n x n nonnegative integer matrix A (Vec<Vec<i64>>).
- Precondition rationale.
MinimumMatrixCover requires nonnegative integer entries (see src/models/algebraic/minimum_matrix_cover.rs). The direct construction a_{ij} = w({i,j}) preserves nonnegativity iff source weights are nonnegative. Negative-weight MaxCut instances are out of scope for this rule and must use a different reduction (e.g., a preprocessing rule that shifts weights and rewrites the objective, registered separately).
GJ Source Entry
[MS13] MATRIX COVER
INSTANCE: n x n matrix A = [a_{ij}] of nonnegative integers.
QUESTION (decision form): Does there exist f : {1,...,n} -> {-1, +1} such that sum_{1 <= i, j <= n} a_{ij} * f(i) * f(j) <= K?
Reference: Transformation from MAXIMUM CUT.
Comment: NP-complete in the strong sense, even for positive definite A. In this codebase the optimization form MinimumMatrixCover is used directly, with Value = Min<i64> (no K parameter).
Reduction Algorithm
Construction (the only construction used by this rule).
Given a MaxCut instance (G, w) with G = (V, E), |V| = n, and nonnegative integer weights w : E -> Z_{>= 0}:
-
Build the n x n adjacency matrix A with i64 entries:
a_{ij} = w({i, j}) if {i, j} in E,
a_{ij} = 0 otherwise,
a_{ii} = 0 for all i.
A is symmetric, zero-diagonal, and nonnegative — a valid MinimumMatrixCover instance.
-
Forward map (witness). Given a MaxCut cut S subseteq V, set f(i) = +1 if i in S, else f(i) = -1.
-
Backward map (witness extraction). Given an optimal sign assignment f* from MinimumMatrixCover, return S* = { i in V : f*(i) = +1 }. The complementary set V \ S* is also optimal (the symmetry f -> -f leaves the quadratic form invariant).
Key identity. For any f in {-1, +1}^n and the corresponding S = { i : f(i) = +1 }:
sum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 * cut(S),
where W = sum_{e in E} w(e) is the total edge weight and cut(S) = sum_{ {i, j} in E, |S cap {i, j}| = 1 } w({i, j}).
Proof of identity. Each edge {i, j} in E contributes to the double sum sum_{i, j} a_{ij} f(i) f(j) twice (once as (i, j), once as (j, i)):
- If
{i, j} is not cut by S, both endpoints share a sign, so f(i) f(j) = +1 and the edge contributes +2 w({i, j}).
- If
{i, j} is cut, the endpoints disagree, so f(i) f(j) = -1 and the edge contributes -2 w({i, j}).
Summing: sum_{i, j} a_{ij} f(i) f(j) = 2 (W - cut(S)) - 2 cut(S) = 2 W - 4 cut(S). QED.
Objective equivalence. Because 2 W is a constant depending only on the source instance,
min_f sum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 * max_S cut(S),
so
MaxCut(G, w) = (2 W - MinimumMatrixCover(A)) / 4.
Witness correctness. A sign assignment f* minimizes the quadratic form iff S* = { i : f*(i) = +1 } (equivalently, its complement) maximizes the cut. The MinimumMatrixCover brute-force solver returns one such f* directly, and the backward map yields a maximum cut.
Time complexity of the reduction itself. O(n^2) to materialize A.
Size Overhead
Symbols:
num_vertices — n = |V| of the source graph.
| Target metric (code name) |
Polynomial (using source symbols) |
Big-O |
num_rows |
num_vertices |
O(num_vertices) |
MinimumMatrixCover's only size field is num_rows = n. The matrix has n^2 entries but that is a derived quantity, not a size field.
Validation Method
- Closed-loop test (mandatory). For several small instances
(G, w):
- Construct the source
MaxCut/SimpleGraph/i32 with nonneg integer weights.
- Apply this reduction to obtain
MinimumMatrixCover(A).
- Solve the target via
BruteForce to obtain min_qf and a witness f*.
- Verify
MaxCut(G, w) = (2 W - min_qf) / 4 by also solving the source via BruteForce.
- Verify witness extraction:
S* = { i : f*(i) = +1 } is an optimal cut in G (equal weight to the source-side optimum).
- Unit-weight cases.
K_3 (max cut = 2), K_{2,2} (max cut = 4), C_4 (max cut = 4 — see the worked example).
- Weighted nonneg cases. Path graph
P_3 with weights (2, 3) — max cut = 5, single optimal partition mod symmetry.
- Edge cases. Empty graph (matrix =
0, max cut = 0); single isolated edge with isolated vertices; disconnected union of two triangles.
- Identity check. For at least one small
n, iterate over all 2^n sign assignments and confirm sum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 cut(S) for every f.
- Precondition test. Construct a
MaxCut/SimpleGraph/i32 instance with a negative edge weight and assert that reduce_to panics or returns an error (the rule does not handle this variant).
Example
Source instance (MaxCut/SimpleGraph/i32, nonneg weights).
Graph G = (V, E) with V = {0, 1, 2, 3}, edges E = { {0,1}, {1,2}, {2,3}, {0,3} } (the 4-cycle C_4), all weights w({i, j}) = 1. Then W = 4. Maximum cut: S* = {0, 2} (or symmetrically {1, 3}), cutting all 4 edges, so MaxCut(G, w) = 4.
Constructed target instance (MinimumMatrixCover).
A is the weighted adjacency matrix of G:
j=0 j=1 j=2 j=3
i=0: 0 1 0 1
i=1: 1 0 1 0
i=2: 0 1 0 1
i=3: 1 0 1 0
All entries are nonnegative integers, the diagonal is zero, and A is symmetric — a valid MinimumMatrixCover instance.
Solving the target. Enumerate all 16 sign assignments and compute qf(f) = sum_{i, j} a_{ij} f(i) f(j):
f |
S = { i : f(i) = +1 } |
cut(S) |
qf(f) = 2W - 4 cut(S) |
(+1, +1, +1, +1) |
{0, 1, 2, 3} |
0 |
+8 |
(+1, -1, +1, -1) |
{0, 2} |
4 |
-8 |
(-1, +1, -1, +1) |
{1, 3} |
4 |
-8 |
(+1, +1, -1, -1) |
{0, 1} |
2 |
0 |
(Other rows omitted; the minimum is -8.)
So MinimumMatrixCover(A) = -8, attained by f* = (+1, -1, +1, -1) (and its negation).
Recovered cut. S* = { i : f*(i) = +1 } = {0, 2}. Check the formula: MaxCut(G, w) = (2 W - min_qf) / 4 = (2 * 4 - (-8)) / 4 = 16 / 4 = 4. Matches. The recovered S* is exactly a maximum cut of G.
Notes / Alternative constructions (informational, not used by this rule)
For completeness, two constructions sometimes appear in the literature; this rule does not use them. They are listed here only to head off confusion:
- Complement-graph construction. Set
A to be the weighted adjacency matrix of the complement graph bar{G}. This swaps the roles of cut and non-cut edges in the quadratic form and is irrelevant once we are minimizing (rather than maximizing) directly. Not used.
- Weight-shifting for negative-weight
MaxCut. A separate (future) reduction may handle negative weights by adding a constant c >= -min_e w(e) to all entries of A and tracking the resulting additive shift in the objective. This is not part of the present rule, which restricts to nonneg-weight sources.
References
- [Garey and Johnson, 1979]: M. R. Garey and D. S. Johnson (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, p. 226 (MS13).
- [Goemans and Williamson, 1995]: M. X. Goemans and D. P. Williamson (1995). "Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming." Journal of the ACM 42(6), pp. 1115-1145. (Background on MaxCut; not used in the NP-hardness reduction itself.)
Source:
MaxCutonSimpleGraphwithi32edge weights, restricted to nonnegative integer weights (w(e) >= 0for everye in E). TheMaxCut/SimpleGraph/One(unit-weight) variant is the special casew(e) == 1and is automatically covered.Target:
MinimumMatrixCoverMotivation: Establishes a direct, witness-preserving reduction
MaxCut -> MinimumMatrixCover. The construction takes the symmetric weighted adjacency matrix ofGas the target matrixA, exploiting the well-known identitysum_{i,j} a_{ij} f(i) f(j) = 2 W - 4 * cut(S), whereS = { i : f(i) = +1 }andW = sum_{e in E} w(e). Maximizing the cut is therefore equivalent to minimizing the quadratic form, which is exactly whatMinimumMatrixCoversolves. This is the canonical NP-hardness witness forMinimumMatrixCover(Garey & Johnson, MS13).Reference: Garey & Johnson, Computers and Intractability (1979), Appendix A1.2, MS13 — "Transformation from MAXIMUM CUT."
Source and target framing
MaxCut/SimpleGraph/i32with the preconditionw(e) >= 0for all edges. (Unit-weightMaxCut/SimpleGraph/Oneis a strict special case and is covered without preprocessing.)Value = Max<i32::Sum>(witness-capable).f*for the target maps back to an optimal cutS* = { i : f*(i) = +1 }for the source.MinimumMatrixCoverwithValue = Min<i64>. Instance is ann x nnonnegative integer matrixA(Vec<Vec<i64>>).MinimumMatrixCoverrequires nonnegative integer entries (seesrc/models/algebraic/minimum_matrix_cover.rs). The direct constructiona_{ij} = w({i,j})preserves nonnegativity iff source weights are nonnegative. Negative-weightMaxCutinstances are out of scope for this rule and must use a different reduction (e.g., a preprocessing rule that shifts weights and rewrites the objective, registered separately).GJ Source Entry
Reduction Algorithm
Construction (the only construction used by this rule).
Given a
MaxCutinstance(G, w)withG = (V, E),|V| = n, and nonnegative integer weightsw : E -> Z_{>= 0}:Build the
n x nadjacency matrixAwithi64entries:a_{ij} = w({i, j})if{i, j} in E,a_{ij} = 0otherwise,a_{ii} = 0for alli.Ais symmetric, zero-diagonal, and nonnegative — a validMinimumMatrixCoverinstance.Forward map (witness). Given a
MaxCutcutS subseteq V, setf(i) = +1ifi in S, elsef(i) = -1.Backward map (witness extraction). Given an optimal sign assignment
f*fromMinimumMatrixCover, returnS* = { i in V : f*(i) = +1 }. The complementary setV \ S*is also optimal (the symmetryf -> -fleaves the quadratic form invariant).Key identity. For any
f in {-1, +1}^nand the correspondingS = { i : f(i) = +1 }:sum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 * cut(S),where
W = sum_{e in E} w(e)is the total edge weight andcut(S) = sum_{ {i, j} in E, |S cap {i, j}| = 1 } w({i, j}).Proof of identity. Each edge
{i, j} in Econtributes to the double sumsum_{i, j} a_{ij} f(i) f(j)twice (once as(i, j), once as(j, i)):{i, j}is not cut byS, both endpoints share a sign, sof(i) f(j) = +1and the edge contributes+2 w({i, j}).{i, j}is cut, the endpoints disagree, sof(i) f(j) = -1and the edge contributes-2 w({i, j}).Summing:
sum_{i, j} a_{ij} f(i) f(j) = 2 (W - cut(S)) - 2 cut(S) = 2 W - 4 cut(S). QED.Objective equivalence. Because
2 Wis a constant depending only on the source instance,min_f sum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 * max_S cut(S),so
MaxCut(G, w) = (2 W - MinimumMatrixCover(A)) / 4.Witness correctness. A sign assignment
f*minimizes the quadratic form iffS* = { i : f*(i) = +1 }(equivalently, its complement) maximizes the cut. TheMinimumMatrixCoverbrute-force solver returns one suchf*directly, and the backward map yields a maximum cut.Time complexity of the reduction itself.
O(n^2)to materializeA.Size Overhead
Symbols:
num_vertices—n = |V|of the source graph.num_rowsnum_verticesO(num_vertices)MinimumMatrixCover's only size field isnum_rows = n. The matrix hasn^2entries but that is a derived quantity, not a size field.Validation Method
(G, w):MaxCut/SimpleGraph/i32with nonneg integer weights.MinimumMatrixCover(A).BruteForceto obtainmin_qfand a witnessf*.MaxCut(G, w) = (2 W - min_qf) / 4by also solving the source viaBruteForce.S* = { i : f*(i) = +1 }is an optimal cut inG(equal weight to the source-side optimum).K_3(max cut = 2),K_{2,2}(max cut = 4),C_4(max cut = 4 — see the worked example).P_3with weights(2, 3)— max cut = 5, single optimal partition mod symmetry.0, max cut =0); single isolated edge with isolated vertices; disconnected union of two triangles.n, iterate over all2^nsign assignments and confirmsum_{i, j} a_{ij} f(i) f(j) = 2 W - 4 cut(S)for everyf.MaxCut/SimpleGraph/i32instance with a negative edge weight and assert thatreduce_topanics or returns an error (the rule does not handle this variant).Example
Source instance (
MaxCut/SimpleGraph/i32, nonneg weights).Graph
G = (V, E)withV = {0, 1, 2, 3}, edgesE = { {0,1}, {1,2}, {2,3}, {0,3} }(the 4-cycleC_4), all weightsw({i, j}) = 1. ThenW = 4. Maximum cut:S* = {0, 2}(or symmetrically{1, 3}), cutting all 4 edges, soMaxCut(G, w) = 4.Constructed target instance (
MinimumMatrixCover).Ais the weighted adjacency matrix ofG:All entries are nonnegative integers, the diagonal is zero, and
Ais symmetric — a validMinimumMatrixCoverinstance.Solving the target. Enumerate all 16 sign assignments and compute
qf(f) = sum_{i, j} a_{ij} f(i) f(j):fS = { i : f(i) = +1 }cut(S)qf(f) = 2W - 4 cut(S)(+1, +1, +1, +1){0, 1, 2, 3}+8(+1, -1, +1, -1){0, 2}-8(-1, +1, -1, +1){1, 3}-8(+1, +1, -1, -1){0, 1}0(Other rows omitted; the minimum is
-8.)So
MinimumMatrixCover(A) = -8, attained byf* = (+1, -1, +1, -1)(and its negation).Recovered cut.
S* = { i : f*(i) = +1 } = {0, 2}. Check the formula:MaxCut(G, w) = (2 W - min_qf) / 4 = (2 * 4 - (-8)) / 4 = 16 / 4 = 4. Matches. The recoveredS*is exactly a maximum cut ofG.Notes / Alternative constructions (informational, not used by this rule)
For completeness, two constructions sometimes appear in the literature; this rule does not use them. They are listed here only to head off confusion:
Ato be the weighted adjacency matrix of the complement graphbar{G}. This swaps the roles of cut and non-cut edges in the quadratic form and is irrelevant once we are minimizing (rather than maximizing) directly. Not used.MaxCut. A separate (future) reduction may handle negative weights by adding a constantc >= -min_e w(e)to all entries ofAand tracking the resulting additive shift in the objective. This is not part of the present rule, which restricts to nonneg-weight sources.References