Algorithm Search⌘K

Proofs: Micali-Vazirani algorithm

These are the human proofs of Micali-Vazirani algorithm, at full length.

The Micali-Vazirani algorithm returns a maximum matching full

This proof shows: correctness, termination.

Let G=(V,E)G = (V, E) be a finite general graph with nn vertices, and let MM be the matching at the start of a phase. Write lml_m for the length of a shortest MM-augmenting path (∞\infty if there is none). The proof has a part that is proved here and one lemma about the search that is cited.

Lemma 1 (the search, cited). In a phase:

(a) for every vertex vv of tenacity at most lml_m, MIN and MAX assign the correct minlevel and maxlevel of vv, and every bridge of tenacity 2i+1≤lm2i + 1 \le l_m is in the list of level ii by the end of MIN at level ii;

(b) for a bridge (u,v)(u, v) processed in line L5, DDFS either returns the highest bottleneck below bud∗(u)\text{bud}^*(u) and bud∗(v)\text{bud}^*(v), or two distinct free vertices with vertex-disjoint paths to them in the graph of predecessors and buds;

(c) a vertex erased in line L8 lies on no shortest augmenting path that is vertex-disjoint from the paths found so far in the phase, and opening petals in line L7 gives an augmenting path of length lml_m that uses no erased vertex.

This is Theorem 34, Lemma 33, Theorem 28 and Section 7.3 of Vazirani, A simplification of the MV matching algorithm and its proof (arXiv:1210.4594, 2013). The rest of this page shows how the result of the algorithm follows from it.

Lemma 2 (one phase). If lm<∞l_m < \infty, the phase augments MM along a nonempty set of vertex-disjoint augmenting paths of length lml_m, and no augmenting path of length lml_m is disjoint from all of them. If lm=∞l_m = \infty, the phase augments nothing.

Proof. Each augmentation in line L8 uses a path PP built in line L7. Before it changes MM, the implementation checks that PP is simple, that its ends are free, and that its edges alternate between edges outside and inside the current matching, starting and ending outside. So PP is an augmenting path of the current matching, and flipping its edges gives a matching with one more edge. Line L8 then erases all vertices of PP. Lines L5 and L7 never use erased vertices, so the paths of one phase are vertex-disjoint. A vertex on none of them keeps its mate, so each path is also an augmenting path of MM, with the same edges outside and inside the matching.

If lm=∞l_m = \infty, there is no augmenting path, and by the check above no path is ever flipped. Let lm=2j+1l_m = 2j + 1. The levels and bridges up to tenacity lml_m are correct by Lemma 1(a). At each level i<ji < j, every DDFS ends at a bottleneck or with an empty support, because two free vertices with disjoint paths from the ends of a bridge of tenacity 2i+12i + 1 would give an augmenting path of length 2i+1<lm2i + 1 < l_m, by Lemma 1(c). At level jj, some bridge of tenacity lml_m lies on a shortest augmenting path, so the first DDFS on such a bridge whose ends are not erased returns two free vertices by Lemma 1(b), and a path is found. Line L9 then ends the phase after level jj, so all paths found have length lml_m. Finally, suppose an augmenting path QQ of length lml_m is disjoint from all paths found. By Lemma 1(c), none of its vertices is erased. It contains a bridge of tenacity lml_m, which is processed at level jj, and Lemma 1(b) and (c) then give another path disjoint from those found, which the algorithm would have flipped. This contradicts the choice of QQ. □\square

Lemma 3 (shortest lengths grow). Let a phase start with MM and lm=ℓ<∞l_m = \ell < \infty, find the paths P1,…,PkP_1, \ldots, P_k, and end with M′=M△P1△⋯△PkM' = M \triangle P_1 \triangle \cdots \triangle P_k. Then every M′M'-augmenting path has more than ℓ\ell edges.

Proof. Let PP be an M′M'-augmenting path. If PP shares no vertex with the PiP_i, it is MM-augmenting, so it has at least ℓ\ell edges, and by Lemma 2 it does not have exactly ℓ\ell. Otherwise PP meets some PiP_i at a vertex vv. Every vertex of PiP_i is matched in M′M' by an edge of PiP_i, so vv is not an end of PP, and PP contains that edge. Now N=M′△PN = M' \triangle P is a matching with ∣M∣+k+1|M| + k + 1 edges, and M△N=(P1∪⋯∪Pk)△PM \triangle N = (P_1 \cup \cdots \cup P_k) \triangle P. The symmetric difference of two matchings is a union of vertex-disjoint paths and cycles, and since NN has k+1k + 1 more edges than MM, it contains at least k+1k + 1 vertex-disjoint MM-augmenting paths, each with at least ℓ\ell edges. So ∣(P1∪⋯∪Pk)△P∣≥(k+1)ℓ|(P_1 \cup \cdots \cup P_k) \triangle P| \ge (k + 1)\ell. The left side equals kℓ+∣P∣−2∣P∩(P1∪⋯∪Pk)∣≤kℓ+∣P∣−2k\ell + |P| - 2|P \cap (P_1 \cup \cdots \cup P_k)| \le k\ell + |P| - 2, so ∣P∣≥ℓ+2|P| \ge \ell + 2. Nothing here uses bipartiteness. □\square

Termination. Each phase that finds a path increases ∣M∣|M|, and ∣M∣≤n/2|M| \le n/2. A phase that finds no path makes line L10 return. So there are at most n/2+1n/2 + 1 phases. Within a phase, the loop of line L3 runs at most 2n+22n + 2 times, and each DDFS and each petal opening only moves to unvisited vertices or down to lower levels, so each step stops.

Theorem. The algorithm returns a maximum matching of GG.

Proof. By Lemma 2, each phase keeps MM a matching. The algorithm stops after a phase that finds no augmenting path. By Lemma 2 this happens only when lm=∞l_m = \infty, that is, when MM has no augmenting path. By Berge's lemma, MM is then a maximum matching. By Lemma 3 and the argument of Hopcroft and Karp, the number of phases is also O(n)O(\sqrt n). ■\blacksquare

Back to Micali-Vazirani algorithm