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>
37 
38 #include <unordered_map>
39 #include <vector>
40 
41 namespace ogdf {
42 namespace matching_blossom {
43 
48  private:
50  std::unordered_map<edge, std::unordered_set<edge>> m_refToSelfLoops;
51 
53  std::unordered_map<edge, edge> m_selfLoopToRef;
54 
56  std::unordered_map<edge, Pseudonode*> m_selfLoopToOtherPseudonode;
57 
58  public:
60 
61  ReferenceEdges() : refEdges(m_selfLoopToRef) { }
62 
63  std::unordered_set<edge>& selfLoops(edge ref) { return m_refToSelfLoops[ref]; }
64 
67  void addReference(edge ref, edge selfLoop, Pseudonode* other) {
68  m_refToSelfLoops[ref].insert(selfLoop);
69  m_selfLoopToRef[selfLoop] = ref;
70  m_selfLoopToOtherPseudonode[selfLoop] = other;
71  }
72 
74  void removeFromOther(edge selfLoop) {
75  auto it = m_selfLoopToOtherPseudonode.find(selfLoop);
76  if (it != m_selfLoopToOtherPseudonode.end() && it->second != nullptr) {
77  auto& otherRefEdges = it->second->referenceEdges;
78  auto edgeIt = otherRefEdges.m_selfLoopToRef.find(selfLoop);
79  if (edgeIt != otherRefEdges.m_selfLoopToRef.end()) {
80  otherRefEdges.m_refToSelfLoops[edgeIt->second].erase(selfLoop);
81  otherRefEdges.m_selfLoopToRef.erase(edgeIt);
82  otherRefEdges.m_selfLoopToOtherPseudonode.erase(selfLoop);
83  }
84  }
85  }
86  };
87 
88 public:
91 
94 
97 
98  Pseudonode(node _graphNode, Cycle* _cycle);
99 
100  ~Pseudonode();
101 
104  void addReference(edge ref, edge selfLoop, Pseudonode* other);
105 };
106 
107 }
108 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::matching_blossom::BaseIteratorContainer
Dummy class for scoped iteration of a std::unordered_map.
Definition: utils.h:109
ogdf::matching_blossom::Pseudonode
Helper class representing a pseudonode in the Blossom algorithm.
Definition: Pseudonode.h:45
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:96
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:56
ogdf::matching_blossom::Pseudonode::ReferenceEdges
Helper class to store reference edges for all self loops.
Definition: Pseudonode.h:47
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:67
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:53
ogdf::matching_blossom::Cycle
Definition: Cycle.h:43
ogdf::matching_blossom::Pseudonode::ReferenceEdges::refEdges
ValueIteratorContainer< edge, edge > refEdges
Definition: Pseudonode.h:59
Cycle.h
Utility class representing a cycle in the Blossom algorithm.
ogdf::matching_blossom::Pseudonode::cycle
Cycle * cycle
The odd-length cycle that this pseudonode represents.
Definition: Pseudonode.h:93
ogdf::matching_blossom::Pseudonode::ReferenceEdges::selfLoops
std::unordered_set< edge > & selfLoops(edge ref)
Definition: Pseudonode.h:63
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:50
ogdf::matching_blossom::Pseudonode::graphNode
node graphNode
The node in the graph that this pseudonode is linked to.
Definition: Pseudonode.h:90
ogdf::matching_blossom::Pseudonode::ReferenceEdges::ReferenceEdges
ReferenceEdges()
Definition: Pseudonode.h:61
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:74
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:356
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233