Skip to content

Commit 8a747ea

Browse files
committed
Add rule: MinimumMaximalMatching -> MinimumMatrixDomination (#847)
1 parent 1826867 commit 8a747ea

4 files changed

Lines changed: 446 additions & 0 deletions

File tree

docs/paper/reductions.typ

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14480,6 +14480,74 @@ The following reductions to Integer Linear Programming are straightforward formu
1448014480
_Solution extraction._ Group target vertices by color. Every class of size $2$ identifies a source edge in $E$; mark those edges as selected (and leave all others unselected) to obtain a maximal matching $M$ of $G$ with $|M| = |V| - k$.
1448114481
]
1448214482

14483+
#let mmm_mmd = load-example("MinimumMaximalMatching", "MinimumMatrixDomination")
14484+
#let mmm_mmd_sol = mmm_mmd.solutions.at(0)
14485+
#reduction-rule("MinimumMaximalMatching", "MinimumMatrixDomination",
14486+
example: true,
14487+
example-source-variant: (graph: "BipartiteGraph"),
14488+
example-caption: [Bipartite graph $B$ with $L = {l_0, l_1}$, $R = {r_0, r_1, r_2}$, and $|F| = 5$ edges.],
14489+
extra: [
14490+
#{
14491+
let m-left = mmm_mmd.source.instance.graph.left_size
14492+
let n-right = mmm_mmd.source.instance.graph.right_size
14493+
let local-edges = mmm_mmd.source.instance.graph.edges
14494+
let ones = mmm_mmd.target.instance.ones
14495+
let big-n = mmm_mmd.target.instance.matrix.len()
14496+
let s-cfg = mmm_mmd_sol.source_config
14497+
let t-cfg = mmm_mmd_sol.target_config
14498+
let matched-source = s-cfg.enumerate()
14499+
.filter(((i, x)) => x == 1)
14500+
.map(((i, _)) => i)
14501+
let selected-target = t-cfg.enumerate()
14502+
.filter(((i, x)) => x == 1)
14503+
.map(((i, _)) => i)
14504+
[
14505+
#pred-commands(
14506+
"pred create --example " + problem-spec(mmm_mmd.source) + " -o mmm.json",
14507+
"pred reduce mmm.json --to " + target-spec(mmm_mmd) + " -o bundle.json",
14508+
"pred solve bundle.json",
14509+
"pred evaluate mmm.json --config " + s-cfg.map(str).join(","),
14510+
)
14511+
14512+
*Step 1 -- Source instance.* Bipartite graph $B$ with $|L| = #m-left$, $|R| = #n-right$ and $#local-edges.len()$ bipartite-local edges #local-edges.map(e => $(#e.at(0), #e.at(1))$).join(", "). The decision threshold is $K = 2$.
14513+
14514+
*Step 2 -- Embedded matrix.* The constructed instance is the $#big-n times #big-n$ binary matrix $M$ whose upper-right $#m-left times #n-right$ block holds the biadjacency matrix $B^*$. Its $#ones.len()$ 1-entries lie at positions #ones.map(p => $(#p.at(0), #p.at(1))$).join(", "), and $M$ is upper triangular (all 1-entries above the row-block boundary).
14515+
14516+
*Step 3 -- Source optimum.* A minimum maximal matching $M^* = {(l_0, r_0), (l_1, r_1)}$ uses source edge indices #matched-source.map(i => str(i)).join(", "), giving $"mm"(B) = #matched-source.len() = 2$.
14517+
14518+
*Step 4 -- Target optimum.* The fixture selects the matrix-domination set $C = {(0, 2), (1, 3)}$ at 1-entry indices #selected-target.map(i => str(i)).join(", "). Every other 1-entry of $M$ shares row $0$ or row $1$ with one of the chosen entries, so $C$ is dominating with $|C| = #selected-target.len() = 2 = "mm"(B) #sym.checkmark$.
14519+
14520+
*Extraction.* The selected 1-entries here happen to be pairwise independent (no shared row or column), so they already correspond to a matching of $B$. In general a matrix-domination witness only yields an edge dominating set, and the Yannakakis-Gavril transformation @yannakakis1980 converts it to a maximal matching of equal size.
14521+
]
14522+
}
14523+
],
14524+
)[
14525+
This $O(n^2)$ reduction @yannakakis1980 takes a bipartite source $B = (L, R, F)$ with $|L| = m$ and $|R| = n$, builds the $N times N$ binary matrix $M$ on $N = m + n$ rows and columns whose upper-right $m times n$ block is the biadjacency matrix $B^*$ and whose other entries are zero, and leaves the decision threshold unchanged. The resulting matrix has exactly $|F|$ 1-entries and is upper triangular.
14526+
][
14527+
_Construction._ Given a Minimum Maximal Matching instance $(B = (L, R, F), K)$ with $B$ bipartite, label the vertices so that $L = {l_0, dots, l_(m-1)}$ corresponds to rows $0, dots, m-1$ of $M$ and $R = {r_0, dots, r_(n-1)}$ corresponds to columns $m, dots, m+n-1$. Define
14528+
$
14529+
M_(i,j) = cases(
14530+
1 quad &"if " i < m " and " j >= m " and " (l_i, r_(j-m)) in F,
14531+
0 quad &"otherwise",
14532+
)
14533+
$
14534+
and set $K' = K$. Output the Minimum Matrix Domination instance $(M, K')$.
14535+
14536+
_Correctness._ The reduction proves the identity $"md"(M) = "mm"(B)$, where $"md"$ denotes the minimum matrix-domination size and $"mm"$ the minimum maximal-matching size.
14537+
14538+
Each 1-entry of $M$ lies in the upper-right block and therefore corresponds bijectively to a source edge: $(i, m + j) <-> (l_i, r_j) in F$. Two 1-entries share a row iff their source edges share a left endpoint; they share a column iff their source edges share a right endpoint. Hence a set $C$ of 1-entries dominates $M$ iff the corresponding edges $F_C subset.eq F$ form an edge dominating set (EDS) of $B$.
14539+
14540+
Yannakakis and Gavril @yannakakis1980 prove that for every graph the minimum EDS size equals the minimum independent EDS size, and an independent EDS is exactly a maximal matching. Combining these facts:
14541+
14542+
($arrow.r.double$) A maximal matching $M^*$ of $B$ with $|M^*| <= K$ is in particular an EDS, so its image in $M$ is a dominating set of size $<= K = K'$.
14543+
14544+
($arrow.l.double$) A dominating set $C$ of $M$ with $|C| <= K'$ corresponds to an EDS $F_C$ of size $|C| <= K' = K$. Applying the polynomial-time Yannakakis-Gavril transformation to $F_C$ yields a maximal matching of $B$ of the same size, so $"mm"(B) <= K$.
14545+
14546+
_Solution extraction._ Read the selected 1-entries of the matrix-domination witness, map each $(i, m + j)$ back to the bipartite edge $(l_i, r_j)$ to obtain an EDS $F_C$ of $B$, and apply the Yannakakis-Gavril EDS-to-maximal-matching conversion to recover a maximal matching $M^*$ with $|M^*| = |F_C|$.
14547+
14548+
_Note on source variant._ The reduction crucially requires the source graph to be bipartite. The biadjacency matrix faithfully represents the edge structure of $B$ (each edge contributes exactly one 1-entry). The adjacency matrix of a general undirected graph would produce two symmetric 1-entries per edge that do not preserve the row/column sharing pattern.
14549+
]
14550+
1448314551
#reduction-rule("MinimumMaximalMatching", "ILP")[
1448414552
Each edge is either selected or not; matching and maximality constraints are both directly linear in binary edge indicators.
1448514553
][
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
//! Reduction from MinimumMaximalMatching (on a bipartite graph) to
2+
//! MinimumMatrixDomination.
3+
//!
4+
//! Classical reduction of Yannakakis and Gavril (1980) establishing
5+
//! NP-completeness of MATRIX DOMINATION (Garey & Johnson MS12). For a bipartite
6+
//! graph `B = (L, R, F)` with `|L| = m` and `|R| = n`, construct the `N x N`
7+
//! binary matrix `M` (with `N = m + n`) whose upper-right `m x n` block is the
8+
//! biadjacency matrix `B*` of `B` and whose remaining entries are zero. The
9+
//! 1-entries of `M` are in bijection with the edges of `B`, and two 1-entries
10+
//! share a row or column iff the corresponding edges share an endpoint. Hence a
11+
//! dominating set of 1-entries in `M` corresponds to an edge dominating set of
12+
//! `B`, and by Yannakakis and Gavril (1980), the minimum edge dominating set
13+
//! size equals the minimum maximal matching size.
14+
//!
15+
//! ## Witness extraction
16+
//!
17+
//! Solving Minimum Matrix Domination on the constructed instance yields a
18+
//! minimum edge dominating set of `B`, which is in general NOT a matching.
19+
//! Yannakakis and Gavril (1980) prove that any edge dominating set can be
20+
//! transformed in polynomial time into an independent edge dominating set
21+
//! (a maximal matching) of the same size. We implement this conversion by a
22+
//! direct search: enumerate maximal matchings of `B` and return one of size at
23+
//! most `|EDS|`. Because every minimum maximal matching is also an EDS and the
24+
//! two minima are equal, such a matching always exists when the target witness
25+
//! is optimal.
26+
//!
27+
//! ## Source variant
28+
//!
29+
//! The reduction requires the bipartite (`BipartiteGraph`) variant of
30+
//! `MinimumMaximalMatching`. The biadjacency matrix faithfully represents the
31+
//! edge structure of a bipartite graph (each edge -> exactly one 1-entry),
32+
//! whereas an undirected adjacency matrix would produce two symmetric 1-entries
33+
//! per edge that do not preserve the row/column sharing pattern.
34+
35+
use crate::models::algebraic::MinimumMatrixDomination;
36+
use crate::models::graph::MinimumMaximalMatching;
37+
use crate::reduction;
38+
use crate::rules::traits::{ReduceTo, ReductionResult};
39+
use crate::topology::{BipartiteGraph, Graph};
40+
41+
/// Result of reducing `MinimumMaximalMatching<BipartiteGraph>` to
42+
/// `MinimumMatrixDomination`.
43+
///
44+
/// Holds the constructed target matrix-domination instance together with a copy
45+
/// of the source bipartite-matching problem. The source copy is used by
46+
/// `extract_solution` to perform the Yannakakis-Gavril conversion from an edge
47+
/// dominating set to an equally-sized maximal matching.
48+
#[derive(Debug, Clone)]
49+
pub struct ReductionMMMToMatrixDomination {
50+
target: MinimumMatrixDomination,
51+
source: MinimumMaximalMatching<BipartiteGraph>,
52+
}
53+
54+
impl ReductionResult for ReductionMMMToMatrixDomination {
55+
type Source = MinimumMaximalMatching<BipartiteGraph>;
56+
type Target = MinimumMatrixDomination;
57+
58+
fn target_problem(&self) -> &Self::Target {
59+
&self.target
60+
}
61+
62+
/// Extract a maximal matching of the source bipartite graph from a
63+
/// matrix-domination witness.
64+
///
65+
/// The target witness identifies a set of 1-entries of `M`. Each selected
66+
/// 1-entry in the upper-right block `B*` corresponds bijectively to a
67+
/// source edge, so the selection induces an edge set `D` of `B` that is an
68+
/// edge dominating set. The minimum edge dominating set size of a graph
69+
/// equals the minimum maximal matching size [Yannakakis-Gavril 1980], so
70+
/// any optimal target witness yields `|D|` equal to `mm(B)`. We then
71+
/// recover a maximal matching `M` of `B` with `|M| <= |D|` by enumerating
72+
/// candidate source configurations.
73+
fn extract_solution(&self, target_solution: &[usize]) -> Vec<usize> {
74+
let num_source_edges = self.source.graph().num_edges();
75+
let target_ones = self.target.ones();
76+
let bound: usize = target_solution
77+
.iter()
78+
.zip(target_ones.iter())
79+
.filter(|(&sel, _)| sel == 1)
80+
.count();
81+
82+
// Search for any maximal matching of B with cardinality at most `bound`.
83+
// For an optimal target witness, |D| = mm(B), so such a matching
84+
// exists by Yannakakis-Gavril (1980). For canonical example sizes this
85+
// enumeration is fast; in the worst case it is 2^|E| which mirrors the
86+
// brute-force solve used elsewhere in the test infrastructure.
87+
//
88+
// Iterate by size from 0 upward so we always return a smallest-known
89+
// maximal matching.
90+
for target_size in 0..=bound {
91+
for mask in 0u64..(1u64 << num_source_edges) {
92+
if mask.count_ones() as usize != target_size {
93+
continue;
94+
}
95+
let config: Vec<usize> = (0..num_source_edges)
96+
.map(|i| ((mask >> i) & 1) as usize)
97+
.collect();
98+
if self.source.is_valid_maximal_matching(&config) {
99+
return config;
100+
}
101+
}
102+
}
103+
104+
// Fallback: a zero configuration. This branch is unreachable when the
105+
// reduction is correct and the supplied target witness is feasible.
106+
vec![0; num_source_edges]
107+
}
108+
}
109+
110+
#[reduction(
111+
overhead = {
112+
num_rows = "num_vertices",
113+
num_cols = "num_vertices",
114+
num_ones = "num_edges",
115+
}
116+
)]
117+
impl ReduceTo<MinimumMatrixDomination> for MinimumMaximalMatching<BipartiteGraph> {
118+
type Result = ReductionMMMToMatrixDomination;
119+
120+
fn reduce_to(&self) -> Self::Result {
121+
let g = self.graph();
122+
let m = g.left_size();
123+
let n = g.right_size();
124+
let big_n = m + n;
125+
126+
// Build the N x N matrix:
127+
// upper-right m x n block = biadjacency matrix B*
128+
// all other entries = 0
129+
// The matrix is upper triangular: 1-entries lie strictly in rows
130+
// 0..m and columns m..m+n.
131+
let mut matrix = vec![vec![false; big_n]; big_n];
132+
for &(left_idx, right_idx) in g.left_edges() {
133+
// Row = l_left_idx (in 0..m), Column = m + right_idx (in m..m+n).
134+
matrix[left_idx][m + right_idx] = true;
135+
}
136+
137+
let target = MinimumMatrixDomination::new(matrix);
138+
139+
ReductionMMMToMatrixDomination {
140+
target,
141+
source: self.clone(),
142+
}
143+
}
144+
}
145+
146+
#[cfg(feature = "example-db")]
147+
pub(crate) fn canonical_rule_example_specs() -> Vec<crate::example_db::specs::RuleExampleSpec> {
148+
use crate::export::SolutionPair;
149+
150+
vec![crate::example_db::specs::RuleExampleSpec {
151+
id: "minimummaximalmatching_to_minimummatrixdomination",
152+
build: || {
153+
// Canonical YES instance from the issue.
154+
//
155+
// Bipartite graph B with L = {l0, l1}, R = {r0, r1, r2} and edges
156+
// F = {(l0, r0), (l0, r1), (l0, r2), (l1, r1), (l1, r2)}.
157+
//
158+
// Source edge indices (in BipartiteGraph::edges() order):
159+
// 0: (l0, r0) = (0, 0)
160+
// 1: (l0, r1) = (0, 1)
161+
// 2: (l0, r2) = (0, 2)
162+
// 3: (l1, r1) = (1, 1)
163+
// 4: (l1, r2) = (1, 2)
164+
//
165+
// mm(B) = 2; one optimum is M = {(l0, r0), (l1, r1)} ->
166+
// source_config = [1, 0, 0, 1, 0].
167+
//
168+
// Constructed N x N matrix with N = 5; 1-entries in row-major
169+
// order (matching the source edge order above):
170+
// idx 0: (0, 2) <- (l0, r0)
171+
// idx 1: (0, 3) <- (l0, r1)
172+
// idx 2: (0, 4) <- (l0, r2)
173+
// idx 3: (1, 3) <- (l1, r1)
174+
// idx 4: (1, 4) <- (l1, r2)
175+
//
176+
// Selecting target_config = [1, 0, 0, 1, 0] picks 1-entries
177+
// {(0, 2), (1, 3)}, which together dominate every other 1-entry by
178+
// shared row 0 or row 1.
179+
let source = MinimumMaximalMatching::new(BipartiteGraph::new(
180+
2,
181+
3,
182+
vec![(0, 0), (0, 1), (0, 2), (1, 1), (1, 2)],
183+
));
184+
crate::example_db::specs::rule_example_with_witness::<_, MinimumMatrixDomination>(
185+
source,
186+
SolutionPair {
187+
source_config: vec![1, 0, 0, 1, 0],
188+
target_config: vec![1, 0, 0, 1, 0],
189+
},
190+
)
191+
},
192+
}]
193+
}
194+
195+
#[cfg(test)]
196+
#[path = "../unit_tests/rules/minimummaximalmatching_minimummatrixdomination.rs"]
197+
mod tests;

src/rules/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ pub(crate) mod minimumdiscreteplanarinversekinematics_qubo;
8989
pub(crate) mod minimumfeedbackarcset_maximumlikelihoodranking;
9090
pub(crate) mod minimumfeedbackvertexset_minimumcodegenerationunlimitedregisters;
9191
pub(crate) mod minimummaximalmatching_maximumachromaticnumber;
92+
pub(crate) mod minimummaximalmatching_minimummatrixdomination;
9293
pub(crate) mod minimummultiwaycut_qubo;
9394
pub(crate) mod minimumvertexcover_comparativecontainment;
9495
pub(crate) mod minimumvertexcover_ensemblecomputation;
@@ -508,6 +509,7 @@ pub(crate) fn canonical_rule_example_specs() -> Vec<crate::example_db::specs::Ru
508509
specs.extend(minimumvertexcover_longestcommonsubsequence::canonical_rule_example_specs());
509510
specs.extend(minimumvertexcover_maximumindependentset::canonical_rule_example_specs());
510511
specs.extend(minimummaximalmatching_maximumachromaticnumber::canonical_rule_example_specs());
512+
specs.extend(minimummaximalmatching_minimummatrixdomination::canonical_rule_example_specs());
511513
specs.extend(minimumvertexcover_minimummaximalmatching::canonical_rule_example_specs());
512514
specs.extend(minimumvertexcover_minimumfeedbackarcset::canonical_rule_example_specs());
513515
specs.extend(minimumvertexcover_minimumfeedbackvertexset::canonical_rule_example_specs());

0 commit comments

Comments
 (0)