44#include <unordered_set>
48using namespace matching_blossom;
50template<
typename TWeight>
64 std::unordered_set<edge>& matching) {
65 return doCall(G, weights, matching);
76 return doCall(GA, matching);
89 std::unordered_set<edge> matching;
92 return std::make_tuple(result, weight);
103 std::unordered_set<edge> matching;
106 return std::make_tuple(result, weight);
118 std::unordered_set<edge>& matching) {
121 return doCall(G, invertedWeights, matching);
135 return doCall(G, weights, matching);
148 std::unordered_set<edge> matching;
151 return std::make_tuple(result, weight);
162 std::unordered_set<edge> matching;
165 return std::make_tuple(result, weight);
176 std::unordered_set<edge>& matching) {
198 std::unordered_set<edge> matching;
210 std::unordered_set<edge> matching;
229 std::unordered_set<edge>& matching) = 0;
235 template<
class WeightContainer>
237 bool invert =
false) {
238 for (
edge e : G.edges) {
239 copy[e] = (invert ? -1 : 1) * getWeight<TWeight>(e, weights);
243 template<
class WeightContainer>
245 const WeightContainer& weights) {
247 for (
edge e : matching) {
248 value += getWeight<TWeight>(e, weights);
253 template<
class WeightContainer>
255 std::unordered_set<edge>& matching) {
260 for (
node origNode : G.nodes) {
266 for (
edge origEdge : G.edges) {
269 weightsCopy[newEdge] = weightsCopy[e] = -getWeight<TWeight>(origEdge, weights);
273 std::unordered_set<edge> matchingCopy;
277 doCall(graphCopy, weightsCopy, matchingCopy);
281 for (
edge e : matchingCopy) {
283 matching.insert(origEdge);
Includes declaration of graph class.
Declaration of class GraphAttributes which extends a Graph by additional attributes.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
Contains logging functionality.
Declares base class for all module types.
Basic declarations, included by all source files.
Class for the representation of edges.
node target() const
Returns the target node of the edge.
node source() const
Returns the source node of the edge.
Stores additional attributes of a graph (like layout information).
const Graph & constGraph() const
Returns a reference to the associated graph.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
const Graph & original() const
Returns a reference to the original graph.
Copies of graphs with mapping between nodes and edges.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
Data type for general directed graphs (adjacency list representation).
Centralized global and local logging facility working on streams like std::cout.
bool maximumWeightPerfectMatching(const GraphAttributes &GA, std::unordered_set< edge > &matching)
Computes a maximum weight perfect matching in GA.
std::tuple< bool, TWeight > maximumWeightPerfectMatching(const Graph &G, const EdgeArray< TWeight > &weights)
Computes a maximum weight perfect matching in G.
std::tuple< bool, TWeight > minimumWeightPerfectMatching(const Graph &G, const EdgeArray< TWeight > &weights)
Computes a minimum weight perfect matching in G.
TWeight maximumWeightMatching(const GraphAttributes &GA)
Computes a maximum weight matching in G.
std::tuple< bool, TWeight > minimumWeightPerfectMatching(const GraphAttributes &GA)
Computes a minimum weight perfect matching in G.
TWeight matchingWeight(const std::unordered_set< edge > &matching, const GraphAttributes &GA)
Calculate the weight of the matching with the weights given in GA.
void doMaximumWeightMatching(const Graph &G, const WeightContainer &weights, std::unordered_set< edge > &matching)
TWeight getMatchingWeight(const std::unordered_set< edge > &matching, const WeightContainer &weights)
bool maximumWeightPerfectMatching(const Graph &G, const EdgeArray< TWeight > &weights, std::unordered_set< edge > &matching)
Computes a maximum weight perfect matching in G.
virtual bool doCall(const Graph &G, const EdgeArray< TWeight > &weights, std::unordered_set< edge > &matching)=0
Main call function for the algorithm with an EdgeArray as weight container.
bool minimumWeightPerfectMatching(const Graph &G, const EdgeArray< TWeight > &weights, std::unordered_set< edge > &matching)
Computes a minimum weight perfect matching in G.
TWeight maximumWeightMatching(const Graph &G, const EdgeArray< TWeight > &weights)
Computes a maximum weight matching in G.
virtual bool doCall(const GraphAttributes &GA, std::unordered_set< edge > &matching)=0
Main call function for the algorithm with GraphAttrubtes as weight container.
void maximumWeightMatching(const GraphAttributes &GA, std::unordered_set< edge > &matching)
Computes a maximum weight matching in GA.
std::tuple< bool, TWeight > maximumWeightPerfectMatching(const GraphAttributes &GA)
Computes a maximum weight perfect matching in G.
TWeight matchingWeight(const std::unordered_set< edge > &matching, const EdgeArray< TWeight > &weights)
Calculate the weight of the matching with the weights given in weights.
bool minimumWeightPerfectMatching(const GraphAttributes &GA, std::unordered_set< edge > &matching)
Computes a minimum weight perfect matching in GA.
virtual ~MatchingModule()
void maximumWeightMatching(const Graph &G, const EdgeArray< TWeight > &weights, std::unordered_set< edge > &matching)
Computes a maximum weight matching in G.
void copyWeights(const Graph &G, const WeightContainer &weights, EdgeArray< TWeight > ©, bool invert=false)
Class for the representation of nodes.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
Utility functions and classes regarding map access and iteration.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.