learngraphtheory.org

Guest User

Using app without sign in

Cover of the book Graph Theory Through Problems

Practice book

Graph Theory Through Problems

300 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.

Available inKindlePaperback

13 chapters

Also by the authorGraph Algorithms for Coding Interviews100 solved interview problems with visual explanations and Python solutions.View on Amazon
Algorithm Selection

Select an algorithm and generate steps to begin visualization

Hopcroft-Karp Calculator

Maximum matching in a bipartite graph

Finds a maximum matching in a bipartite graph through phases of shortest augmenting paths

Time: O(E√V)
Space: O(V)
Use Case: Assigning workers to jobs, students to schools, ads to slots
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Hopcroft-Karp Matching

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.

How it works

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.

Applications

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

Interactive Controls

Zoom Controls

69%
Nodes: 8
Edges: 7