Perfect Matchings in O(n \log n) Time in Regular Bipartite Graphs

Ashish Goel, Michael Kapralov, Sanjeev Khanna

Abstract

Finding a perfect matching in a $d$-regular bipartite graph is a fundamental problem in combinatorial optimization. While classical algorithms like the Hopcroft-Karp method require $O(m\sqrt{n})$ time, and more recent developments achieved $O(m)$ time, these remain tied to the number of edges $m$. This paper introduces a randomized algorithm that finds a perfect matching in $O(n \log n)$ expected time. By employing adaptive uniform sampling through random walks, the algorithm effectively bypasses the need to examine every edge in the graph. Furthermore, the authors establish that any deterministic algorithm must take $\Omega(nd)$ time, highlighting that randomization is essential for achieving sub-linear performance relative to the edge count in dense graphs.

Introduction

In graph theory, a $d$-regular bipartite graph is one where every vertex has exactly $d$ neighbors, and the vertices are divided into two disjoint sets such that no two vertices within the same set are connected. A "perfect matching" is a subset of edges that covers every vertex exactly once. It is a well-established result that every $d$-regular bipartite graph contains at least one perfect matching.

The computational challenge lies in the efficiency of finding such a matching. For decades, the standard was the Hopcroft-Karp algorithm, which runs in $O(m\sqrt{n})$ time, where $m$ is the number of edges and $n$ is the number of vertices. While subsequent research reduced this to $O(m)$, this still requires time proportional to the number of edges. In dense graphs, where $d$ can be as large as $n$, the number of edges $m = nd$ reaches $O(n^2)$. The algorithm presented in this paper breaks this barrier, achieving a complexity of $O(n \log n)$, which is nearly linear in the number of vertices and potentially much smaller than the total number of edges.

The Search for Sub-linear Complexity

The central question addressed by the authors is whether a perfect matching can be found without inspecting every edge. This is a "sub-linear" time problem relative to $m$. Previous attempts to solve this using non-adaptive sampling—where edges are sampled randomly at the beginning—failed to provide a general solution because they hit a mathematical limit in how much information could be gathered.

The authors demonstrate that the limitation of deterministic algorithms is inherent. They prove a lower bound of $\Omega(nd)$, meaning any algorithm that does not use randomness must, in the worst case, look at a constant fraction of all edges. This establishes randomization not just as a convenience, but as a mathematical necessity for surpassing the $O(m)$ threshold.

The Randomized Algorithm: Adaptive Uniform Sampling

The core of the proposed solution is a randomized algorithm based on adaptive uniform sampling. Unlike non-adaptive methods, this algorithm makes sampling decisions dynamically as it explores the graph.

1. The Matching Graph and Augmenting Paths

The algorithm maintains a current matching (initially empty) and iteratively seeks to increase its size. It constructs a directed "matching graph" where edges currently in the matching are directed from one side of the bipartition to the other, and edges not in the matching are directed in the opposite direction. A path from an unmatched vertex on one side to an unmatched vertex on the other side is an "augmenting path." Finding and "flipping" such a path increases the size of the matching by one.

2. Random Walks

To find these augmenting paths efficiently, the algorithm performs a random walk starting from an unmatched source node. Because the graph is $d$-regular, the authors prove that a random walk is highly likely to encounter an unmatched sink node within a reasonable number of steps. The walk naturally "senses" the structure of the matching as it progresses.

3. Truncation and Restarts

To maintain the $O(n \log n)$ complexity, the algorithm must avoid getting stuck in long, unproductive cycles or paths. The authors implement a "truncation" strategy: if a random walk exceeds a specific length without finding a sink, it is terminated, and a new walk begins. This ensures that the expected work remains bounded even if individual walks fail.

4. Data Structure Requirements

The efficiency of the algorithm relies on the ability to sample a random neighbor of any vertex in $O(1)$ time. This requires the graph to be stored in an adjacency array. If the graph were stored in a less accessible format, such as a linked list, the sampling step would become a bottleneck, potentially degrading the overall performance.

Theoretical Foundations: The Stationary Distribution Trick

A key theoretical contribution of the paper is the method used to bound the search time. To analyze the expected length of the random walk, the authors employ a clever conceptual trick: they imagine merging all source nodes and all sink nodes into a single "super-node." This transformation creates a balanced directed graph. By analyzing the stationary distribution of a Markov chain on this transformed graph, the authors can rigorously prove the expected time to find an augmenting path.

Results and Applications

The primary result is an expected running time of $O(n \log n)$ for finding a perfect matching in any $d$-regular bipartite graph. This is a significant breakthrough for dense graphs, where it is orders of magnitude faster than the previous $O(m)$ standard.

Beyond graph theory, the authors extend their techniques to linear algebra and matrix theory. They provide an $O(n \log^2 n)$ algorithm to find a matching in the support of a doubly stochastic matrix. This has practical implications for the Birkhoff-von Neumann decomposition, a process used extensively in data networking, switch scheduling, and various resource allocation problems.

Conclusion and Future Work

The algorithm presented represents a major step forward in randomized graph algorithms, proving that sub-linear time (relative to edges) is achievable for regular bipartite matchings. However, some limitations remain. The reliance on the $d$-regularity of the graph is significant; in general bipartite graphs, the lack of uniform degrees makes the random walk analysis much more complex. Additionally, the requirement for an adjacency array for $O(1)$ sampling highlights the importance of data representation in algorithm design. Future research may explore whether similar adaptive sampling techniques can be applied to more general classes of graphs or other combinatorial optimization problems.

Summary updated

BibTeX
@inproceedings{goel2010perfect,
  author = {Ashish Goel and Michael Kapralov and Sanjeev Khanna},
  title = {{Perfect Matchings in O(n \textbackslash\{\}log n) Time in Regular Bipartite Graphs}},
  booktitle = {STOC},
  year = {2010},
  doi = {10.1145/1806689.1806697},
}
Figure