V
- the graph vertex typeE
- the graph edge typepublic class GreedyWeightedMatching<V,E> extends Object implements MatchingAlgorithm<V,E>
This algorithm can be run in two modes: with and without edge cost normalization. Without
normalization, the algorithm 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. The resulting matching is
guaranteed to be a $\frac{1}{2}$-Approximation.
With normalization, the edges are sorted in non-increasing order of their normalized costs
$\frac{c(u,v)}{d(u)+d(v)}$ instead, after which the algorithm proceeds in the same manner. Here,
$c(u,v)$ is the cost of edge $(u,v)$, and $d(u)$ resp $d(v)$ are the degrees of vertices $u$ resp
$v$. Running this algorithm in normalized mode often (but not always!) produces a better result
than running the algorithm without normalization. Note however that the normalized version
does NOT produce a $\frac{1}{2}$-approximation. See this
proof for details. The runtime complexity remains the same, independent of whether
normalization is used.
For more information about approximation algorithms for the maximum weight matching problem in arbitrary graphs see:
PathGrowingWeightedMatching
MatchingAlgorithm.Matching<V,E>, MatchingAlgorithm.MatchingImpl<V,E>
DEFAULT_EPSILON
Constructor and Description |
---|
GreedyWeightedMatching(Graph<V,E> graph,
boolean normalizeEdgeCosts)
Create and execute a new instance of the greedy maximum weight matching algorithm.
|
GreedyWeightedMatching(Graph<V,E> graph,
boolean normalizeEdgeCosts,
double epsilon)
Create and execute a new instance of the greedy maximum weight matching algorithm.
|
Modifier and Type | Method and Description |
---|---|
MatchingAlgorithm.Matching<V,E> |
getMatching()
Get a matching that is a $\frac{1}{2}$-approximation of the maximum weighted matching.
|
public GreedyWeightedMatching(Graph<V,E> graph, boolean normalizeEdgeCosts)
MatchingAlgorithm.DEFAULT_EPSILON
tolerance.graph
- the input graphnormalizeEdgeCosts
- boolean indicating whether edge normalization has to be used.public GreedyWeightedMatching(Graph<V,E> graph, boolean normalizeEdgeCosts, double epsilon)
graph
- the input graphnormalizeEdgeCosts
- boolean indicating whether edge normalization has to be used.epsilon
- tolerance when comparing floating point valuespublic MatchingAlgorithm.Matching<V,E> getMatching()
getMatching
in interface MatchingAlgorithm<V,E>
Copyright © 2018. All rights reserved.