43#include <unordered_set>
47namespace matching_blossom {
49template<
class TWeight>
51template<
class TWeight>
54template<
class TWeight>
149template<
class TWeight>
214template<
class TWeight>
287 edge e = adj->theEdge();
288 node v = adj->twinNode();
295 auxNode(auxGraphNode)->addEvenFreeEdge(e);
321 if (
auxNode->currentEdge() ==
nullptr) {
337 for (
auto treeNodes : {
tree.evenNodes,
tree.oddNodes}) {
338 for (
node v : treeNodes) {
343 for (
auto adj :
auxNode->graphNode()->adjEntries) {
358 std::vector<node> stack;
363 std::unordered_set<node> component = {u};
364 while (!stack.empty()) {
365 node v = stack.back();
368 node w = adj->twinNode();
371 if (
auxEdge->hasEvenOddEqualityEdge()) {
379 components.push_back(component);
385 for (
auto component : components) {
386 count += component.size();
Implementation of an Alternating Tree helper structure for the Blossom algorithm.
Includes declaration of graph class.
Declaration of graph copy classes.
Decralation of GraphElement and GraphList classes.
An extension of the standard priority queue with additional features.
Basic declarations, included by all source files.
Class for adjacency list elements.
Class for the representation of edges.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
std::array< node, 2 > nodes() const
Returns a list of adjacent nodes. If this edge is a self-loop, both entries will be the same node.
bool isIncident(node v) const
Returns true iff v is incident to the edge.
node source() const
Returns the source node of the edge.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
void delNode(node v) override
Removes node v.
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.
void setOriginalGraph(const Graph *G) override
Re-initializes the copy using G (which might be null), but does not create any nodes or edges.
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
int numberOfNodes() const
Returns the number of nodes in the graph.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
bool empty() const
Checks whether the queue is empty.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
void addEdgeToPQ(edge e, EdgePQ &pq)
Helper function to add an edge to a priority queue with its current reduced weight.
AuxEdge(edge e, BlossomVHelper< TWeight > &helper)
void addEvenEvenEdge(edge e)
Adds e to evenEvenEdges.
EdgePQ & evenOddEdgesFromPerspective(AuxNode< TWeight > *auxNode)
Returns evenOddEdges or oddEvenEdges, depending on the perspective of auxNode (the even node).
BlossomVHelper< TWeight > & m_helper
void addEvenOddEdgeFromPerspective(edge e, AuxNode< TWeight > *auxNode)
Adds e to evenOddEdges or oddEvenEdges depending on the perspective of auxNode.
bool hasEvenOddEqualityEdge()
Whether or not this edge connects two trees via an alternating equality edge.
GraphCopySimple & graph()
AuxNode< TWeight > * createAuxNode(node v)
Creates an AuxNode for v and stores it in the appropriate maps.
const NodeArray< AuxNode< TWeight > * > & nodes() const
void connectedComponents(std::vector< std::unordered_set< node > > &components)
Calculates the connected components of the auxiliary graph and stores them in components....
NodeArray< AuxNode< TWeight > * > m_nodeAuxNodeMap
maps normal graph nodes to the AuxNode whose tree they belong to
AuxEdge< TWeight > * assertCurrentEdge(AuxNode< TWeight > *auxNode, AuxNode< TWeight > *current)
Creates an AuxEdge between auxNode and current if it does not exist and sets the currentEdge of auxNo...
AuxEdge< TWeight > * auxEdge(edge e)
Returns the AuxEdge corresponding to e, which must be an edge of the auxiliary graph.
void setAuxNode(node v, AuxNode< TWeight > *auxNode)
Sets the AuxNode of v to auxNode.
NodeArray< AuxNode< TWeight > * > m_auxGraphNodeMap
maps auxiliary graph nodes to their AuxNode objects
AuxGraph(BlossomVHelper< TWeight > &helper)
BlossomVHelper< TWeight > & m_helper
void reset()
Rebuilds the auxiliary graph from the current graph.
AuxNode< TWeight > * treeAuxNode(node v)
Returns the AuxNode of whose tree the node v of the actual graph is a part of.
AlternatingTree< TWeight > * treeOf(node v)
Returns the tree which contains v, or nullptr if v is free.
EdgeArray< AuxEdge< TWeight > * > m_auxGraphEdgeMap
maps auxiliary graph edges to their AuxEdge objects
AuxNode< TWeight > * auxNode(node v)
Returns the AuxNode corresponding to v, which must be a node of the auxiliary graph.
AuxEdge< TWeight > * createAuxEdge(edge e)
Creates an AuxEdge for e and stores it in the appropriate maps.
const EdgeArray< AuxEdge< TWeight > * > & edges() const
AuxNode< TWeight > * auxNodeForEdge(edge e)
Returns the AuxNode of the auxiliary graph whose tree contains at least one endpoint of e....
void deleteNode(AuxNode< TWeight > *auxNode)
Removes auxNode and all incident edges from the auxiliary graph.
struct ogdf::matching_blossom::AuxNode::@6 m_currentEdge
Structure representing the current edge of this tree. To avoid resetting all edges of all trees after...
AlternatingTree< TWeight > m_tree
The alternating tree this node represents.
BlossomVHelper< TWeight > & m_helper
The auxiliary graph this node belongs to.
AlternatingTree< TWeight > & tree()
EdgePQ m_evenFreeEdges
Edges between an even node in this tree and a free node.
AuxEdge< TWeight > * edge
void addEvenFreeEdge(edge e)
Add e to the list of even-free edges of this tree.
NodePQ & oddPseudonodes()
AuxEdge< TWeight > * currentEdge()
The aux edge pointing to the current aux node.
node m_node
The actual node in the auxiliary graph.
void addOddPseudonode(node v)
Add v to the list of odd pseudonodes of this tree.
double delta(node v)
The delta of this tree for the given node.
void addDelta(double delta)
Add delta to this tree. delta must be non-negative.
EdgePQ m_evenEvenEdges
Eges between even nodes in this tree.
double m_delta
The cummulated delta of this tree.
void setCurrentEdge(AuxEdge< TWeight > *edge)
Sets the current edge of this tree to edge and update the iteration to the current one.
void addEvenEvenEdge(edge e)
Add e to the list of even-even edges of this tree.
NodePQ m_oddPseudonodes
All odd pseudonodes in this tree.
AuxNode(node auxGraphNode, node graphNode, BlossomVHelper< TWeight > &helper)
void push(const E &element, const TWeight priority)
Adds a new element to the queue.
Helper class for the blossom matching algorithms.
const E & topElement() const
Returns the topmost element in the queue.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...