Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
StaticSPQRTree.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/List.h>
37#include <ogdf/basic/basic.h>
41
42namespace ogdf {
43class PertinentGraph;
44class Triconnectivity;
45
79class OGDF_EXPORT StaticSPQRTree : public virtual SPQRTree {
80public:
81 friend class StaticSkeleton;
82
83 // constructors
84
90 explicit StaticSPQRTree(const Graph& G) : m_skOf(G), m_copyOf(G) {
91 OGDF_ASSERT(G.numberOfEdges() > 0);
92 m_pGraph = &G;
93 init(G.firstEdge());
94 }
95
101 StaticSPQRTree(const Graph& G, edge e) : m_skOf(G), m_copyOf(G) {
102 m_pGraph = &G;
103 init(e);
104 }
105
111 StaticSPQRTree(const Graph& G, Triconnectivity& tricComp) : m_skOf(G), m_copyOf(G) {
112 m_pGraph = &G;
113 init(G.firstEdge(), tricComp);
114 }
115
118
121
123 const Graph& originalGraph() const override { return *m_pGraph; }
124
126 const Graph& tree() const override { return m_tree; }
127
129 edge rootEdge() const override { return m_rootEdge; }
130
132 node rootNode() const override { return m_rootNode; }
133
135 int numberOfSNodes() const override { return m_numS; }
136
138 int numberOfPNodes() const override { return m_numP; }
139
141 int numberOfRNodes() const override { return m_numR; }
142
147 NodeType typeOf(node v) const override { return m_type[v]; }
148
150 List<node> nodesOfType(NodeType t) const override;
151
156 Skeleton& skeleton(node v) const override { return *m_sk[v]; }
157
162 edge skeletonEdgeSrc(edge e) const { return m_skEdgeSrc[e]; }
163
168 edge skeletonEdgeTgt(edge e) const { return m_skEdgeTgt[e]; }
169
174 const Skeleton& skeletonOfReal(edge e) const override { return *m_skOf[e]; }
175
180 edge copyOfReal(edge e) const override { return m_copyOf[e]; }
181
185
190 node rootTreeAt(edge e) override;
191
196 node rootTreeAt(node v) override;
197
199
200protected:
202 void init(edge e);
203
205 void init(edge eRef, Triconnectivity& tricComp);
206
208 void rootRec(node v, edge ef);
209
214 void cpRec(node v, PertinentGraph& Gp) const override {
215 const Skeleton& S = skeleton(v);
216
217 for (edge e : S.getGraph().edges) {
218 edge eOrig = S.realEdge(e);
219 if (eOrig != nullptr) {
220 cpAddEdge(eOrig, Gp);
221 }
222 }
223
224 for (adjEntry adj : v->adjEntries) {
225 node w = adj->theEdge()->target();
226 if (w != v) {
227 cpRec(w, Gp);
228 }
229 }
230 }
231
234
237
238 int m_numS;
239 int m_numP;
240 int m_numR;
241
243
247
250};
251
252}
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Declaration of class SPQRTree.
Declaration of class Skeleton.
Declaration of class StaticSkeleton.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
Class for the representation of edges.
Definition Graph_d.h:364
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition Graph_d.h:932
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Definition Graph_d.h:272
Pertinent graphs of nodes in an SPQR-tree.
Linear-time implementation of static SPQR-trees.
Definition SPQRTree.h:73
NodeType
The type of a tree node in T.
Definition SPQRTree.h:76
Skeleton graphs of nodes in an SPQR-tree.
Definition Skeleton.h:60
virtual edge realEdge(edge e) const =0
Returns the real edge that corresponds to skeleton edge e.
const Graph & getGraph() const
Returns a reference to the skeleton graph M.
Definition Skeleton.h:90
Linear-time implementation of static SPQR-trees.
node rootTreeAt(node v) override
Roots T at node v and returns v.
node rootTreeAt(edge e) override
Roots T at edge e and returns the new root node of T.
EdgeArray< edge > m_skEdgeSrc
corresponding edge in skeleton(source(e))
void cpRec(node v, PertinentGraph &Gp) const override
Recursively performs the task of adding edges (and nodes) to the pertinent graph Gp for each involved...
node rootNode() const override
Returns the root node of T.
NodeArray< NodeType > m_type
type of nodes in T
int m_numR
number of R-nodes
StaticSPQRTree(const Graph &G)
Creates an SPQR tree T for graph G rooted at the first edge of G.
const Graph & tree() const override
Returns a reference to the tree T.
int numberOfRNodes() const override
Returns the number of R-nodes in T.
Skeleton & skeleton(node v) const override
Returns the skeleton of node v.
const Graph & originalGraph() const override
Returns a reference to the original graph G.
const Skeleton & skeletonOfReal(edge e) const override
Returns the skeleton that contains the real edge e.
EdgeArray< edge > m_skEdgeTgt
corresponding edge in skeleton(target(e))
edge skeletonEdgeSrc(edge e) const
Returns the edge in skeleton of source(e) that corresponds to tree edge e.
int numberOfPNodes() const override
Returns the number of P-nodes in T.
void init(edge eRef, Triconnectivity &tricComp)
Initialization (called by constructor).
EdgeArray< edge > m_copyOf
skeleton edge corresponding to real edge e
int numberOfSNodes() const override
Returns the number of S-nodes in T.
void init(edge e)
Initialization (called by constructor).
StaticSPQRTree(const Graph &G, edge e)
Creates an SPQR tree T for graph G rooted at the edge e.
edge rootEdge() const override
Returns the edge of G at which T is rooted.
node m_rootNode
root node of T
NodeType typeOf(node v) const override
Returns the type of node v.
edge m_rootEdge
edge of G at which T is rooted
StaticSPQRTree(const Graph &G, Triconnectivity &tricComp)
Creates an SPQR tree T for graph G rooted at the first edge of G.
void rootRec(node v, edge ef)
Recursively performs rooting of tree.
int m_numP
number of P-nodes
edge copyOfReal(edge e) const override
Returns the skeleton edge that corresponds to the real edge e.
edge skeletonEdgeTgt(edge e) const
Returns the edge in skeleton of target(e) that corresponds to tree edge e.
const Graph * m_pGraph
pointer to original graph
EdgeArray< StaticSkeleton * > m_skOf
skeleton containing real edge e
int m_numS
number of S-nodes
NodeArray< StaticSkeleton * > m_sk
pointer to skeleton of a node in T
List< node > nodesOfType(NodeType t) const override
Returns the list of all nodes with type t.
~StaticSPQRTree()
Destructor.
Graph m_tree
underlying tree graph
Skeleton graphs of nodes in a static SPQR-tree.
realizes Hopcroft/Tarjan algorithm for finding the triconnected components of a biconnected multi-gra...
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_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.