Math 2.0

Combinatorics Definition

Hopcroft–Karp algorithm

Builds on Bipartite graphMatchingPathAlgorithm

Definition

Let GG be a finite bipartite graph with vertex classes UU and WW, and let MM be a matching in GG. A vertex is free if it lies on no edge of MM. An augmenting path for MM is a path between two distinct free vertices whose edges alternate between edges not in MM and edges in MM.

The Hopcroft–Karp algorithm is the following algorithm.

  1. Start with M=∅M = \emptyset.
  2. Find the least length ℓ\ell of an augmenting path for MM; if there is none, return MM.
  3. Choose a maximal set {P1,…,Pk}\set{P_1, \dots, P_k} of pairwise vertex-disjoint augmenting paths of length ℓ\ell.
  4. Replace MM by the symmetric difference M△(P1∪⋯∪Pk)M \mathbin{\triangle} (P_1 \cup \dots \cup P_k), where each PiP_i is seen as a set of edges, and return to step 2.

Each pass through steps 2 to 4 is a phase.

Remarks

Example: let U={u1,u2}U = \set{u_1, u_2} and W={w1,w2}W = \set{w_1, w_2} with edges u1w1u_1 w_1, u2w1u_2 w_1 and u2w2u_2 w_2. In the first phase ℓ=1\ell = 1, and a maximal set of disjoint single edges is {u1w1,u2w2}\set{u_1 w_1, u_2 w_2}, which is already a perfect matching. If instead the first phase chooses {u2w1}\set{u_2 w_1}, the second phase uses the augmenting path u1,w1,u2,w2u_1, w_1, u_2, w_2 of length 33 and gives the same size 22.

Non-example: the path u1,w1u_1, w_1 is not augmenting for M={u2w1}M = \set{u_2 w_1}, because w1w_1 is not free.

By Berge's theorem, a matching is maximum if and only if it has no augmenting path, so the output is a maximum matching. Step 2 uses breadth-first search and step 3 uses depth-first search, so each phase takes time O(m)O(m). There are O(n)O(\sqrt{n}) phases, so the total time is O(mn)O(m \sqrt{n}), where nn is the number of vertices and mm the number of edges.

Reading path

To understand this page from the ground up, read these 5 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Algorithm concept
  2. Bipartite graph concept
  3. Matching concept
  4. Path concept
  5. Hopcroft–Karp algorithm definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm
About this page
TagKN5KTC6KNW
URIm2://KN5KTC6KNW
Kinddefinition
WritingW0 stub
MSC05C70, 05C85, 68W40
DefinesHopcroft–Karp algorithm
UsesBipartite graph, Matching, Path, Algorithm
Changed3 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.