Content deleted Content added
→Algorithm: dfs also requires the paths to alternate |
fix notation; add AMO reference; separate notes and references section; rm CLRS reference as it only gives it in an exercise rather than actually describing it in-text; rm nonbipartite ref |
||
Line 1:
The '''Hopcroft–Karp algorithm''' finds maximum cardinality [[matching]]s in [[bipartite graph]]s in
The algorithm was found by {{harvs|first1=John|last1=Hopcroft|author1-link=John Hopcroft|first2=Richard|last2=Karp|author2-link=Richard Karp|txt|year=1973}}. It increases the size of the matching by a sequence of augmenting paths, a standard technique in matching algorithms, but instead of finding just a single augmenting path, the algorithm finds a maximal set of shortest augmenting paths in each iteration. As a result only O(√''n'') iterations are needed.
A vertex that is not the endpoint of an edge in some partial matching ''M'' is called a ''free vertex''. The basic concept that the algorithm relies on is that of an ''
Conversely, suppose that a matching ''M'' is not optimal, and let ''P'' be the symmetric difference ''M'' ⊕ ''M''* where ''M''* is an optimal matching. Then ''P'' must form a collection of disjoint cycles and
An
▲==Alternating paths==
▲The basic concept that the algorithm relies on is that of an ''alternating path'', a path that starts at an unmatched vertex, ends at an unmatched vertex, and alternates between unmatched and matched edges within the path. If ''M'' is a matching of size ''n'', and ''P'' is an alternating path relative to ''M'', then the matching ''M'' ⊕ ''P'' would have a size of ''n'' + 1. Thus, by finding alternating paths, an algorithm may increase the size of the matching.
▲Conversely, suppose that a matching ''M'' is not optimal, and let ''P'' be the symmetric difference ''M'' ⊕ ''M''* where ''M''* is an optimal matching. Then ''P'' must form a collection of disjoint cycles and alternating paths; the difference in size between ''M'' and ''M''* is the number of paths in ''P''. Thus, if no alternating path can be found, an algorithm may safely terminate, since in this case ''M'' must be optimal.
▲An alternating path is closely related to an [[augmenting path]], a path in a [[maximum flow]] problem that increases the amount of flow between the terminals of the flow. It is possible to transform the bipartite matching problem into a maximum flow instance, such that the alternating paths of the matching problem become augmenting paths of the flow problem. The Hopcroft–Karp algorithm may be generalized to problems of maximum flow on unweighted graphs, but is not as efficient in that generalization as it is for bipartite matching.
==Algorithm==
Line 37 ⟶ 28:
Since the algorithm performs a total of at most 2√''n'' phases, it takes a total time of O(''m'' √''n'').
==Notes==
{{reflist}}▼
==References==
*{{citation|first1=Ravindra K.|last1=Ahuja|first2=Thomas L.|last2=Magnanti|first3=James B.|last3=Orlin|title=Network Flows: Theory, ALgorithms and Applications|publisher=Prentice-Hall|year=1993}}.
▲{{reflist}}
*{{citation|first1=John E.|last1=Hopcroft|author1-link=John Hopcroft|first2=Richard M.|last2=Karp|author2-link=Richard Karp|title=An ''n''<sup>5/2</sup> algorithm for maximum matchings in bipartite graphs|journal=SIAM Journal on Computing|volume=2|issue=4|pages=225–231|year=1973|doi=10.1137/0202019}}.</ref>
[[Category:Graph algorithms]]
|