Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
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
38namespace ogdf {
39
40class OverlappingGraphCopies;
41
42// room for improvement: common interface with GraphCopyBase, add auto-linking ::insert method
46
50
51 void unmap();
52
53public:
55 : m_pOGC(&mPOgc), m_vOrig(*this, nullptr), m_eOrig(*this, nullptr) { }
56
57 ~OverlappingGraphCopy() override { unmap(); }
58
60
62
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
161
162 using Graph::newNode;
163
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
208
209 const Graph* m_G;
212
213public:
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}
Includes declaration of graph class.
RegisteredMultiArray for the usual GraphArray classes.
Simple, safe base classes for C++ observables and observers.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition Graph_d.h:161
bool isSource() const
Returns true iff this is the source adjacency entry of the corresponding edge.
Definition Graph_d.h:480
Class for the representation of edges.
Definition Graph_d.h:364
adjEntry adjSource() const
Returns the corresponding adjacancy entry at source node.
Definition Graph_d.h:408
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition Graph_d.h:441
adjEntry adjTarget() const
Returns the corresponding adjacancy entry at target node.
Definition Graph_d.h:411
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Class for the representation of nodes.
Definition Graph_d.h:241
const Graph * graphOf() const
Returns the graph containing this node (debug only).
Definition Graph_d.h:345
The manager class for multiple OverlappingGraphCopy instances of the same graph.
const EA::EntryType & copies(edge e) const
Version of GraphCopySimple that may efficiently share some overlap with other instances of the same o...
bool isDummy(node v) const
Returns true iff v has no corresponding node in the original graph.
void delEdge(edge e) override
Removes edge e.
node copy(node v) const
Returns the node in the graph copy corresponding to v.
const Graph & original() const
Returns a reference to the original graph.
bool isDummy(edge e) const
Returns true iff e has no corresponding edge in the original graph.
node newNode(node vOrig)
Creates a new node in the graph copy with original node vOrig.
OverlappingGraphCopy(OverlappingGraphCopies &mPOgc)
edge copy(edge e) const
Returns the edge in the graph copy corresponding to e.
NodeArray< node > m_vOrig
The corresponding node in the original graph.
EdgeArray< edge > m_eOrig
The corresponding edge in the original graph.
OverlappingGraphCopies * m_pOGC
The master instance.
edge newEdge(edge eOrig)
Creates a new edge in the graph copy with original edge eOrig.
node original(node v) const
Returns the node in the original graph corresponding to v.
adjEntry original(adjEntry adj) const
Returns the adjacency entry in the original graph corresponding to adj.
edge original(edge e) const
Returns the edge in the original graph corresponding to e.
void clear() override
Removes all nodes and all edges from the graph.
adjEntry copy(adjEntry adj) const
Returns the adjacency entry in the graph copy corresponding to adj.
void delNode(node v) override
Removes node v.
void init(const Base *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
Data structure for two-dimensional mappings that are sparse in the second dimension.
EntryType & get_all(const Key1 &k1)
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_NO_COPY(cls)
Explicitly disables (deletes) copy construction and assignment for class cls.
Definition copy_move.h:37
#define OGDF_NO_MOVE(cls)
Explicitly disables (deletes) move construction and assignment for class cls.
Definition copy_move.h:42
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.
A wrapper around std::map that uses a constant-size array (or only a single value) plus linear search...