template<typename GR, typename WM>
class lemon::MaxWeightedMatching< GR, WM >
This class provides an efficient implementation of Edmond's maximum weighted matching algorithm. The implementation is based on extensive use of priority queues and provides
time complexity.
The maximum weighted matching problem is to find a subset of the edges in an undirected graph with maximum overall weight for which each node has at most one incident edge. It can be formulated with the following linear program.
where
is the set of edges incident to a node in
,
is the set of edges with both ends in
and
is the set of odd cardinality subsets of the nodes.
The algorithm calculates an optimal matching and a proof of the optimality. The solution of the dual problem can be used to check the result of the algorithm. The dual linear problem is the following.
The algorithm can be executed with the run() function. After it the matching (the primal solution) and the dual solution can be obtained using the query functions and the BlossomIt nested class, which is able to iterate on the nodes of a blossom. If the value type is integer, then the dual solution is multiplied by 4.
- Template Parameters
-
GR | The undirected graph type the algorithm runs on. |
WM | The type edge weight map. The default type is GR::EdgeMap<int>. |
|
| MaxWeightedMatching (const Graph &graph, const WeightMap &weight) |
|
|
The simplest way to execute the algorithm is to use the run() member function.
|
void | init () |
| Initialize the algorithm.
|
|
void | fractionalInit () |
| Initialize the algorithm with fractional matching.
|
|
void | start () |
| Start the algorithm.
|
|
void | run () |
| Run the algorithm.
|
|
|
Functions to get the primal solution, i.e. the maximum weighted matching.
Either run() or start() function should be called before using them.
|
Value | matchingWeight () const |
| Return the weight of the matching.
|
|
int | matchingSize () const |
| Return the size (cardinality) of the matching.
|
|
bool | matching (const Edge &edge) const |
| Return true if the given edge is in the matching.
|
|
Arc | matching (const Node &node) const |
| Return the matching arc (or edge) incident to the given node.
|
|
const MatchingMap & | matchingMap () const |
| Return a const reference to the matching map.
|
|
Node | mate (const Node &node) const |
| Return the mate of the given node.
|
|
|
Functions to get the dual solution.
Either run() or start() function should be called before using them.
|
Value | dualValue () const |
| Return the value of the dual solution.
|
|
Value | nodeValue (const Node &n) const |
| Return the dual value (potential) of the given node.
|
|
int | blossomNum () const |
| Return the number of the blossoms in the basis.
|
|
int | blossomSize (int k) const |
| Return the number of the nodes in the given blossom.
|
|
Value | blossomValue (int k) const |
| Return the dual value (ptential) of the given blossom.
|
|