Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

OverlappingGraphCopies.h
Go to the documentation of this file.
1 
31 #pragma once
32 
33 #include <ogdf/basic/Graph.h>
34 #include <ogdf/basic/Observer.h>
35 #include <ogdf/basic/basic.h>
37 
38 namespace ogdf {
39 
40 class OverlappingGraphCopies;
41 
42 // room for improvement: common interface with GraphCopyBase, add auto-linking ::insert method
45  friend class OverlappingGraphCopies;
46 
50 
51  void unmap();
52 
53 public:
55  : m_pOGC(&mPOgc), m_vOrig(*this, nullptr), m_eOrig(*this, nullptr) { }
56 
57  ~OverlappingGraphCopy() override { unmap(); }
58 
60 
62 
63 
64  const OverlappingGraphCopies& master() const { return *m_pOGC; }
65 
67  const Graph& original() const;
68 
75  node original(node v) const {
76  node ov = m_vOrig[v];
77  OGDF_ASSERT(ov == nullptr || ov->graphOf() == &original());
78  return ov;
79  }
80 
87  edge original(edge e) const {
88  edge oe = m_eOrig[e];
89  OGDF_ASSERT(oe == nullptr || oe->graphOf() == &original());
90  return oe;
91  }
92 
104  edge f = original(adj->theEdge());
105  return adj->isSource() ? f->adjSource() : f->adjTarget();
106  }
107 
114  node copy(node v) const;
115 
122  edge copy(edge e) const;
123 
135  adjEntry copy(adjEntry adj) const {
136  edge f = copy(adj->theEdge());
137  if (f == nullptr) {
138  return nullptr;
139  }
140  return adj->isSource() ? f->adjSource() : f->adjTarget();
141  }
142 
147  bool isDummy(node v) const { return m_vOrig[v] == nullptr; }
148 
153  bool isDummy(edge e) const { return m_eOrig[e] == nullptr; }
154 
160  node newNode(node vOrig);
161 
162  using Graph::newNode;
163 
169  edge newEdge(edge eOrig);
170 
171  using Graph::newEdge;
172 
178  void delEdge(edge e) override;
179 
185  void delNode(node v) override;
186 
187  void clear() override {
188  unmap();
189  Graph::clear();
190  }
191 
193  m_pOGC = nullptr;
194  m_vOrig.init();
195  m_eOrig.init();
196  }
197 };
198 
200 
205  friend class OverlappingGraphCopy;
208 
209  const Graph* m_G;
212 
213 public:
214  explicit OverlappingGraphCopies(const Graph& G)
215  : m_G(&G), m_node_copies(G), m_edge_copies(G) { }
216 
218 
220 
221  const NA::EntryType& copies(node n) const { return m_node_copies.get_all(n); }
222 
223  const EA::EntryType& copies(edge e) const { return m_edge_copies.get_all(e); }
224 
225  const Graph* constGraph() const { return m_G; }
226 };
227 
228 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::OverlappingGraphCopy::breakLinkForMasterDeconstruction
void breakLinkForMasterDeconstruction()
Definition: OverlappingGraphCopies.h:192
Graph.h
Includes declaration of graph class.
ogdf::OverlappingGraphCopy::~OverlappingGraphCopy
~OverlappingGraphCopy() override
Definition: OverlappingGraphCopies.h:57
ogdf::OverlappingGraphCopies
The manager class for multiple OverlappingGraphCopy instances of the same graph.
Definition: OverlappingGraphCopies.h:204
GraphMultiArray.h
RegisteredMultiArray for the usual GraphArray classes. TODO should be moved to a central location.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::OverlappingGraphCopy::m_pOGC
OverlappingGraphCopies * m_pOGC
The master instance.
Definition: OverlappingGraphCopies.h:47
ogdf::OverlappingGraphCopy::original
adjEntry original(adjEntry adj) const
Returns the adjacency entry in the original graph corresponding to adj.
Definition: OverlappingGraphCopies.h:103
ogdf::OverlappingGraphCopy::clear
void clear() override
Removes all nodes and all edges from the graph.
Definition: OverlappingGraphCopies.h:187
Observer.h
Simple, safe base classes for C++ observables and observers.
OGDF_NO_MOVE
#define OGDF_NO_MOVE(cls)
Explicitly disables (deletes) move construction and assignment for class cls.
Definition: copy_move.h:42
ogdf::OverlappingGraphCopies::m_edge_copies
EA m_edge_copies
Definition: OverlappingGraphCopies.h:211
ogdf::OverlappingGraphCopies::m_node_copies
NA m_node_copies
Definition: OverlappingGraphCopies.h:210
ogdf::OverlappingGraphCopies::OverlappingGraphCopies
OverlappingGraphCopies(const Graph &G)
Definition: OverlappingGraphCopies.h:214
ogdf::UsuallySmallMap
A wrapper around std::map that uses a constant-size array (or only a single value) plus linear search...
Definition: RegisteredMultiArray.h:52
ogdf::OverlappingGraphCopy
Version of GraphCopySimple that may efficiently share some overlap with other instances of the same o...
Definition: OverlappingGraphCopies.h:44
ogdf::OverlappingGraphCopies::m_G
const Graph * m_G
Definition: OverlappingGraphCopies.h:209
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::AdjElement::isSource
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Definition: Graph_d.h:479
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:160
ogdf::Graph::clear
virtual void clear()
Removes all nodes and all edges from the graph.
Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
ogdf::EdgeElement::graphOf
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition: Graph_d.h:440
ogdf::RegisteredMultiArray
Data structure for two-dimensional mappings that are sparse in the second dimension.
Definition: RegisteredMultiArray.h:269
ogdf::OverlappingGraphCopy::m_vOrig
NodeArray< node > m_vOrig
The corresponding node in the original graph.
Definition: OverlappingGraphCopies.h:48
ogdf::OverlappingGraphCopies::constGraph
const Graph * constGraph() const
Definition: OverlappingGraphCopies.h:225
OGDF_NO_COPY
#define OGDF_NO_COPY(cls)
Explicitly disables (deletes) copy construction and assignment for class cls.
Definition: copy_move.h:37
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::EdgeElement::adjSource
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition: Graph_d.h:407
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::OverlappingGraphCopy::original
edge original(edge e) const
Returns the edge in the original graph corresponding to e.
Definition: OverlappingGraphCopies.h:87
ogdf::OverlappingGraphCopy::copy
adjEntry copy(adjEntry adj) const
Returns the adjacency entry in the graph copy corresponding to adj.
Definition: OverlappingGraphCopies.h:135
ogdf::EdgeElement::adjTarget
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition: Graph_d.h:410
ogdf::RegisteredMultiArray::get_all
EntryType & get_all(const Key1 &k1)
Definition: RegisteredMultiArray.h:291
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::Graph::newNode
node newNode(int index=-1)
Creates a new node and returns it.
Definition: Graph_d.h:1064
ogdf::OverlappingGraphCopy::isDummy
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
Definition: OverlappingGraphCopies.h:147
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::NodeElement::graphOf
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition: Graph_d.h:344
ogdf::RegisteredArray< GraphRegistry< Key >, Value, WithDefault, Graph >::init
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Definition: RegisteredArray.h:858
ogdf::OverlappingGraphCopy::OverlappingGraphCopy
OverlappingGraphCopy(OverlappingGraphCopies &mPOgc)
Definition: OverlappingGraphCopies.h:54
ogdf::OverlappingGraphCopy::original
node original(node v) const
Returns the node in the original graph corresponding to v.
Definition: OverlappingGraphCopies.h:75
ogdf::Graph::newEdge
edge newEdge(node v, node w, int index=-1)
Creates a new edge (v,w) and returns it.
Definition: Graph_d.h:1083
ogdf::OverlappingGraphCopy::isDummy
bool isDummy(edge e) const
Returns true iff e has no corresponding edge in the original graph.
Definition: OverlappingGraphCopies.h:153
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::OverlappingGraphCopies::copies
const EA::EntryType & copies(edge e) const
Definition: OverlappingGraphCopies.h:223
ogdf::OverlappingGraphCopy::m_eOrig
EdgeArray< edge > m_eOrig
The corresponding edge in the original graph.
Definition: OverlappingGraphCopies.h:49