Table of Contents
Fetching ...

Gabow's $O(\sqrt{n}m)$ Maximum Cardinality Matching Algorithm, Revisited

Kurt Mehlhorn, Romina Nobahari

Abstract

We revisit Gabow's $O(\sqrt{n} m)$ maximum cardinality matching algorithm (The Weighted Matching Approach to Maximum Cardinality Matching, Fundamenta Informaticae, 2017). It adapts the weighted matching algorithm of Gabow and Tarjan~\cite{GT91} to maximum cardinality matching. Gabow's algorithm works iteratively. In each iteration, it constructs a maximal number of edge-disjoint shortest augmenting paths with respect to the current matching and augments them. It is well-known that $O(\sqrt{n})$ iterations suffice. Each iteration consists of three parts. In the first part, the length of the shortest augmenting path is computed. In the second part, an auxiliary graph $H$ is constructed with the property that shortest augmenting paths in $G$ correspond to augmenting paths in $H$. In the third part, a maximal set of edge-disjoint augmenting paths in $H$ is determined, and the paths are lifted to and augmented to $G$. We give a new algorithm for the first part. Gabow's algorithm for the first part is derived from Edmonds' primal-dual algorithm for weighted matching. We believe that our approach is more direct and will be easier to teach. We have implemented the algorithm; the implementation is available at the companion webpage (https://people.mpi-inf.mpg.de/~mehlhorn/CompanionPageGenMatchingImplementation.html).

Gabow's $O(\sqrt{n}m)$ Maximum Cardinality Matching Algorithm, Revisited

Abstract

We revisit Gabow's maximum cardinality matching algorithm (The Weighted Matching Approach to Maximum Cardinality Matching, Fundamenta Informaticae, 2017). It adapts the weighted matching algorithm of Gabow and Tarjan~\cite{GT91} to maximum cardinality matching. Gabow's algorithm works iteratively. In each iteration, it constructs a maximal number of edge-disjoint shortest augmenting paths with respect to the current matching and augments them. It is well-known that iterations suffice. Each iteration consists of three parts. In the first part, the length of the shortest augmenting path is computed. In the second part, an auxiliary graph is constructed with the property that shortest augmenting paths in correspond to augmenting paths in . In the third part, a maximal set of edge-disjoint augmenting paths in is determined, and the paths are lifted to and augmented to . We give a new algorithm for the first part. Gabow's algorithm for the first part is derived from Edmonds' primal-dual algorithm for weighted matching. We believe that our approach is more direct and will be easier to teach. We have implemented the algorithm; the implementation is available at the companion webpage (https://people.mpi-inf.mpg.de/~mehlhorn/CompanionPageGenMatchingImplementation.html).
Paper Structure (14 sections, 14 theorems, 6 equations, 6 figures, 1 table)

This paper contains 14 sections, 14 theorems, 6 equations, 6 figures, 1 table.

Key Result

Lemma 1

Consider a blossom $B$ with base $b$ and a node $v$ of $B$. Then $b$ lies on the canonical path of $v$, and the suffix of the canonical path starting in $b$ and ending in $v$ has length $\mathit{lcp}(v) - \mathit{lcp}(b)$.

Figures (6)

  • Figure 1: The vertex $z$ becomes even by the addition of the bridge $xy$. The path from $r$ to $x$ has length $\mathit{lcp}(x)$, the path from $r$ to $y$ has length $\mathit{lcp}(y)$, the path from $r$ to $z$ has length $\mathit{lcp}_{\mathit{odd}}(z)$, the path from $y$ to $z$ has length $\mathit{lcp}(y) - \mathit{lcp}_{\mathit{odd}}(z)$; therefore, $\mathit{lcp}(z) \mathbin{\raisebox{0.05ex}{\rm :}\!\!=} \mathit{lcp}(x) + 1 + \mathit{lcp}(y) - \mathit{lcp}_{\mathit{odd}}(z)$. Moreover, the even length path from $b$ to $z$ has length $\mathit{lcp}(z) - \mathit{lcp}(b)$. Edges are drawn solid, and paths are drawn dash-dotted.
  • Figure 2: The execution of part I on the example given in Gabow:GeneralMatching: (a) Shows the input graph. (b) At the end of phase 0, $S$ consists of the two free nodes $a$ and $l$. (c) At the end of phase 2, we have grown $S$ to level 2. (d) After the growth-step in phase 4, $S$ has grown to level 4. There is an even-even edge $ce$ with $\mathit{lcp}(c) + \mathit{lcp}(e) = 2 + 4 = 2\cdot 4 - 2$. (e) After the bridge-steps in phase 4, $d$ is now even with $\mathit{lcp}(d) = 4$. (f) In phase 5, we add the bridge $ik$ with $\mathit{lcp}(i)+ \mathit{lcp}(k) = 4 + 4 = 2\cdot 5 - 2$. The vertices $h$ and $j$ become even with $\mathit{lcp}$-value equal to $6$. (g) In phase 6, we grow the tree and add node $r$ at level 5 and node $q$ at level 6. Then we process the bridge $pq$ with $\mathit{lcp}(p) + \mathit{lcp}(q) = 4 + 6 = 2\cdot6 - 2$, $r$ becomes even with $\mathit{lcp}(r) = 6$. We also add the bridge $eh$ with $\mathit{lcp}(e) + \mathit{lcp}(h) = 4 + 6 = 2\cdot 6 - 2$. Vertices $b$ and $f$ become even with $\mathit{lcp}$-value equal to $10$. (h) Finally, in phase 7, we add the bridge $fn$ with $\mathit{lcp}(f) + \mathit{lcp}(n) = 10 + 2 = 2\cdot 7 - 2$. We have found an augmenting path of length 13, and Part I ends. (j) The contracted graph: Vertices $a$ to $k$ are contracted into the red supernode, and vertices $p$ to $r$ into the green supernode. Edges $mf$ and $pf$ are discarded. (i) also shows the structure inside the supernodes. In (d) we grow out of $c$ using edge $cd$ and set $\mathit{lcp}_{\mathit{odd}}(d) = 3$ and $\mathit{lcp}(e) = 4$. When we consider $ce$, we set $\mathit{lcp}_{\mathit{odd}}(e) = 3$.
  • Figure 3: Part I of the Matching Algorithm. Augmenting paths are only found for $\Delta \le n/2$. The remaining phases are needed for the correct construction of the witness of optimality; see Section \ref{['Implementation']}.
  • Figure 4: Cascading bridges: (a) $\Delta$ is assumed to be odd. At the beginning of phase $\Delta$ , $a$, $b$, $d$, and $f$ are even, and $c$, $e$, and $g$ are odd. Nodes $a$ and $b$ are guaranteed to have their correct $\mathit{lcp}$-values by the first part of Lemma \ref{['correctness']}. We add the bridge $ab$ with $\mathit{lcp}$-sum $2\Delta - 2$; its skew is zero. As a consequence, $c$ becomes even with $\mathit{lcp}$-value $\Delta + 1$ and the edge $cd$ becomes an even-even edge with $\mathit{lcp}$-sum $2\Delta - 2$ and a skewness of 4. We add $cd$, $e$ becomes even with the $\mathit{lcp}$-value $\Delta + 3$, and $ef$ becomes an even-even edge with $\mathit{lcp}$-sum $2\Delta - 2$ and skew 8. Note that the edges $ab$, $cd$, and $ef$ have increasing skew. (b) $\Delta$ is assumed to be even. In the growth-step in phase $\Delta$ we have added node $h$ at level $\Delta - 1$ and node $i$ at level $\Delta$. The edge $ei$ is a bridge with $\mathit{lcp}$-sum $2\Delta - 2$ and skew 2. The addition of $ei$ makes $h$ even with $\mathit{lcp}(h) = \Delta$ and creates the bridges $hg$ and $hj$ with skew 2. Node $k$ becomes even with $\mathit{lcp}(k) = \Delta + 2$. Then $kl$ has two even endpoints, $\mathit{lcp}$-sum $2\Delta - 2$, and skew 6. So we add $kl$.
  • Figure 5: The graph has seven vertices, and a maximum matching is shown. A certificate of optimality gives label one to vertices $b$ and $d$, label two to vertices $e$, $f$, and $g$, and label zero to vertices $a$ and $c$. After phase $\left\lfloor 7/2 \right\rfloor$, the search structure consists of the path from $a$ to $c$, and the two matching edges $de$ and $fg$ still belong to the reservoir of unexplored edges. The labeling algorithm would give label one to $b$ and to one of the vertices in $\{\space d,e,f,g \space\}$ and would give label two to the other vertices in this set. If $d$ is labeled two, the edge $cd$ connects labels zero and two and violates the witness property. After phase seven, all vertices belong to the search structure, and the correct labeling is computed.
  • ...and 1 more figures

Theorems & Definitions (14)

  • Lemma 1
  • Lemma 2: Even-odd edges go up at most one level
  • Lemma 3: Discover bridges in order
  • Lemma 4: Bridge-steps generate growth-steps only for later phases
  • Lemma 5: Non-horizontal bridges: Skewness increases
  • Lemma 6: Growth-steps in phase $\Delta$ generate bridge-steps for phases $\ge \Delta$
  • Lemma 7: Correctness
  • Lemma 8
  • Lemma 9
  • Lemma 10
  • ...and 4 more