Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

SPQRTree.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/List.h>
36 #include <ogdf/basic/SList.h>
37 #include <ogdf/basic/basic.h>
40 
41 namespace ogdf {
42 
74 public:
76  enum class NodeType { SNode, PNode, RNode };
77 
78  // destructor
79  virtual ~SPQRTree() { }
80 
81  SPQRTree() {};
82  SPQRTree(const SPQRTree& copy) = delete;
83  SPQRTree(SPQRTree&& move) = delete;
84  SPQRTree& operator=(const SPQRTree& copy) = delete;
85  SPQRTree& operator=(SPQRTree&& move) = delete;
86 
89 
91  virtual const Graph& originalGraph() const = 0;
92 
94  virtual const Graph& tree() const = 0;
95 
97  virtual edge rootEdge() const = 0;
98 
100  virtual node rootNode() const = 0;
101 
103  virtual int numberOfSNodes() const = 0;
104 
106  virtual int numberOfPNodes() const = 0;
107 
109  virtual int numberOfRNodes() const = 0;
110 
115  virtual NodeType typeOf(node v) const = 0;
116 
118  virtual List<node> nodesOfType(NodeType t) const = 0;
119 
124  virtual Skeleton& skeleton(node v) const = 0;
125 
130  virtual const Skeleton& skeletonOfReal(edge e) const = 0;
131 
136  virtual edge copyOfReal(edge e) const = 0;
137 
142  void pertinentGraph(node v, PertinentGraph& Gp) const {
143  if (m_cpV == nullptr) {
144  m_cpV = new NodeArray<node>(originalGraph(), nullptr);
145  }
146  NodeArray<node>& cpV = *m_cpV;
147 
148  Gp.init(v);
149  cpRec(v, Gp);
150 
151  const Skeleton& S = skeleton(v);
152 
153  edge e = Gp.m_skRefEdge = S.referenceEdge();
154  if (e != nullptr) {
155  e = Gp.m_P.newEdge(cpV[S.original(e->source())], cpV[S.original(e->target())]);
156  }
157  Gp.m_vEdge = e;
158 
159  while (!m_cpVAdded.empty()) {
160  cpV[m_cpVAdded.popFrontRet()] = nullptr;
161  }
162  }
163 
167 
172  virtual node rootTreeAt(edge e) = 0;
173 
178  virtual node rootTreeAt(node v) = 0;
179 
180  void directSkEdge(node vT, edge e, node src) {
181  OGDF_ASSERT(e != nullptr);
182  OGDF_ASSERT(src == e->source() || src == e->target());
183 
184  if (e->source() != src) {
185  skeleton(vT).getGraph().reverseEdge(e);
186  }
187  }
188 
190  Graph& M = skeleton(vT).getGraph();
191  M.reverseEdge(M.split(e));
192  }
193 
194  // !@}
195 
196 protected:
201  virtual void cpRec(node v, PertinentGraph& Gp) const = 0;
202 
204  edge cpAddEdge(edge eOrig, PertinentGraph& Gp) const {
205  edge eP = Gp.m_P.newEdge(cpAddNode(eOrig->source(), Gp), cpAddNode(eOrig->target(), Gp));
206  Gp.m_origE[eP] = eOrig;
207  return eP;
208  }
209 
211  node cpAddNode(node vOrig, PertinentGraph& Gp) const {
212  node& vP = (*m_cpV)[vOrig];
213  if (vP == nullptr) {
214  m_cpVAdded.pushBack(vOrig);
215  Gp.m_origV[vP = Gp.m_P.newNode()] = vOrig;
216  }
217  return vP;
218  }
219 
220  // auxiliary members used for computing pertinent graphs
223 };
224 
225 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
ogdf::SPQRTree::m_cpVAdded
SList< node > m_cpVAdded
list of added nodes (auxiliary member)
Definition: SPQRTree.h:222
PertinentGraph.h
Declaration of class PertinentGraph.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::Graph::split
virtual edge split(edge e)
Splits edge e into two edges introducing a new node.
ogdf::PertinentGraph::m_P
Graph m_P
actual graph
Definition: PertinentGraph.h:119
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::SPQRTree
Linear-time implementation of static SPQR-trees.
Definition: SPQRTree.h:73
ogdf::Graph::reverseEdge
void reverseEdge(edge e)
Reverses the edge e, i.e., exchanges source and target node.
Skeleton.h
Declaration of class Skeleton.
Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
ogdf::SPQRTree::cpAddEdge
edge cpAddEdge(edge eOrig, PertinentGraph &Gp) const
Add an edge to Gp corresponding to eOrig.
Definition: SPQRTree.h:204
ogdf::Skeleton::referenceEdge
edge referenceEdge() const
Returns the reference edge of S in M.
Definition: Skeleton.h:87
ogdf::SPQRTree::replaceSkEdgeByPeak
void replaceSkEdgeByPeak(node vT, edge e)
Definition: SPQRTree.h:189
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243
SList.h
Declaration of singly linked lists and iterators.
ogdf::PertinentGraph::m_skRefEdge
edge m_skRefEdge
reference edge (in skeleton(m_vT))
Definition: PertinentGraph.h:121
ogdf::PertinentGraph::m_vEdge
edge m_vEdge
reference edge (in m_P)
Definition: PertinentGraph.h:120
ogdf::PertinentGraph::m_origV
NodeArray< node > m_origV
corresp.
Definition: PertinentGraph.h:123
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::EdgeStandardType::tree
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
ogdf::SPQRTree::pertinentGraph
void pertinentGraph(node v, PertinentGraph &Gp) const
Returns the pertinent graph of tree node v in Gp.
Definition: SPQRTree.h:142
ogdf::SPQRTree::SPQRTree
SPQRTree()
Definition: SPQRTree.h:81
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::SPQRTree::NodeType
NodeType
The type of a tree node in T.
Definition: SPQRTree.h:76
ogdf::Graph::newNode
node newNode(int index=-1)
Creates a new node and returns it.
Definition: Graph_d.h:1064
ogdf::PertinentGraph::init
void init(node vT)
Initialization of a pertinent graph of tree node vT.
Definition: PertinentGraph.h:74
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
List.h
Declaration of doubly linked lists and iterators.
ogdf::Skeleton
Skeleton graphs of nodes in an SPQR-tree.
Definition: Skeleton.h:60
ogdf::Skeleton::original
virtual node original(node v) const =0
Returns the vertex in the original graph G that corresponds to v.
ogdf::PertinentGraph
Pertinent graphs of nodes in an SPQR-tree.
Definition: PertinentGraph.h:58
ogdf::SPQRTree::~SPQRTree
virtual ~SPQRTree()
Definition: SPQRTree.h:79
ogdf::SPQRTree::cpAddNode
node cpAddNode(node vOrig, PertinentGraph &Gp) const
Add a node to Gp corresponding to vOrig if required.
Definition: SPQRTree.h:211
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
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::SPQRTree::m_cpV
NodeArray< node > * m_cpV
node in pertinent graph corresponding to an original node (auxiliary member)
Definition: SPQRTree.h:221
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::PertinentGraph::m_origE
EdgeArray< edge > m_origE
corresp.
Definition: PertinentGraph.h:124
ogdf::SPQRTree::directSkEdge
void directSkEdge(node vT, edge e, node src)
Definition: SPQRTree.h:180