Algorithm Search⌘K

Proofs: Dulmage-Mendelsohn decomposition

These are the human proofs of Dulmage-Mendelsohn decomposition, at full length.

The Dulmage-Mendelsohn decomposition runs in O((n + m) n^(1/2)) time full

This proof shows: time.worst.

Let G=(X∪Y,E)G = (X \cup Y, E) have nn vertices and mm edges, stored as adjacency lists on both sides. Each operation on an index, a mark or a queue costs O(1)O(1) on the word RAM.

Line L1. Hopcroft-Karp finds a maximum matching in O((n+m)n)O((n + m)\sqrt n) time and Θ(n+m)\Theta(n + m) space.

Lines L2 to L6. In the search from the free left vertices, a left vertex is enqueued only when it is marked, and it is marked at most once, so at most ∣X∣|X| vertices are dequeued. A dequeued vertex scans its adjacency list once, at O(1)O(1) per edge, including the lookup of mate[y]\text{mate}[y] in line L5. So the search costs O(n+m)O(n + m), and so does the mirror search of line L6.

Lines L7 and L8. V0V_0 is found by one pass over the marks, O(n)O(n). HH has at most ∣X∣|X| nodes and at most one arc per edge, built by one pass over the adjacency lists of X0X_0: O(n+m)O(n + m).

Lines L9 to L11. Tarjan's algorithm runs in time linear in the size of HH, O(n+m)O(n + m), and reversing its output costs O(n)O(n). Line L10 looks up one mate per left vertex, and writing the parts costs O(n)O(n).

Total. O((n+m)n)+O(n+m)=O((n+m)n)O((n + m)\sqrt n) + O(n + m) = O((n + m)\sqrt n) time. The space is the graph, the mate arrays, the marks, the queues, HH and Tarjan's stack, all O(n+m)O(n + m), and the graph itself needs Ω(n+m)\Omega(n + m), so it is Θ(n+m)\Theta(n + m). ■\blacksquare

The Dulmage-Mendelsohn algorithm returns the canonical decomposition full

This proof shows: correctness, termination.

Let G=(X∪Y,E)G = (X \cup Y, E) be a finite bipartite graph, every edge joining XX to YY, and let MM be the maximum matching of line L1. Write XX=X∩VXX_X = X \cap V_X, YX=Y∩VXY_X = Y \cap V_X, XY=X∩VYX_Y = X \cap V_Y, YY=Y∩VYY_Y = Y \cap V_Y, X0=X∩V0X_0 = X \cap V_0 and Y0=Y∩V0Y_0 = Y \cap V_0. An edge is allowed if some maximum matching contains it.

Termination. Each search of lines L2 to L6 enqueues a vertex only when it marks it, and marks each vertex at most once, so it ends after at most nn dequeues. Tarjan's algorithm on the finite digraph HH ends. So the algorithm ends.

Claim 1 (what the search marks). A vertex is in VXV_X if and only if it is reachable from a free vertex of XX by an MM-alternating path, that is, a path x0 y1 x1 y2…x_0\, y_1\, x_1\, y_2 \ldots with x0x_0 free, xi−1yi∉Mx_{i-1} y_i \notin M and yixi∈My_i x_i \in M. Every vertex of YXY_X is matched, and its mate is in XXX_X. Every neighbour of a vertex of XXX_X is in YXY_X.

Proof. Lines L3 to L5 follow exactly these steps: any edge from a left vertex (an edge of MM at xix_i leads back to yiy_i, already marked), and the matching edge from a right vertex. If a marked yy were free, the path to it would be augmenting, against the maximality of MM and Berge's lemma; so yy is matched and line L5 marks its mate. Line L4 marks every neighbour of a dequeued left vertex, and every marked left vertex is dequeued. □\square

The mirror statement holds for VYV_Y, with the roles of XX and YY swapped.

Claim 2 (VXV_X and VYV_Y are canonical). XXX_X is the set of left vertices missed by some maximum matching, and YX=N(XX)Y_X = N(X_X). Symmetrically YYY_Y is the set of right vertices missed by some maximum matching and XY=N(YY)X_Y = N(Y_Y). Moreover VX∩VY=∅V_X \cap V_Y = \emptyset.

Proof. If x∈XXx \in X_X, the alternating path PP from a free x0x_0 to xx has even length and ends with an edge of MM at xx, or is empty; M△E(P)M \triangle E(P) is a maximum matching that misses xx. Conversely let a maximum matching NN miss xx. If xx is free in MM it is a root. Otherwise the component of M△NM \triangle N that contains xx is a path starting at xx with an edge of MM. It alternates, and as ∣M∣=∣N∣|M| = |N| it has even length, so it ends at a left vertex zz with an edge of NN, and zz is free in MM. Read from zz, it is an MM-alternating path from a free left vertex to xx, so x∈XXx \in X_X. By Claim 1, YX⊆N(XX)Y_X \subseteq N(X_X) (each y∈YXy \in Y_X was marked from a left neighbour in XXX_X) and N(XX)⊆YXN(X_X) \subseteq Y_X. The mirror argument handles VYV_Y.

Suppose v∈VX∩VYv \in V_X \cap V_Y. Let PP be an alternating path from a free left x0x_0 to vv and QQ one from a free right y0y_0 to vv, and let ww be the first vertex of PP on QQ. On PP, left vertices are entered by edges of MM and right vertices by edges outside MM; on QQ it is the reverse. So PP from x0x_0 to ww followed by QQ backwards from ww to y0y_0 alternates at ww; its two parts share only ww; and if w=x0w = x_0 or w=y0w = y_0 one part is empty. It is an MM-augmenting path, which is impossible. □\square

Claim 3 (two minimum covers). K1=(X∖XX)∪YXK_1 = (X \setminus X_X) \cup Y_X and K2=(Y∖YY)∪XYK_2 = (Y \setminus Y_Y) \cup X_Y are minimum vertex covers. Hence no edge with both ends in K1K_1, or both ends in K2K_2, is allowed.

Proof. Every edge at XXX_X ends in YXY_X by Claim 1, and every other edge has its left end in X∖XXX \setminus X_X, so K1K_1 is a cover. By Claim 1, MM matches YXY_X into XXX_X, and each vertex of XXX_X is free or the mate of a vertex of YXY_X, so ∣YX∣=∣XX∣−f|Y_X| = |X_X| - f with f=∣X∣−∣M∣f = |X| - |M| the number of free left vertices. Then ∣K1∣=∣X∣−∣XX∣+∣YX∣=∣X∣−f=∣M∣|K_1| = |X| - |X_X| + |Y_X| = |X| - f = |M|, and a cover has at least ν(G)\nu(G) vertices, so K1K_1 is minimum. A maximum matching NN has ∣N∣=∣K1∣|N| = |K_1| edges, each with at least one end in K1K_1, and distinct edges of NN have distinct ends; so every edge of NN has exactly one end in K1K_1. The same holds for K2K_2. □\square

Claim 3 rules out the edges from X0X_0 to YXY_X (both ends in K1K_1), from XYX_Y to Y0Y_0 (both in K2K_2) and from XYX_Y to YXY_X (both in K1K_1). By Claim 1 and its mirror, no edge joins XXX_X to Y∖YXY \setminus Y_X or X∖XYX \setminus X_Y to YYY_Y. So every edge lies inside VXV_X, inside VYV_Y, inside V0V_0, or is one of the three kinds just excluded.

Claim 4 (edges inside the surplus parts are allowed). Every edge xyxy with x∈XXx \in X_X and y∈YXy \in Y_X is allowed; symmetrically for VYV_Y.

Proof. If xy∈Mxy \in M we are done. Otherwise let PP be an alternating path from a free x0x_0 to xx, of even length. If yy is not on PP, let x′=mate[y]x' = \text{mate}[y]; then M′=(M△E(P))∖{yx′}∪{xy}M' = (M \triangle E(P)) \setminus \{yx'\} \cup \{xy\} is a matching (it misses xx before the edge xyxy is added, and yx′∉Py x' \notin P since y∉Py \notin P), of size ∣M∣|M|, containing xyxy. If yy is on PP, it is entered by an edge outside MM and left by its matching edge, so the part of PP from yy to xx together with the edge xyxy is an even alternating cycle, and flipping it gives a maximum matching that contains xyxy. □\square

Claim 5 (blocks). An edge xy∉Mxy \notin M with x∈X0x \in X_0 and y∈Y0y \in Y_0 is allowed if and only if xx and mate[y]\text{mate}[y] are in the same strongly connected component of HH.

Proof. Every vertex of V0V_0 is matched, since free vertices are in VXV_X or VYV_Y; so mate[y]∈X0\text{mate}[y] \in X_0 by Claim 1 and its mirror, and yy is not in VXV_X or VYV_Y. If xx and x′=mate[y]x' = \text{mate}[y] are in one component, HH has a directed path from x′x' back to xx, and with the arc x→x′x \to x' a directed cycle x=x1→x2→⋯→xk→x1x = x_1 \to x_2 \to \cdots \to x_k \to x_1 with distinct nodes. Each arc xi→xi+1x_i \to x_{i+1} is an edge from xix_i to mate[xi+1]\text{mate}[x_{i+1}], so x1 mate[x2] x2 mate[x3]⋯xk mate[x1] x1x_1\, \text{mate}[x_2]\, x_2\, \text{mate}[x_3] \cdots x_k\, \text{mate}[x_1]\, x_1 is an even alternating cycle of GG through xyxy, and flipping it gives a maximum matching that contains xyxy.

Conversely let NN be a maximum matching with xy∈Nxy \in N. The component of M△NM \triangle N through xyxy is an alternating path or cycle. A path would have an end missed by MM or by NN, a vertex missed by some maximum matching, which by Claim 2 lies in VXV_X or VYV_Y, and the whole path would be alternating from it, for MM or for NN; by Claim 1 applied to that matching and Claim 2, all its vertices would lie in VXV_X or in VYV_Y, but x∈V0x \in V_0. So it is a cycle CC. If CC met VXV_X, take a vertex u∈XXu \in X_X on CC (a vertex of YXY_X on CC has its MM-mate in XXX_X on CC). Going round CC from uu along its edge of NN, every right vertex reached is a neighbour of a vertex of XXX_X, so in YXY_X, and its MM-mate is in XXX_X; so all of CC lies in VXV_X, against x∈V0x \in V_0. The same holds for VYV_Y. So C⊆V0C \subseteq V_0, and its NN-edges xi mate[xi+1]x_i\, \text{mate}[x_{i+1}] are arcs xi→xi+1x_i \to x_{i+1} of HH forming a directed cycle through x→mate[y]x \to \text{mate}[y]. □\square

Conclusion. By Claim 5, the edges of MM and the allowed edges inside V0V_0 join only vertices of one set Bi=Ci∪mate[Ci]B_i = C_i \cup \text{mate}[C_i], and each BiB_i is connected by them, since each arc inside CiC_i is an allowed edge and CiC_i is strongly connected. So the blocks are the connected components of the allowed edges inside V0V_0. Together with Claims 2 to 4, the allowed edges are exactly those inside VXV_X, inside VYV_Y and inside one block, and the parts and the blocks depend only on GG. Each block has ∣Ci∣|C_i| left and ∣Ci∣|C_i| right vertices. An edge xyxy of V0V_0 between blocks gives the arc x→mate[y]x \to \text{mate}[y] between components; in the topological order of line L9 the component of xx comes first, so the edge goes from the left side of BiB_i to the right side of BjB_j with i<ji < j. Line L9 returns that order, because Tarjan's algorithm emits the components in reverse topological order and the algorithm reverses it. Finally MM is maximum by line L1. ■\blacksquare

Back to Dulmage-Mendelsohn decomposition