org.jgrapht.alg.matching
Class HopcroftKarpBipartiteMatching<V,E>
- java.lang.Object
-
- org.jgrapht.alg.matching.HopcroftKarpBipartiteMatching<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
- MatchingAlgorithm<V,E>
public class HopcroftKarpBipartiteMatching<V,E> extends java.lang.Object implements MatchingAlgorithm<V,E>
This class is an implementation of the Hopcroft-Karp algorithm which finds a maximum matching in an undirected simple bipartite graph. The algorithm runs in O(|E|*√|V|) time. The original algorithm is described in: Hopcroft, John E.; Karp, Richard M. (1973), "An n5/2 algorithm for maximum matchings in bipartite graphs", SIAM Journal on Computing 2 (4): 225–231, doi:10.1137/0202019 A coarse overview of the algorithm is given in: http://en.wikipedia.org/wiki/Hopcroft-Karp_algorithm Note: the behavior of this class is undefined when the input isn't a bipartite graph, i.e. when there are edges within a single partition!
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.MatchingAlgorithm
MatchingAlgorithm.Matching<E>, MatchingAlgorithm.MatchingImpl<E>
-
-
Field Summary
-
Fields inherited from interface org.jgrapht.alg.interfaces.MatchingAlgorithm
DEFAULT_EPSILON
-
-
Constructor Summary
Constructors Constructor and Description HopcroftKarpBipartiteMatching(Graph<V,E> graph, java.util.Set<V> partition1, java.util.Set<V> partition2)Construct a new instance of the Hopcroft-Karp algorithm for the computation of maximum matchings in bipartite graphs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description MatchingAlgorithm.Matching<E>computeMatching()Compute a matching for a given graph.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.alg.interfaces.MatchingAlgorithm
getMatching
-
-
-
-
Constructor Detail
-
HopcroftKarpBipartiteMatching
public HopcroftKarpBipartiteMatching(Graph<V,E> graph, java.util.Set<V> partition1, java.util.Set<V> partition2)
Construct a new instance of the Hopcroft-Karp algorithm for the computation of maximum matchings in bipartite graphs.- Parameters:
graph- the input graphpartition1- the first partition of the vertex setpartition2- the second partition of the vertex set
-
-
Method Detail
-
computeMatching
public MatchingAlgorithm.Matching<E> computeMatching()
Compute a matching for a given graph.- Specified by:
computeMatchingin interfaceMatchingAlgorithm<V,E>- Returns:
- a matching
-
-
DataMelt 3.0 © DataMelt by jWork.ORG