A Systematic Approach to Algorithms

Vijay K. Garg · The University of Texas at Austin

Chapter 12. Bipartite Matching

Classical bipartite matching, vertex-cover, and chain-cover constructions.

This page: Classical forms. View LLP forms »

This page collects the classical implementations of the algorithms developed in this chapter. The lattice-linear (LLP) reformulations and chapter setup live on the LLP companion page.

BipartiteMatching

Matches the book's Algorithm BipartiteMatching: for each left vertex $j$ in turn, alternatingPath(j, ...) looks for an alternating path from $j$ to some free right vertex $k$ ($S[k]$ unmatched) via a DFS over the right side, folding the book's "assign $S[]$ along the path" step into the recursion.

Time complexity: $O(n \cdot m)$ via the augmenting-path scheme, where $n$ is the number of left vertices and $m$ the number of edges.

VertexCoverFromMatching

König's-theorem construction in code, via alternating reachability: $Z$ is the set of vertices reachable from an unmatched $L$-vertex by an alternating path (a non-matching edge, then a matching edge, and so on), found by a BFS that alternates which kind of edge it follows depending on which side of the graph it is currently exploring. The cover is $C := (L \setminus Z) \cup (R \cap Z)$.

Time complexity: $O(n + m)$.