V
- the graph vertex typeE
- the graph edge typepublic class GreedyWeightedMatching<V,E> extends Object implements MatchingAlgorithm<V,E>
The greedy algorithm is the algorithm that first orders the edge set in non-increasing order of weights and then greedily constructs a maximal cardinality matching out of the edges with positive weight. A maximal cardinality matching (not to be confused with maximum cardinality) is a matching that cannot be increased in cardinality without removing an edge first.
For more information about approximation algorithms for the maximum weight matching problem in arbitrary graphs see:
PathGrowingWeightedMatching
MatchingAlgorithm.Matching<E>, MatchingAlgorithm.MatchingImpl<E>
DEFAULT_EPSILON
Constructor and Description |
---|
GreedyWeightedMatching(Graph<V,E> graph)
Create and execute a new instance of the greedy maximum weight matching algorithm.
|
GreedyWeightedMatching(Graph<V,E> graph,
double epsilon)
Create and execute a new instance of the greedy maximum weight matching algorithm.
|
Modifier and Type | Method and Description |
---|---|
MatchingAlgorithm.Matching<E> |
computeMatching()
Get a matching that is a 1/2-approximation of the maximum weighted matching.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMatching
public GreedyWeightedMatching(Graph<V,E> graph)
MatchingAlgorithm.DEFAULT_EPSILON
tolerance.graph
- the input graphpublic MatchingAlgorithm.Matching<E> computeMatching()
computeMatching
in interface MatchingAlgorithm<V,E>
Copyright © 2017. All rights reserved.