LLMpediaThe first transparent, open encyclopedia generated by LLMs

Hopcroft–Karp algorithm

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Expansion Funnel Raw 3 → Dedup 1 → NER 0 → Enqueued 0
1. Extracted3
2. After dedup1 (None)
3. After NER0 (None)
Rejected: 1 (not NE: 1)
4. Enqueued0 ()
Hopcroft–Karp algorithm
NameHopcroft–Karp algorithm
AuthorsJohn Hopcroft; Richard Karp
Year1973
InputBipartite graph G = (U, V, E)
OutputMaximum matching
ComplexityO(√n·m)

Hopcroft–Karp algorithm The Hopcroft–Karp algorithm is a classical algorithm for computing maximum matchings in bipartite graphs, developed by John Hopcroft and Richard Karp in 1973. It improved on earlier work by Jack Edmonds and others, combining breadth-first search layering with repeated depth-first search augmentation to achieve near-optimal asymptotic performance for sparse instances. The algorithm is cornerstone material in algorithmic graph theory and is taught alongside results by Donald Knuth and Ronald Rivest in curricula that reference results from the ACM and IEEE.

Introduction

The Hopcroft–Karp algorithm addresses the maximum matching problem on finite bipartite graphs, where a matching is a set of vertex-disjoint edges connecting two partite sets U and V. Building on foundational contributions by Jack Edmonds, Robert Tarjan, and Harold Kuhn, Hopcroft and Karp derived an approach that uses layered shortest augmenting paths to accelerate augmentation compared to naive methods associated with Konrad Zuse-era formulations. The work influenced subsequent research at institutions like MIT, Harvard, and Stanford, and appears in texts by Michael Sipser, Andrew Viterbi, and Tim Roughgarden.

Algorithm Description

The algorithm operates in alternating phases of layered breadth-first search and multiple depth-first searches. Starting from an initial empty matching, it constructs a BFS layering from all free vertices in U to build a level graph that captures the shortest augmenting distances, an idea echoing techniques used in network flow research at Bell Labs and IBM Research. Within the level graph, it performs disjoint augmentations via DFS to find maximal collections of vertex-disjoint shortest augmenting paths, leveraging concepts appearing in work by Richard Bellman, Lester Ford, and D. R. Fulkerson. Each phase reduces the distance to unmatched vertices in V or increases the matching size until no augmenting path remains, similar in spirit to approaches explored at Carnegie Mellon University and Princeton.

Correctness and Complexity

Correctness follows from classical augmenting path theorems originally proven by Julius König and extended by Jack Edmonds, with Hopcroft and Karp formalizing that repeatedly finding maximal sets of shortest augmenting paths preserves the invariant of maximality and leads to an optimal matching. Complexity analysis yields O(√n·m) time for a graph with n vertices and m edges, a bound influenced by earlier complexity theory from the work of Stephen Cook and Leonid Levin and refined through combinatorial arguments used by Éva Tardos and Richard Karp. The bound is tight for certain families of graphs studied by Paul Erdős and Béla Bollobás, and the algorithm is frequently compared to Dinic's method for maximum flow developed by Yefim Dinitz and later analyzed by László Lovász.

Implementation Details

A practical implementation maintains adjacency lists and arrays for pairings and distances, reflecting implementation patterns taught in courses at California Institute of Technology and University of Cambridge. Core routines include a BFS that enqueues free vertices from U and labels levels until free vertices in V are discovered, and a DFS that follows layered edges to produce augmenting paths, patterns similar to implementations in libraries from GNU, Microsoft Research, and Google. Careful index handling, memory allocation strategies from Sun Microsystems-era recommendations, and iterative rather than recursive DFS variants help portability across platforms such as Linux, Windows, and macOS, and make integration with frameworks from Oracle and Red Hat straightforward.

Optimizations and Variants

Numerous optimizations and variants extend the original method. Weighted or capacity-constrained variants relate to work by Jack Edmonds and Ellis Johnson on assignment problems and are used in algorithms derived from Hungarian algorithm improvements by Harold Kuhn and James Munkres. Parallel and distributed adaptations echo methods explored in projects at IBM, Intel, and NVIDIA for multicore and GPU acceleration, while dynamic maintenance of matchings connects to dynamic graph studies by David Karger and Monika Henzinger. Practical heuristics, including vertex ordering inspired by Donald Knuth’s literate programming and caching techniques used at Facebook and Twitter, can substantially improve runtime on real-world datasets studied by researchers at Stanford, UCLA, and ETH Zurich.

Applications and Practical Use

The Hopcroft–Karp algorithm is widely used in applications ranging from resource allocation and scheduling studied at the Massachusetts Institute of Technology to compiler register allocation research at Bell Labs. It underpins matching components in recommendation systems at Amazon and content delivery networks operated by Netflix, and it appears in computational biology pipelines developed at the Broad Institute for sequence alignment tasks. Further applications include job assignment problems handled by the United Nations and European Commission planning tools, network switch fabric designs researched at Cisco and Juniper, and classroom examples in textbooks by Thomas Cormen, Charles Leiserson, Ronald Rivest, and Clifford Stein.

Category:Algorithms Category:Graph theory Category:Combinatorics