A perfect matching cut of a graph is a perfect matching that is also an edge cut, and a maximum matching cut is a matching cut with the most edges. We study pmc and mmc on subgraphs of the square grid, where perfect matching cuts are exactly the tilings with two-colored dominoes in which adjacent cells of different dominoes have the same color. pmc is NP-complete on induced grid graphs, even with all degrees in $\{2,3\}$ and large girth, so two-color domino tiling is NP-complete. Adapting an algorithm of Worman and Yang, we solve pmc in $O(n)$ time without holes and in $O(2^hh^2n)$ time with $h$ holes, and compress it into a 3-CNF formula with $O(h)$ variables and clauses. For mmc, we describe matching cuts by vertex-disjoint strips, whose conflict graph is an outerstring graph. This gives an $O(n^3)$-time algorithm without holes, an $O(1.7624^pn^3)$-time algorithm when the holes have total perimeter $p$, a linear-time $\frac{21}{41}$-approximation, and an $O(n^2)$-time algorithm for disconnected perfect matching. Strips extend to quadrangulated disks, such as polycube surface patches, where we characterize by curvature when both problems are solvable in $O(n^3)$ time.
All figures are interactive and computed live. The grid figures of §§2–5 share one working graph; the figures of §6 share one quadrangulated disk. Statement numbers follow the paper.
1Introduction
A matching cut of $G=(V,E)$ is an edge cut that is a matching, and a perfect matching cut is one that is a perfect matching. Deciding whether a graph has a matching cut (mc) or a perfect matching cut (pmc) is NP-complete, as is Maximum Matching Cut (mmc). With two colors and bichromatic dominoes, Biedl's colored domino tilings are exactly the perfect matching cuts of the layout's grid graph (Proposition 11).
Figure 1. Structure of the paper; an arrow means “is used in”.
2Preliminaries
2.1Cuts, colorings, and parity
For $s\colon V(G)\to\mathbb F_2$ write $\delta(s)=\{uv\in E(G): s(u)\ne s(v)\}$.
Definition 1. A perfect matching cut of $G$ is a perfect matching $M$ with $M=\delta(s)$ for some $s$, a side coloring of $M$.
Definition 2. For connected $G$, a matching cut is a nonempty matching $M=\delta(s)$; a maximum weight matching cut maximizes $w(M)$. A perfect matching is disconnected if it contains a matching cut.
Observation 3. $\delta(s)$ is a perfect matching cut if and only if every vertex $v$ has exactly one neighbor $u$ with $s(u)\ne s(v)$.
Lemma 4. Let $G$ be connected and $F\subseteq E(G)$. Then $F=\delta(s)$ for some $s$ if and only if $|F\cap E(C)|$ is even for every cycle $C$; the only such colorings are $s$ and $s\oplus1$.
2.2Plane graphs
Lemma 5 (face parity). Let $G$ be a connected plane graph and $F\subseteq E(G)$. Then $F=\delta(s)$ for some $s$ if and only if $|F\cap\partial f|$ is even for every bounded face $f$.
2.3Grid graphs
A grid subgraph is a finite subgraph of the lattice $\mathbb L$ on $\mathbb Z^2$; an induced grid graph is $\mathbb L[W]$. The unit square $Q_{x,y}$ is a square face if all four of its sides are edges.
Definition 6. A hole is a bounded face that is not a square face. $G$ is hole-free if it is connected and has no hole; equivalently, it has exactly $m-n+1$ square faces.
Lemma 7 (square rule). Let $G$ be a connected grid subgraph and $M$ a matching. If $M=\delta(s)$, then for every square face $Q$, $M\cap\partial Q$ is empty or a pair of opposite sides. Conversely, if this holds for every square face and $|M\cap\partial h|$ is even for every hole $h$, then $M=\delta(s)$ for some $s$.
Figure 2. The square rule (Lemma 7).Figure 3. Observation 3 and Lemmas 4, 5, 7 on the working graph. Odd faces are shaded; the search of Lemma 4 can be animated.
3Hardness and two-color domino tiling
3.1Subdivisions
Lemma 8. Let $H$ be obtained from $G$ by replacing every edge $uv$ by a path of length $\ell_{uv}\equiv1\pmod 4$ with internal vertices of degree 2. Side colorings of perfect matching cuts of $H$ restrict to those of $G$, and those of $G$ extend uniquely to $H$.
Figure 4. The two candidate colorings of a subdivided edge; $q_i=s(v_{i-1})\oplus s(v_i)$.
3.2Realization in the grid
Lemma 9 (grid realization). For a bipartite graph $G$ of maximum degree $\le4$ given by an orthogonal drawing, and $\ell_0\in\mathbb N$, one can compute in polynomial time $W\subseteq\mathbb Z^2$ such that (i) $\mathbb L[W]$ is obtained from $G$ as in Lemma 8 with all $\ell_{uv}\ge\ell_0$, and (ii) any two points of $W$ differing by $(\pm1,\pm1)$ have a common neighbor in $W$.
Theorem 10.pmc is NP-complete on induced grid graphs, even for 2-connected ones with all degrees in $\{2,3\}$ and girth at least $g$, for every fixed $g$.
Figure 5. Lemma 9 applied to the cube $Q_3$ ($R=5$).
3.3Two-color domino tiling
Proposition 11. With colors $\{0,1\}$ and $n/2$ copies of the domino $\{0,1\}$, a pair $(M,c)$ is a tiling of the layout $L$ if and only if $M$ is a perfect matching cut of $G_L$ with side coloring $c$.
Corollary 12. Two-color domino tiling is NP-complete.
Figure 6. A perfect matching cut as a tiling with dominoes $\{0,1\}$.
4Perfect matching cuts
4.1Leaves and corners
Let $R$ be obtained from $G$ by deleting vertices. A vertex $v$ is forced if $d_R(v)\le1$, or $d_R(v)=2$ and $v$ is a corner of a square face $Q_v$ of $R$. Its forced set $X_v$, a leaf $\{u,v\}$ or the corner $V(Q_v)$, is matched to itself by every perfect matching cut that matches $V(R)$ internally.
4.2The algorithm
Theorem 13. Let $G$ be a connected grid subgraph with $h$ holes. Algorithm 1 computes a perfect matching cut of $G$ and a side coloring, or decides that none exists, in $O(n)$ time if $h=0$ and in $O(2^hh^2n)$ time if $h\ge1$.
Algorithm 1. The leaf–corner decomposition, with branching when stuck and a linear system over $\mathbb F_2$ at each terminal node.
4.3A compact SAT encoding
Theorem 14. For a connected grid subgraph $G$ with $h\ge1$ holes, one can compute in polynomial time a 3-CNF formula $\varphi$ with $O(h)$ variables and clauses that is satisfiable if and only if $G$ has a perfect matching cut.
Corollary 15. A $T(N)N^{O(1)}$-time algorithm for 3-SAT with $O(N)$ clauses gives a $T(O(h))\,n^{O(1)}$-time algorithm for pmc.
Figure 7. The formula $\varphi$ of Theorem 14: stuck graph with exceptional vertices (labelled by type) and pieces, the clauses, and a CDCL solution decoded to a perfect matching cut.
5Strips and maximum matching cuts
Corollary 16. Maximum matching cut is NP-hard on induced grid graphs.
5.1Strips
Definition 17. The strips of $G$ are the classes of the equivalence relation on $E(G)$ generated by $h_{x,y}\sim h_{x,y+1}$ and $v_{x,y}\sim v_{x+1,y}$ for every square face $Q_{x,y}$. The conflict graph $K$ joins two strips that share a vertex.
Lemma 18. $M$ is a matching with $M=\delta(s)$ if and only if (i) $M=\bigcup I$ for an independent set $I$ of $K$, and (ii) $|M\cap\partial h|$ is even for every hole $h$.
Figure 8. Strips and the conflict graph $K$ with weights $|S|$.
5.2An outerstring representation of the conflict graph
Fact 20 (Keil, Mitchell, Pradhan, Vatshelle). A maximum-weight independent set of a graph given by an outerstring representation of size $N$ can be computed in $O(N^3)$ time.
Lemma 21. $K[\mathcal S^\circ]$ has an outerstring representation of size $O(n)$, computable in $O(n)$ time.
Figure 9. Zigzag curves $\gamma_S$, tails, and the collar $D$.
5.3Hole-free grid subgraphs
Theorem 22. On hole-free grid subgraphs, a maximum weight matching cut and a side coloring can be computed in $O(n^3)$ time.
5.4Grid subgraphs with holes
Lemma 25. A graph on $t$ vertices with all degrees in $\{1,2,3,4\}$ has at most $17^{t/5}<1.7624^t$ independent sets.
Theorem 26. A maximum weight matching cut can be computed in $O(17^{t/5}n^3)$ time, where $t=|\mathcal S\setminus\mathcal S^\circ|\le p(G)$.
Figure 10. Strips classified by end faces; the guessing algorithm of Theorem 26.
5.5Approximation
Theorem 29. On connected grid subgraphs, a matching cut with at least $\frac{21}{41}\,\mathrm{opt}$ edges can be computed in $O(n)$ time.
Figure 11. Stripe cuts (Lemma 27), 2-core and tree dynamic program (Lemma 28), and the two ratio bounds.
5.6Disconnected perfect matchings
Theorem 30.Disconnected Perfect Matching is solvable in $O(n^2)$ time on hole-free grid subgraphs.
Figure 12. For each strip $S$, a perfect matching of $G-V(S)$.
6Quadrangulated disks
Definition 31. A quadrangulated disk is a connected plane graph in which every bounded face is bounded by a 4-cycle, a quad. Then $\sum_v(4-2d(v)+q(v))=4$. (1)
6.1Strips of a quadrangulated disk
Definition 32. The strips are the classes of the relation generated by being opposite sides of a quad.
Lemma 33. Every strip is a ladder $e_0,Q_1,e_1,\dots,Q_k,e_k$ that is either open (both ends on the outer face) or closed ($e_k=e_0$).
Lemma 35. $M$ is a matching cut if and only if it is a nonempty union of matching strips with pairwise disjoint vertex sets.
Corollary 36.Disconnected Perfect Matching is solvable in $O(n^2)$ time on quadrangulated disks.
Figure 13. Strips and ladders. The disk is editable: Extend glues a square to a boundary edge, Quad adds a 4-cycle, Move and Delete act on vertices and squares.
6.2Outer strings for open strips
Lemma 40. For distinct open matching strips $Z,Z'$: $\gamma'_Z\cap\gamma'_{Z'}\ne\emptyset$ if and only if $V(Z)\cap V(Z')\ne\emptyset$.
Theorem 42. If every matching strip of a quadrangulated disk is open, maximum weight matching cut and pmc are solvable in $O(n^3)$ time.
Figure 14. Interior diagonals (×), zigzag curves $\gamma'_Z=u_0w_0\,c_{Q_1}\,w_1u_1\,c_{Q_2}\cdots$, and the collar.
6.3Curvature decides whether strips close
For an interior vertex, $\kappa(v)=4-d(v)$; $\kappa^+(G)=\sum_v\max(\kappa(v),0)$.
Lemma 43. A closed matching strip bounds a disk $R$ of interior vertices with $\sum_{v\in R}\kappa(v)=4$.
Corollary 44. If $G$ is a squaregraph or $\kappa^+(G)<4$, every matching strip is open.
Proposition 45. Every strip of a stepped patch is an open matching strip.
Figure 15. Curvature, closed strips with their enclosed disks, and stepped surfaces.
6.4Closed strips
Theorem 46. With $t$ closed matching strips, maximum weight matching cut and pmc are solvable in $O(2^tn^3)$ time.
Figure 16. All guesses $J$ of closed matching strips, each completed by open strips.
7Open problems
The complexity of tiling with bichromatic dominoes over three colors.
The complexity of Disconnected Perfect Matching on grid subgraphs with holes.
An $o(n^3)$-time algorithm without holes, or an FPT algorithm in the number of holes, for maximum matching cut.
A PTAS for maximum matching cut on grid subgraphs.
Fixed-parameter tractability in $\kappa^+(G)$ on quadrangulated disks.
AQuadrangulated images
Quadrilateral meshes are standard in computer graphics, and the strips of §6 are their dual chords (also called polychords or edge rings). A matching cut is a union of vertex-disjoint matching chords; it splits the mesh into two sides, and every vertex has at most one neighbor across the cut. The figure meshes the foreground of an image and computes a maximum matching cut by Lemma 35, as an exact maximum independent set of the conflict graph of matching strips.
The pipeline: threshold (Otsu, or the alpha channel) and keep the largest region with holes filled; extract a smooth boundary by marching squares; place hexagonal-lattice points inside; triangulate with Delaunator; pair adjacent triangles into well-shaped quads and split every polygon into quads through its centroid and edge midpoints, as in Blossom-Quad (Remacle et al., 2012); then smooth interior vertices. The result is an all-quad mesh of a disk.
Figure 17. A quadrangulated image and a maximum matching cut. Sides are tinted; the cut edges are black and their dual chords gold. The stages show the mask, the Delaunay triangulation and the triangle pairing.
Notes
In Edit mode, click a lattice point to add or remove a vertex, click between two vertices to toggle an edge, and drag to paint. Ctrl/⌘ Z undoes. Copy link stores the graph in the URL.
Maximum-weight independent sets are computed by exact branch and bound rather than by the algorithm of Fact 20. Satisfiability is decided by a small CDCL solver. Formulas are typeset with KaTeX.