Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
42 namespace ogdf::matching_blossom {
43 class Cycle;
44 } // namespace ogdf::matching_blossom
45 
46 namespace ogdf {
47 namespace 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 
93 public:
96 
99 
102 
103  Pseudonode(node _graphNode, Cycle* _cycle);
104 
105  ~Pseudonode();
106 
109  void addReference(edge ref, edge selfLoop, Pseudonode* other);
110 };
111 
112 }
113 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::matching_blossom::BaseIteratorContainer
Dummy class for scoped iteration of a std::unordered_map.
Definition: utils.h:112
ogdf::matching_blossom::Pseudonode
Helper class representing a pseudonode in the Blossom algorithm.
Definition: Pseudonode.h:50
Graph.h
Includes declaration of graph class.
ogdf::matching_blossom::Pseudonode::referenceEdges
ReferenceEdges referenceEdges
The ReferenceEdges for self loops of this pseudonode.
Definition: Pseudonode.h:101
ogdf::matching_blossom::Pseudonode::ReferenceEdges::m_selfLoopToOtherPseudonode
std::unordered_map< edge, Pseudonode * > m_selfLoopToOtherPseudonode
A mapping of all self loops to the pseudonode they previously pointed to.
Definition: Pseudonode.h:61
ogdf::matching_blossom::Pseudonode::ReferenceEdges
Helper class to store reference edges for all self loops.
Definition: Pseudonode.h:52
ogdf::matching_blossom
Definition: AlternatingTree.h:50
ogdf::matching_blossom::Pseudonode::ReferenceEdges::addReference
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
ogdf::matching_blossom::Pseudonode::ReferenceEdges::m_selfLoopToRef
std::unordered_map< edge, edge > m_selfLoopToRef
A mapping of all self loops to their reference edges.
Definition: Pseudonode.h:58
ogdf::matching_blossom::Cycle
Definition: Cycle.h:44
ogdf::matching_blossom::Pseudonode::ReferenceEdges::refEdges
ValueIteratorContainer< edge, edge > refEdges
Definition: Pseudonode.h:64
ogdf::matching_blossom::Pseudonode::cycle
Cycle * cycle
The odd-length cycle that this pseudonode represents.
Definition: Pseudonode.h:98
ogdf::matching_blossom::Pseudonode::ReferenceEdges::selfLoops
std::unordered_set< edge > & selfLoops(edge ref)
Definition: Pseudonode.h:68
ogdf::matching_blossom::Pseudonode::ReferenceEdges::m_refToSelfLoops
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
ogdf::matching_blossom::Pseudonode::graphNode
node graphNode
The node in the graph that this pseudonode is linked to.
Definition: Pseudonode.h:95
ogdf::matching_blossom::Pseudonode::ReferenceEdges::ReferenceEdges
ReferenceEdges()
Definition: Pseudonode.h:66
basic.h
Basic declarations, included by all source files.
ogdf::matching_blossom::Pseudonode::ReferenceEdges::removeFromOther
void removeFromOther(edge selfLoop)
Remove the given selfLoop from the reference edges of the other pseudonode.
Definition: Pseudonode.h:79
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
utils.h
Utility functions and classes regarding map access and iteration.
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240