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 have vertices and edges, stored as adjacency lists on both sides. Each operation on an index, a mark or a queue costs on the word RAM.
Line L1. Hopcroft-Karp finds a maximum matching in time and 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 vertices are dequeued. A dequeued vertex scans its adjacency list once, at per edge, including the lookup of in line L5. So the search costs , and so does the mirror search of line L6.
Lines L7 and L8. is found by one pass over the marks, . has at most nodes and at most one arc per edge, built by one pass over the adjacency lists of : .
Lines L9 to L11. Tarjan's algorithm runs in time linear in the size of , , and reversing its output costs . Line L10 looks up one mate per left vertex, and writing the parts costs .
Total. time. The space is the graph, the mate arrays, the marks, the queues, and Tarjan's stack, all , and the graph itself needs , so it is .
The Dulmage-Mendelsohn algorithm returns the canonical decomposition full
This proof shows: correctness, termination.
Let be a finite bipartite graph, every edge joining to , and let be the maximum matching of line L1. Write , , , , and . 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 dequeues. Tarjan's algorithm on the finite digraph ends. So the algorithm ends.
Claim 1 (what the search marks). A vertex is in if and only if it is reachable from a free vertex of by an -alternating path, that is, a path with free, and . Every vertex of is matched, and its mate is in . Every neighbour of a vertex of is in .
Proof. Lines L3 to L5 follow exactly these steps: any edge from a left vertex (an edge of at leads back to , already marked), and the matching edge from a right vertex. If a marked were free, the path to it would be augmenting, against the maximality of and Berge's lemma; so 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.
The mirror statement holds for , with the roles of and swapped.
Claim 2 ( and are canonical). is the set of left vertices missed by some maximum matching, and . Symmetrically is the set of right vertices missed by some maximum matching and . Moreover .
Proof. If , the alternating path from a free to has even length and ends with an edge of at , or is empty; is a maximum matching that misses . Conversely let a maximum matching miss . If is free in it is a root. Otherwise the component of that contains is a path starting at with an edge of . It alternates, and as it has even length, so it ends at a left vertex with an edge of , and is free in . Read from , it is an -alternating path from a free left vertex to , so . By Claim 1, (each was marked from a left neighbour in ) and . The mirror argument handles .
Suppose . Let be an alternating path from a free left to and one from a free right to , and let be the first vertex of on . On , left vertices are entered by edges of and right vertices by edges outside ; on it is the reverse. So from to followed by backwards from to alternates at ; its two parts share only ; and if or one part is empty. It is an -augmenting path, which is impossible.
Claim 3 (two minimum covers). and are minimum vertex covers. Hence no edge with both ends in , or both ends in , is allowed.
Proof. Every edge at ends in by Claim 1, and every other edge has its left end in , so is a cover. By Claim 1, matches into , and each vertex of is free or the mate of a vertex of , so with the number of free left vertices. Then , and a cover has at least vertices, so is minimum. A maximum matching has edges, each with at least one end in , and distinct edges of have distinct ends; so every edge of has exactly one end in . The same holds for .
Claim 3 rules out the edges from to (both ends in ), from to (both in ) and from to (both in ). By Claim 1 and its mirror, no edge joins to or to . So every edge lies inside , inside , inside , or is one of the three kinds just excluded.
Claim 4 (edges inside the surplus parts are allowed). Every edge with and is allowed; symmetrically for .
Proof. If we are done. Otherwise let be an alternating path from a free to , of even length. If is not on , let ; then is a matching (it misses before the edge is added, and since ), of size , containing . If is on , it is entered by an edge outside and left by its matching edge, so the part of from to together with the edge is an even alternating cycle, and flipping it gives a maximum matching that contains .
Claim 5 (blocks). An edge with and is allowed if and only if and are in the same strongly connected component of .
Proof. Every vertex of is matched, since free vertices are in or ; so by Claim 1 and its mirror, and is not in or . If and are in one component, has a directed path from back to , and with the arc a directed cycle with distinct nodes. Each arc is an edge from to , so is an even alternating cycle of through , and flipping it gives a maximum matching that contains .
Conversely let be a maximum matching with . The component of through is an alternating path or cycle. A path would have an end missed by or by , a vertex missed by some maximum matching, which by Claim 2 lies in or , and the whole path would be alternating from it, for or for ; by Claim 1 applied to that matching and Claim 2, all its vertices would lie in or in , but . So it is a cycle . If met , take a vertex on (a vertex of on has its -mate in on ). Going round from along its edge of , every right vertex reached is a neighbour of a vertex of , so in , and its -mate is in ; so all of lies in , against . The same holds for . So , and its -edges are arcs of forming a directed cycle through .
Conclusion. By Claim 5, the edges of and the allowed edges inside join only vertices of one set , and each is connected by them, since each arc inside is an allowed edge and is strongly connected. So the blocks are the connected components of the allowed edges inside . Together with Claims 2 to 4, the allowed edges are exactly those inside , inside and inside one block, and the parts and the blocks depend only on . Each block has left and right vertices. An edge of between blocks gives the arc between components; in the topological order of line L9 the component of comes first, so the edge goes from the left side of to the right side of with . Line L9 returns that order, because Tarjan's algorithm emits the components in reverse topological order and the algorithm reverses it. Finally is maximum by line L1.