Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
SPQRTree.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/SList.h>
37
38namespace ogdf {
39
71public:
73 enum class NodeType { SNode, PNode, RNode };
74
75 // destructor
76
77 virtual ~SPQRTree() { }
78
81
83 virtual const Graph& originalGraph() const = 0;
84
86 virtual const Graph& tree() const = 0;
87
89 virtual edge rootEdge() const = 0;
90
92 virtual node rootNode() const = 0;
93
95 virtual int numberOfSNodes() const = 0;
96
98 virtual int numberOfPNodes() const = 0;
99
101 virtual int numberOfRNodes() const = 0;
102
107 virtual NodeType typeOf(node v) const = 0;
108
110 virtual List<node> nodesOfType(NodeType t) const = 0;
111
116 virtual Skeleton& skeleton(node v) const = 0;
117
122 virtual const Skeleton& skeletonOfReal(edge e) const = 0;
123
128 virtual edge copyOfReal(edge e) const = 0;
129
135 if (m_cpV == nullptr) {
136 m_cpV = new NodeArray<node>(originalGraph(), nullptr);
137 }
138 NodeArray<node>& cpV = *m_cpV;
139
140 Gp.init(v);
141 cpRec(v, Gp);
142
143 const Skeleton& S = skeleton(v);
144
145 edge e = Gp.m_skRefEdge = S.referenceEdge();
146 if (e != nullptr) {
147 e = Gp.m_P.newEdge(cpV[S.original(e->source())], cpV[S.original(e->target())]);
148 }
149 Gp.m_vEdge = e;
150
151 while (!m_cpVAdded.empty()) {
152 cpV[m_cpVAdded.popFrontRet()] = nullptr;
153 }
154 }
155
159
164 virtual node rootTreeAt(edge e) = 0;
165
170 virtual node rootTreeAt(node v) = 0;
171
172 void directSkEdge(node vT, edge e, node src) {
173 OGDF_ASSERT(e != nullptr);
174 OGDF_ASSERT(src == e->source() || src == e->target());
175
176 if (e->source() != src) {
177 skeleton(vT).getGraph().reverseEdge(e);
178 }
179 }
180
182 Graph& M = skeleton(vT).getGraph();
183 M.reverseEdge(M.split(e));
184 }
185
186 // !@}
187
188protected:
193 virtual void cpRec(node v, PertinentGraph& Gp) const = 0;
194
197 edge eP = Gp.m_P.newEdge(cpAddNode(eOrig->source(), Gp), cpAddNode(eOrig->target(), Gp));
198 Gp.m_origE[eP] = eOrig;
199 return eP;
200 }
201
204 node& vP = (*m_cpV)[vOrig];
205 if (vP == nullptr) {
206 m_cpVAdded.pushBack(vOrig);
207 Gp.m_origV[vP = Gp.m_P.newNode()] = vOrig;
208 }
209 return vP;
210 }
211
212 // auxiliary members used for computing pertinent graphs
215};
216
217}
Declaration of class PertinentGraph.
Declaration of singly linked lists and iterators.
Declaration of class Skeleton.
Class for the representation of edges.
Definition Graph_d.h:300
node target() const
Returns the target node of the edge.
Definition Graph_d.h:338
node source() const
Returns the source node of the edge.
Definition Graph_d.h:335
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
void reverseEdge(edge e)
Reverses the edge e, i.e., exchanges source and target node.
virtual edge split(edge e)
Splits edge e into two edges introducing a new node.
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
void init()
Reinitializes the array. Associates the array with no graph.
Definition NodeArray.h:266
Class for the representation of nodes.
Definition Graph_d.h:177
Pertinent graphs of nodes in an SPQR-tree.
Singly linked lists (maintaining the length of the list).
Definition SList.h:833
Linear-time implementation of static SPQR-trees.
Definition SPQRTree.h:70
virtual List< node > nodesOfType(NodeType t) const =0
Returns the list of all nodes with type t.
virtual int numberOfSNodes() const =0
Returns the number of S-nodes in T.
virtual edge copyOfReal(edge e) const =0
Returns the skeleton edge that corresponds to the real edge e.
node cpAddNode(node vOrig, PertinentGraph &Gp) const
Add a node to Gp corresponding to vOrig if required.
Definition SPQRTree.h:203
edge cpAddEdge(edge eOrig, PertinentGraph &Gp) const
Add an edge to Gp corresponding to eOrig.
Definition SPQRTree.h:196
virtual NodeType typeOf(node v) const =0
Returns the type of node v.
void pertinentGraph(node v, PertinentGraph &Gp) const
Returns the pertinent graph of tree node v in Gp.
Definition SPQRTree.h:134
void replaceSkEdgeByPeak(node vT, edge e)
Definition SPQRTree.h:181
virtual const Graph & tree() const =0
Returns a reference to the tree T.
virtual node rootTreeAt(node v)=0
Roots T at node v and returns v.
virtual int numberOfPNodes() const =0
Returns the number of P-nodes in T.
NodeArray< node > * m_cpV
node in pertinent graph corresponding to an original node (auxiliary member)
Definition SPQRTree.h:213
virtual void cpRec(node v, PertinentGraph &Gp) const =0
Recursively performs the task of adding edges (and nodes) to the pertinent graph Gp for each involved...
SList< node > m_cpVAdded
list of added nodes (auxiliary member)
Definition SPQRTree.h:214
void directSkEdge(node vT, edge e, node src)
Definition SPQRTree.h:172
virtual const Graph & originalGraph() const =0
Returns a reference to the original graph G.
virtual int numberOfRNodes() const =0
Returns the number of R-nodes in T.
virtual edge rootEdge() const =0
Returns the edge of G at which T is rooted.
virtual Skeleton & skeleton(node v) const =0
Returns the skeleton of node v.
virtual const Skeleton & skeletonOfReal(edge e) const =0
Returns the skeleton that contains the real edge e.
NodeType
The type of a tree node in T.
Definition SPQRTree.h:73
virtual node rootNode() const =0
Returns the root node of T.
virtual ~SPQRTree()
Definition SPQRTree.h:77
virtual node rootTreeAt(edge e)=0
Roots T at edge e and returns the new root node of T.
Skeleton graphs of nodes in an SPQR-tree.
Definition Skeleton.h:59
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.