Guest User
Using app without sign in

Practice book
Graph Theory Through Problems300 Exercises with Hints, Worked Algorithms and Complete Solutions
By Mohammed Islam Hadjoudj
Learn graph theory by solving problems: 300 exercises, from routine checks to challenging proofs, each with a complete solution.
Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on AmazonSelect an algorithm and generate steps to begin visualization
Maximum matching in a bipartite graph
Finds a maximum matching in a bipartite graph through phases of shortest augmenting paths
Select an algorithm and generate steps to begin visualization
The Hopcroft-Karp algorithm finds a maximum matching in a bipartite graph: the largest set of edges in which no two edges share a vertex. Matchings model every assignment problem where items on one side are paired with items on the other, such as workers with jobs or students with projects, and Hopcroft-Karp is the fastest classic algorithm for the unweighted case.
The algorithm works in phases. Each phase starts with a breadth-first search from every unmatched left vertex, building layers that alternate between unmatched edges going right and matched edges coming back left, and stops at the first layer that reaches an unmatched right vertex. A depth-first search then follows those layers to collect a maximal set of vertex-disjoint shortest augmenting paths, and flipping each path adds one pair to the matching. Because the shortest augmenting path gets longer after every phase, only O(√V) phases are needed, for O(E√V) time in total.
Bipartite matching assigns workers to shifts, students to schools, ads to slots and donors to recipients, and it sits inside other results such as König's theorem on minimum vertex covers. When pairs carry costs, the Hungarian method is the usual choice; Hopcroft-Karp is the tool when every pair is simply allowed or not. It is a classic topic in algorithms courses and competitive programming.
Related algorithms: Maximum Flow, Bipartite Check, Minimum Cut, Breadth-First Search