Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Pseudonode.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/basic.h>
37
38#include <unordered_map>
39#include <unordered_set>
40#include <utility>
41
42namespace ogdf::matching_blossom {
43class Cycle;
44} // namespace ogdf::matching_blossom
45
46namespace ogdf {
47namespace matching_blossom {
48
53 private:
55 std::unordered_map<edge, std::unordered_set<edge>> m_refToSelfLoops;
56
58 std::unordered_map<edge, edge> m_selfLoopToRef;
59
61 std::unordered_map<edge, Pseudonode*> m_selfLoopToOtherPseudonode;
62
63 public:
65
66 ReferenceEdges() : refEdges(m_selfLoopToRef) { }
67
68 std::unordered_set<edge>& selfLoops(edge ref) { return m_refToSelfLoops[ref]; }
69
72 void addReference(edge ref, edge selfLoop, Pseudonode* other) {
73 m_refToSelfLoops[ref].insert(selfLoop);
74 m_selfLoopToRef[selfLoop] = ref;
75 m_selfLoopToOtherPseudonode[selfLoop] = other;
76 }
77
79 void removeFromOther(edge selfLoop) {
80 auto it = m_selfLoopToOtherPseudonode.find(selfLoop);
81 if (it != m_selfLoopToOtherPseudonode.end() && it->second != nullptr) {
82 auto& otherRefEdges = it->second->referenceEdges;
83 auto edgeIt = otherRefEdges.m_selfLoopToRef.find(selfLoop);
84 if (edgeIt != otherRefEdges.m_selfLoopToRef.end()) {
85 otherRefEdges.m_refToSelfLoops[edgeIt->second].erase(selfLoop);
86 otherRefEdges.m_selfLoopToRef.erase(edgeIt);
87 otherRefEdges.m_selfLoopToOtherPseudonode.erase(selfLoop);
88 }
89 }
90 }
91 };
92
93public:
96
99
102
103 Pseudonode(node _graphNode, Cycle* _cycle);
104
106
109 void addReference(edge ref, edge selfLoop, Pseudonode* other);
110};
111
112}
113}
Includes declaration of graph class.
Basic declarations, included by all source files.
Class for the representation of edges.
Definition Graph_d.h:364
Class for the representation of nodes.
Definition Graph_d.h:241
Dummy class for scoped iteration of a std::unordered_map.
Definition utils.h:112
Helper class to store reference edges for all self loops.
Definition Pseudonode.h:52
std::unordered_map< edge, edge > m_selfLoopToRef
A mapping of all self loops to their reference edges.
Definition Pseudonode.h:58
std::unordered_set< edge > & selfLoops(edge ref)
Definition Pseudonode.h:68
void addReference(edge ref, edge selfLoop, Pseudonode *other)
Add a self loop selfLoop which was removed because of the reference edge ref and pointed previously t...
Definition Pseudonode.h:72
void removeFromOther(edge selfLoop)
Remove the given selfLoop from the reference edges of the other pseudonode.
Definition Pseudonode.h:79
ValueIteratorContainer< edge, edge > refEdges
Definition Pseudonode.h:64
std::unordered_map< edge, std::unordered_set< edge > > m_refToSelfLoops
A mapping of all reference edges to all self loops that were removed because of them.
Definition Pseudonode.h:55
std::unordered_map< edge, Pseudonode * > m_selfLoopToOtherPseudonode
A mapping of all self loops to the pseudonode they previously pointed to.
Definition Pseudonode.h:61
Helper class representing a pseudonode in the Blossom algorithm.
Definition Pseudonode.h:50
ReferenceEdges referenceEdges
The ReferenceEdges for self loops of this pseudonode.
Definition Pseudonode.h:101
Pseudonode(node _graphNode, Cycle *_cycle)
void addReference(edge ref, edge selfLoop, Pseudonode *other)
Add a self loop selfLoop which was removed because of the reference edge ref and pointed previously t...
Cycle * cycle
The odd-length cycle that this pseudonode represents.
Definition Pseudonode.h:98
node graphNode
The node in the graph that this pseudonode is linked to.
Definition Pseudonode.h:95
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
Utility functions and classes regarding map access and iteration.
The namespace for all OGDF objects.