|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
43 #include <unordered_set>
47 namespace matching_blossom {
49 template<
class TWeight>
51 template<
class TWeight>
54 template<
class TWeight>
149 template<
class TWeight>
214 template<
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();
371 if (
auxEdge->hasEvenOddEqualityEdge()) {
379 components.push_back(component);
385 for (
auto component : components) {
386 count += component.size();
The namespace for all OGDF objects.
Includes declaration of graph class.
An extension of the standard priority queue with additional features.
AuxNode< TWeight > * createAuxNode(node v)
Creates an AuxNode for v and stores it in the appropriate maps.
AuxEdge< TWeight > * edge
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...
NodePQ & oddPseudonodes()
edge copy(edge e) const override
Returns the edge in the graph copy corresponding to e.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
AlternatingTree< TWeight > * treeOf(node v)
Returns the tree which contains v, or nullptr if v is free.
void addEvenFreeEdge(edge e)
Add e to the list of even-free edges of this tree.
void deleteNode(AuxNode< TWeight > *auxNode)
Removes auxNode and all incident edges from the auxiliary graph.
AuxGraph(BlossomVHelper< TWeight > &helper)
NodeArray< AuxNode< TWeight > * > m_auxGraphNodeMap
maps auxiliary graph nodes to their AuxNode objects
const EdgeArray< AuxEdge< TWeight > * > & edges() const
AuxEdge< TWeight > * auxEdge(edge e)
Returns the AuxEdge corresponding to e, which must be an edge of the auxiliary graph.
EdgePQ m_evenFreeEdges
Edges between an even node in this tree and a free node.
Copies of graphs with mapping between nodes and edges.
EdgePQ & evenOddEdgesFromPerspective(AuxNode< TWeight > *auxNode)
Returns evenOddEdges or oddEvenEdges, depending on the perspective of auxNode (the even node).
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 addOddPseudonode(node v)
Add v to the list of odd pseudonodes of this tree.
Helper class for the blossom matching algorithms.
Class for adjacency list elements.
AuxNode< TWeight > * treeAuxNode(node v)
Returns the AuxNode of whose tree the node v of the actual graph is a part of.
void setCurrentEdge(AuxEdge< TWeight > *edge)
Sets the current edge of this tree to edge and update the iteration to the current one.
edge theEdge() const
Returns the edge associated with this adjacency entry.
bool empty() const
Checks whether the queue is empty.
EdgeArray< AuxEdge< TWeight > * > m_auxGraphEdgeMap
maps auxiliary graph edges to their AuxEdge objects
void addDelta(double delta)
Add delta to this tree. delta must be non-negative.
internal::GraphObjectContainer< NodeElement > nodes
The container containing all node objects.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
int numberOfNodes() const
Returns the number of nodes in the graph.
NodePQ m_oddPseudonodes
All odd pseudonodes in this tree.
AuxEdge< TWeight > * createAuxEdge(edge e)
Creates an AuxEdge for e and stores it in the appropriate maps.
AuxNode< TWeight > * auxNodeForEdge(edge e)
Returns the AuxNode of the auxiliary graph whose tree contains at least one endpoint of e....
Decralation of GraphElement and GraphList classes.
void connectedComponents(std::vector< std::unordered_set< node >> &components)
Calculates the connected components of the auxiliary graph and stores them in components....
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
AlternatingTree< TWeight > m_tree
The alternating tree this node represents.
AlternatingTree< TWeight > & tree()
AuxEdge< TWeight > * currentEdge()
The aux edge pointing to the current aux node.
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.
Declaration of graph copy classes.
RegisteredArray for nodes, edges and adjEntries of a graph.
AuxNode(node auxGraphNode, node graphNode, BlossomVHelper< TWeight > &helper)
void delNode(node v) override
Removes node v.
const E & topElement() const
Returns the topmost element in the queue.
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
double delta(node v)
The delta of this tree for the given node.
void clear() override
Removes all nodes and edges from this copy but does not break the link with the original graph.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
AuxNode< TWeight > * auxNode(node v)
Returns the AuxNode corresponding to v, which must be a node of the auxiliary graph.
NodeArray< AuxNode< TWeight > * > m_nodeAuxNodeMap
maps normal graph nodes to the AuxNode whose tree they belong to
BlossomVHelper< TWeight > & m_helper
bool hasEvenOddEqualityEdge()
Whether or not this edge connects two trees via an alternating equality edge.
void addEdgeToPQ(edge e, EdgePQ &pq)
Helper function to add an edge to a priority queue with its current reduced weight.
const NodeArray< AuxNode< TWeight > * > & nodes() const
Basic declarations, included by all source files.
BlossomVHelper< TWeight > & m_helper
void push(const E &element, const TWeight priority)
Adds a new element to the queue.
AuxEdge(edge e, BlossomVHelper< TWeight > &helper)
Implementation of an Alternating Tree helper structure for the Blossom algorithm.
void addEvenOddEdgeFromPerspective(edge e, AuxNode< TWeight > *auxNode)
Adds e to evenOddEdges or oddEvenEdges depending on the perspective of auxNode.
Class for the representation of edges.
const Graph * graphOf() const
Returns the graph containing this node (debug only).
void reset()
Rebuilds the auxiliary graph from the current graph.
node m_node
The actual node in the auxiliary graph.
bool isIncident(node v) const
Returns true iff v is incident to the edge.
double m_delta
The cummulated delta of this tree.
void setAuxNode(node v, AuxNode< TWeight > *auxNode)
Sets the AuxNode of v to auxNode.
void addEvenEvenEdge(edge e)
Adds e to evenEvenEdges.
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.
EdgePQ m_evenEvenEdges
Eges between even nodes in this tree.
Class for the representation of nodes.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
void addEvenEvenEdge(edge e)
Add e to the list of even-even edges of this tree.
GraphCopySimple & 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...
const Graph & original() const
Returns a reference to the original graph.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
BlossomVHelper< TWeight > & m_helper
The auxiliary graph this node belongs to.