There are several different algorithms for calculate matchings in graphs. The matching problems in bipartite graphs are generally easier than in general graphs. The goal of the matching optimization can be the finding maximum cardinality, maximum weight or minimum cost matching. The search can be constrained to find perfect or maximum cardinality matching.
Lemon contains the next algorithms:
Classes | |
class | MaxBipartiteMatching< BpUGraph > |
Bipartite Max Cardinality Matching algorithm. More... | |
class | MaxWeightedBipartiteMatching< _BpUGraph, _WeightMap, _Traits > |
Bipartite Max Weighted Matching algorithm. More... | |
class | MinCostMaxBipartiteMatching< _BpUGraph, _CostMap, _Traits > |
Bipartite Min Cost Matching algorithm. More... | |
class | MaxMatching< Graph > |
Edmonds' alternating forest maximum matching algorithm. More... | |
class | MaxWeightedMatching< _UGraph, _WeightMap > |
Weighted matching in general undirected graphs. More... | |
class | MaxWeightedPerfectMatching< _UGraph, _WeightMap > |
Weighted perfect matching in general undirected graphs. More... | |
class | PrBipartiteMatching< Graph > |
Max cardinality matching algorithm based on push-relabel principle. More... | |
Files | |
file | bipartite_matching.h |
Maximum matching algorithms in bipartite graphs. | |
file | max_matching.h |
Maximum matching algorithms in undirected graph. | |
file | pr_bipartite_matching.h |
Push-prelabel maximum matching algorithms in bipartite graphs. | |
Functions | |
template<typename BpUGraph > | |
int | maxBipartiteMatching (const BpUGraph &graph) |
Maximum cardinality bipartite matching. | |
template<typename BpUGraph , typename MatchingMap > | |
int | maxBipartiteMatching (const BpUGraph &graph, MatchingMap &matching) |
Maximum cardinality bipartite matching. | |
template<typename BpUGraph , typename MatchingMap , typename BarrierMap > | |
int | maxBipartiteMatching (const BpUGraph &graph, MatchingMap &matching, BarrierMap &barrier) |
Maximum cardinality bipartite matching. | |
template<typename BpUGraph , typename WeightMap , typename MatchingMap > | |
WeightMap::Value | maxWeightedBipartiteMatching (const BpUGraph &graph, const WeightMap &weight, MatchingMap &matching) |
Maximum weighted bipartite matching. | |
template<typename BpUGraph , typename WeightMap , typename MatchingMap > | |
WeightMap::Value | maxWeightedMaxBipartiteMatching (const BpUGraph &graph, const WeightMap &weight, MatchingMap &matching) |
Maximum weighted maximum cardinality bipartite matching. | |
template<typename BpUGraph , typename CostMap , typename MatchingMap > | |
CostMap::Value | minCostMaxBipartiteMatching (const BpUGraph &graph, const CostMap &cost, MatchingMap &matching) |
Minimum cost maximum cardinality bipartite matching. | |
template<class Graph > | |
int | prBipartiteMatching (const Graph &g) |
Maximum cardinality of the matchings in a bipartite graph. | |
template<class Graph , class MT > | |
int | prBipartiteMatching (const Graph &g, MT &matching) |
Maximum cardinality matching in a bipartite graph. | |
template<class Graph , class MT , class GT > | |
int | prBipartiteMatching (const Graph &g, MT &matching, GT &barrier) |
Maximum cardinality matching in a bipartite graph. | |
template<class Graph > | |
bool | prPerfectBipartiteMatching (const Graph &g) |
Perfect matching in a bipartite graph. | |
template<class Graph , class MT > | |
bool | prPerfectBipartiteMatching (const Graph &g, MT &matching) |
Perfect matching in a bipartite graph. | |
template<class Graph , class MT , class GT > | |
bool | prPerfectBipartiteMatching (const Graph &g, MT &matching, GT &barrier) |
Perfect matching in a bipartite graph. |
int lemon::maxBipartiteMatching | ( | const BpUGraph & | graph | ) | [inline] |
This function calculates the maximum cardinality matching in a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. |
int lemon::maxBipartiteMatching | ( | const BpUGraph & | graph, | |
MatchingMap & | matching | |||
) | [inline] |
This function calculates the maximum cardinality matching in a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. |
matching | The ANodeMap of UEdges which will be set to covered matching undirected edge. |
int lemon::maxBipartiteMatching | ( | const BpUGraph & | graph, | |
MatchingMap & | matching, | |||
BarrierMap & | barrier | |||
) | [inline] |
This function calculates the maximum cardinality matching in a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. |
matching | The ANodeMap of UEdges which will be set to covered matching undirected edge. | |
barrier | The BNodeMap of bools which will be set to a barrier of the BNode-set. |
WeightMap::Value lemon::maxWeightedBipartiteMatching | ( | const BpUGraph & | graph, | |
const WeightMap & | weight, | |||
MatchingMap & | matching | |||
) | [inline] |
This function calculates the maximum weighted matching in a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. | |
weight | The undirected edge map which contains the weights. |
matching | The undirected edge map which will be set to the matching. |
WeightMap::Value lemon::maxWeightedMaxBipartiteMatching | ( | const BpUGraph & | graph, | |
const WeightMap & | weight, | |||
MatchingMap & | matching | |||
) | [inline] |
This function calculates the maximum weighted of the maximum cardinality matchings of a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. | |
weight | The undirected edge map which contains the weights. |
matching | The undirected edge map which will be set to the matching. |
CostMap::Value lemon::minCostMaxBipartiteMatching | ( | const BpUGraph & | graph, | |
const CostMap & | cost, | |||
MatchingMap & | matching | |||
) | [inline] |
This function calculates the maximum cardinality matching with minimum cost of a bipartite graph. It gives back the matching in an undirected edge map.
graph | The bipartite graph. | |
cost | The undirected edge map which contains the costs. |
matching | The undirected edge map which will be set to the matching. |
int lemon::prBipartiteMatching | ( | const Graph & | g | ) | [inline] |
This function finds the maximum cardinality of the matchings in a bipartite graph g
.
g | An undirected bipartite graph. |
int lemon::prBipartiteMatching | ( | const Graph & | g, | |
MT & | matching | |||
) | [inline] |
This function finds a maximum cardinality matching in a bipartite graph g
.
g | An undirected bipartite graph. |
matching | A write ANodeMap of value type UEdge . The found edges will be returned in this map, i.e. for an ANode n the edge matching[n] is the one that covers the node n . |
int lemon::prBipartiteMatching | ( | const Graph & | g, | |
MT & | matching, | |||
GT & | barrier | |||
) | [inline] |
This function finds a maximum cardinality matching in a bipartite graph g
.
g | An undirected bipartite graph. |
matching | A write ANodeMap of value type UEdge . The found edges will be returned in this map, i.e. for an ANode n the edge matching[n] is the one that covers the node n . | |
barrier | A bool WriteMap on the BNodes. The map will be set exactly once for each BNode. The nodes with true value represent a barrier B, i.e. the cardinality of B minus the number of its neighbor is equal to the number of the BNode s minus the cardinality of the maximum matching. |
bool lemon::prPerfectBipartiteMatching | ( | const Graph & | g | ) | [inline] |
This function checks whether the bipartite graph g
has a perfect matching.
g | An undirected bipartite graph. |
true
iff g
has a perfect matching.bool lemon::prPerfectBipartiteMatching | ( | const Graph & | g, | |
MT & | matching | |||
) | [inline] |
This function finds a perfect matching in a bipartite graph g
.
g | An undirected bipartite graph. |
matching | A write ANodeMap of value type UEdge . The found edges will be returned in this map, i.e. for an ANode n the edge matching[n] is the one that covers the node n . The values are unchanged if the graph has no perfect matching. |
true
iff g
has a perfect matching.bool lemon::prPerfectBipartiteMatching | ( | const Graph & | g, | |
MT & | matching, | |||
GT & | barrier | |||
) | [inline] |
This function finds a perfect matching in a bipartite graph g
.
g | An undirected bipartite graph. |
matching | A write ANodeMap of value type UEdge . The found edges will be returned in this map, i.e. for an ANode n the edge matching[n] is the one that covers the node n . The values are unchanged if the graph has no perfect matching. | |
barrier | A bool WriteMap on the BNodes. The map will only be set if g has no perfect matching. In this case it is set exactly once for each BNode. The nodes with true value represent a barrier, i.e. a subset B a of BNodes with the property that the cardinality of B is greater than the number of its neighbors. |
true
iff g
has a perfect matching.