How this calculation works
A bipartite graph has two disjoint vertex parts, and every edge goes from one part to the other. This page finds the largest set of edges with no shared endpoint by repeatedly searching for augmenting paths. It also returns a minimum vertex cover, a set of vertices touching every input edge. Equality between cover size and matching size provides a certificate that the matching is maximum, rather than merely one that a greedy step cannot extend.
A matching uses every endpoint at most once; for a bipartite graph, maximum matching size equals minimum vertex-cover size.A worked example
With edges L1–R1, L1–R2, L2–R1, L3–R2 and L3–R3, a matching of size three is L1–R2, L2–R1, L3–R3. All endpoints are distinct. Choosing L1–R1 first without allowing reassignment could leave L2 unmatched, which is why augmenting paths matter. The complete left part is also a vertex cover of size three, matching the three-edge lower bound and proving the optimum size.
Good to know
Accepts 1–25 vertices per part and at most 200 cross-part edge rows. Each row uses separate one-based left and right indices, so identical numeric indices can refer to different vertices. Duplicate pairs are merged. The objective is unweighted cardinality, not costs or preferences. The selected matching and minimum cover can be nonunique. A maximum matching need not include every vertex, and this page does not count all possible matchings.
Reference: NetworkX — bipartite matching and minimum vertex covers (opens in a new tab) ↗
An augmenting path can repair an earlier pairing
A greedy choice can occupy an endpoint needed by another left vertex even when a full matching exists. An augmenting path alternates between unused and currently matched edges, starting and ending at unmatched vertices. Flipping the chosen status along that path increases cardinality by one while retaining the rule that no endpoint is repeated. The algorithm therefore can move an earlier assignment instead of treating the first choices as permanent.
In the default example, assigning L1 to R1 can be repaired by moving L1 to R2 and assigning L2 to R1. The result then leaves R3 available for L3. The table labels both parts explicitly, so L1 and R1 are not accidentally merged just because each uses numeric index one. The vertex counts also preserve unmatched isolates that never appear in an edge row.
The Maximum flow minimum cut calculator for a directed graph offers another network certificate, but its capacities and conservation model differ from this cross-part cardinality problem.
A maximum matching and a maximal matching make different claims
A maximal matching cannot be enlarged simply by adding one disjoint edge. It can still be smaller than another matching that requires rearranging existing pairs. Maximum means no matching of larger cardinality exists at all. The minimum-cover certificate closes that gap: every matched edge needs at least one covering endpoint, so any vertex cover is an upper bound on matching size. Equality proves that the displayed cardinality is optimal.
The cover is constructed from alternating reachability after the matching phase. The implementation then checks that every input edge meets the cover and that its size equals the matching size. A different valid solver can return other pairs or another minimum cover with the same size. Comparing outputs should prioritize those constraints instead of assuming one arrangement is canonical. If costs or ranking preferences matter, even a full matching here can be the wrong assignment objective; no unstated price ordering is imposed.
A few questions, answered
Can an edge join two left vertices?
No. The input grammar always means left-index,right-index. A general nonbipartite matching problem requires a different algorithm and cannot be encoded by relabeling a within-part edge as though it crossed the partition.
Why are some vertices unmatched even though the result is maximum?
The available edges may not permit a larger matching, or the two parts may differ in size. Maximum cardinality is the largest feasible number of pairs, not a promise to cover every vertex.