Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ExtendedNestingGraph.h
Go to the documentation of this file.
1
34#pragma once
35
39
40namespace ogdf {
41
44 m_cnClusters = 0;
45 m_cnEdges = 0;
46 }
47
49 m_cnClusters = cnClusters;
50 m_cnEdges = cnEdges;
51 }
52
53 void incEdges(int cn) { m_cnEdges += cn; }
54
55 void incClusters() { ++m_cnClusters; }
56
58 m_cnClusters += cr.m_cnClusters;
59 m_cnEdges += cr.m_cnEdges;
60 return *this;
61 }
62
64 return RCCrossings(m_cnClusters + cr.m_cnClusters, m_cnEdges + cr.m_cnEdges);
65 }
66
68 return RCCrossings(m_cnClusters - cr.m_cnClusters, m_cnEdges - cr.m_cnEdges);
69 }
70
71 bool operator<=(const RCCrossings& cr) const {
72 if (m_cnClusters == cr.m_cnClusters) {
73 return m_cnEdges <= cr.m_cnEdges;
74 } else {
75 return m_cnClusters <= cr.m_cnClusters;
76 }
77 }
78
79 bool operator<(const RCCrossings& cr) const {
80 if (m_cnClusters == cr.m_cnClusters) {
81 return m_cnEdges < cr.m_cnEdges;
82 } else {
83 return m_cnClusters < cr.m_cnClusters;
84 }
85 }
86
87 bool isZero() const { return m_cnClusters == 0 && m_cnEdges == 0; }
88
90 m_cnClusters = m_cnEdges = std::numeric_limits<int>::max();
91 return *this;
92 }
93
94 static int compare(const RCCrossings& x, const RCCrossings& y) {
95 int dc = y.m_cnClusters - x.m_cnClusters;
96 if (dc != 0) {
97 return dc;
98 }
99 return y.m_cnEdges - x.m_cnEdges;
100 }
101
104};
105
106OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const RCCrossings& cr);
107
109public:
110 enum class Type { Compound, Node, AuxNode };
111
112 struct Adjacency {
114 m_u = nullptr;
115 m_v = nullptr;
116 m_weight = 0;
117 }
118
119 Adjacency(node u, LHTreeNode* vNode, int weight = 1) {
120 m_u = u;
121 m_v = vNode;
122 m_weight = weight;
123 }
124
128
130 };
131
134 m_uc = nullptr;
135 m_u = nullptr;
136 m_cNode = nullptr;
137 m_uNode = nullptr;
138 }
139
141 m_uc = uc;
142 m_u = u;
143 m_cNode = cNode;
144 m_uNode = uNode;
145
146 m_edge = e;
147 }
148
153
155 };
156
157 // Construction
159 m_parent = nullptr;
160 m_origCluster = c;
161 m_node = nullptr;
162 m_type = Type::Compound;
163 m_down = nullptr;
164
165 m_up = up;
166 if (up) {
167 up->m_down = this;
168 }
169 }
170
171 LHTreeNode(LHTreeNode* parent, node v, Type t = Type::Node) {
172 m_parent = parent;
173 m_origCluster = nullptr;
174 m_node = v;
175 m_type = t;
176 m_up = nullptr;
177 m_down = nullptr;
178 }
179
180 // Access functions
181 bool isCompound() const { return m_type == Type::Compound; }
182
183 int numberOfChildren() const { return m_child.size(); }
184
185 const LHTreeNode* parent() const { return m_parent; }
186
187 const LHTreeNode* child(int i) const { return m_child[i]; }
188
189 cluster originalCluster() const { return m_origCluster; }
190
191 node getNode() const { return m_node; }
192
193 const LHTreeNode* up() const { return m_up; }
194
195 const LHTreeNode* down() const { return m_down; }
196
197 int pos() const { return m_pos; }
198
199 // Modification functions
200 LHTreeNode* parent() { return m_parent; }
201
202 void setParent(LHTreeNode* p) { m_parent = p; }
203
204 LHTreeNode* child(int i) { return m_child[i]; }
205
206 void initChild(int n) { m_child.init(n); }
207
208 void setChild(int i, LHTreeNode* p) { m_child[i] = p; }
209
210 void setPos();
211
212 void store() { m_storedChild = m_child; }
213
214 void restore() { m_child = m_storedChild; }
215
216 void permute() { m_child.permute(); }
217
219
224
225private:
227
231
234
237 int m_pos;
238
240};
241
244public:
245 ENGLayer() { m_root = nullptr; }
246
248
249 const LHTreeNode* root() const { return m_root; }
250
251 LHTreeNode* root() { return m_root; }
252
253 void setRoot(LHTreeNode* r) { m_root = r; }
254
255 void store();
256 void restore();
257 void permute();
258
261
262private:
264
266};
267
269
294
296public:
297 // the type of a node in this copy
298 enum class NodeType { Node, ClusterTop, ClusterBottom, Dummy, ClusterTopBottom };
299
301
302 const ClusterGraphCopy& getClusterGraph() const { return m_CGC; }
303
304 const ClusterGraph& getOriginalClusterGraph() const { return m_CGC.getOriginalClusterGraph(); }
305
306 node copy(node v) const { return m_copy[v]; }
307
308 node top(cluster cOrig) const { return m_topNode[cOrig]; }
309
310 node bottom(cluster cOrig) const { return m_bottomNode[cOrig]; }
311
312 int topRank(cluster c) const { return m_topRank[c]; }
313
314 int bottomRank(cluster c) const { return m_bottomRank[c]; }
315
316 NodeType type(node v) const { return m_type[v]; }
317
318 node origNode(node v) const { return m_origNode[v]; }
319
320 edge origEdge(edge e) const { return m_origEdge[e]; }
321
322 cluster originalCluster(node v) const { return m_CGC.original(m_CGC.clusterOf(v)); }
323
324 cluster parent(node v) const { return m_CGC.clusterOf(v); }
325
326 cluster parent(cluster c) const { return c->parent(); }
327
328 bool isVirtual(cluster c) const { return m_CGC.original(c) == nullptr; }
329
330 const List<edge>& chain(edge e) const { return m_copyEdge[e]; }
331
332 // is edge e reversed ?
333 bool isReversed(edge e) const { return e->source() != origNode(chain(e).front()->source()); }
334
335 bool isLongEdgeDummy(node v) const { return type(v) == NodeType::Dummy && v->outdeg() == 1; }
336
337 bool verticalSegment(edge e) const { return m_vertical[e]; }
338
339 int numberOfLayers() const { return m_numLayers; }
340
341 int rank(node v) const { return m_rank[v]; }
342
343 int pos(node v) const { return m_pos[v]; }
344
345 const LHTreeNode* layerHierarchyTree(int i) const { return m_layer[i].root(); }
346
347 const ENGLayer& layer(int i) const { return m_layer[i]; }
348
352 void permute();
353
355
356 int aeLevel(node v) const { return m_aeLevel[v]; }
357
358protected:
359 cluster lca(node u, node v) const;
361 LHTreeNode** vChild) const;
362
363 edge addEdge(node u, node v, bool addAlways = false);
367 bool tryEdge(node u, node v, Graph& G, NodeArray<int>& level);
368
370 void assignPos(const LHTreeNode* vNode, int& count);
371
372private:
379
380#if 0
382 const ClusterGraph &m_CG;
383#else
386#endif
387
388 // mapping: nodes in CG <-> nodes in this copy
391
392 // mapping: clusters in CG <-> nodes in this copy
393 ClusterArray<node> m_topNode; // the node representing top-most part of cluster (min. rank)
394 ClusterArray<node> m_bottomNode; // the node representing bottom-most part of cluster (max. rank)
397
398 // the type of a node in this copy
400
401 // mapping: edges in CG <-> edges in this copy
404
405 // level of each node
408
409 // the layers
411 // positions within a layer
413
414 // can an edge segment be drawn vertically?
416
417 // temporary data for "addEdge()"
421
422 // temporary data for "lca()"
429};
430
431}
Declaration and implementation of ClusterArray class.
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
Declaration and implementation of EdgeArray class.
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
Dynamic arrays indexed with clusters.
Representation of clusters in a clustered graph.
cluster parent()
Returns the parent of the cluster.
void createClusterTree(cluster cOrig)
const ClusterGraph * m_pCG
ClusterArray< cluster > m_original
ClusterArray< cluster > m_copy
ClusterGraphCopy(const ExtendedNestingGraph &H, const ClusterGraph &CG)
void setParent(node v, cluster c)
cluster original(cluster cCopy) const
const ExtendedNestingGraph * m_pH
const ClusterGraph & getOriginalClusterGraph() const
void init(const ExtendedNestingGraph &H, const ClusterGraph &CG)
cluster copy(cluster cOrig) const
Representation of clustered graphs.
Represents layer in an extended nesting graph.
void removeAuxNodes()
void simplifyAdjacencies(List< LHTreeNode::Adjacency > &adjs)
const LHTreeNode * root() const
void simplifyAdjacencies()
void setRoot(LHTreeNode *r)
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
node source() const
Returns the source node of the edge.
Definition Graph_d.h:335
void assignAeLevel(cluster c, int &count)
RCCrossings reduceCrossings(LHTreeNode *cNode, bool dirTopDown)
SListPure< cluster > m_markedClustersTree
const ClusterGraph & getOriginalClusterGraph() const
void assignPos(const LHTreeNode *vNode, int &count)
const LHTreeNode * layerHierarchyTree(int i) const
EdgeArray< List< edge > > m_copyEdge
ClusterArray< LHTreeNode * > m_markTree
ClusterArray< cluster > m_mark
bool isVirtual(cluster c) const
cluster parent(cluster c) const
const List< edge > & chain(edge e) const
bool reachable(node v, node u, SListPure< node > &successors)
const ENGLayer & layer(int i) const
LHTreeNode * lca(LHTreeNode *uNode, LHTreeNode *vNode, LHTreeNode **uChild, LHTreeNode **vChild) const
ClusterArray< node > m_bottomNode
const ClusterGraphCopy & getClusterGraph() const
edge addEdge(node u, node v, bool addAlways=false)
ClusterGraphCopy m_CGC
copy of original cluster graph
SListPure< cluster > m_markedClusters
ExtendedNestingGraph(const ClusterGraph &CG)
cluster originalCluster(node v) const
node bottom(cluster cOrig) const
bool tryEdge(node u, node v, Graph &G, NodeArray< int > &level)
node top(cluster cOrig) const
cluster lca(node u, node v) const
void moveDown(node v, const SListPure< node > &successors, NodeArray< int > &level)
void createVirtualClusters(cluster c, NodeArray< node > &vCopy, ClusterArray< node > &cCopy)
RCCrossings reduceCrossings(int i, bool dirTopDown)
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
List< ClusterCrossing > m_upperClusterCrossing
Array< LHTreeNode * > m_child
cluster originalCluster() const
void setChild(int i, LHTreeNode *p)
void removeAuxChildren()
List< Adjacency > m_upperAdj
void setParent(LHTreeNode *p)
LHTreeNode * child(int i)
const LHTreeNode * up() const
const LHTreeNode * parent() const
LHTreeNode(LHTreeNode *parent, node v, Type t=Type::Node)
const LHTreeNode * down() const
List< Adjacency > m_lowerAdj
const LHTreeNode * child(int i) const
Array< LHTreeNode * > m_storedChild
LHTreeNode(cluster c, LHTreeNode *up)
List< ClusterCrossing > m_lowerClusterCrossing
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
int outdeg() const
Returns the outdegree of the node.
Definition Graph_d.h:217
Singly linked lists.
Definition SList.h:179
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition memory.h:84
int r[]
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:978
Adjacency(node u, LHTreeNode *vNode, int weight=1)
ClusterCrossing(node uc, LHTreeNode *cNode, node u, LHTreeNode *uNode, edge e)
RCCrossings operator-(const RCCrossings &cr) const
RCCrossings operator+(const RCCrossings &cr) const
bool operator<=(const RCCrossings &cr) const
RCCrossings & setInfinity()
RCCrossings & operator+=(const RCCrossings &cr)
RCCrossings(int cnClusters, int cnEdges)
bool operator<(const RCCrossings &cr) const
static int compare(const RCCrossings &x, const RCCrossings &y)