Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

DynamicSPQRForest.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 
37 namespace ogdf {
38 
50 public:
52  enum class TNodeType {
53  SComp = static_cast<int>(
55  PComp = static_cast<int>(
57  RComp = static_cast<int>(
59  };
60 
61 protected:
63  mutable Graph m_T;
64 
73 
83 
93 
104 
108 
111 
114 
118 
122 
125 
129 
133 
137 
139  void init();
140 
151  inline node newSPQRNode(node vB, const TNodeType spqrNodeType) const {
152  node vT = m_T.newNode();
153  m_tNode_owner[vT] = vT;
154  m_tNode_type[vT] = spqrNodeType;
155  m_tNode_hEdges[vT] = new List<edge>;
156 
157  if (spqrNodeType == TNodeType::PComp) {
158  m_bNode_numP[vB]++;
159  } else if (spqrNodeType == TNodeType::SComp) {
160  m_bNode_numS[vB]++;
161  } else if (spqrNodeType == TNodeType::RComp) {
162  m_bNode_numR[vB]++;
163  }
164 
165  return vT;
166  }
167 
174  inline void addHEdge(edge eH, node vT) const {
175  m_hEdge_position[eH] = m_tNode_hEdges[vT]->pushBack(eH);
176  m_hEdge_tNode[eH] = vT;
177  }
178 
186  inline void delHEdge(edge eH, node vT) const {
187  m_tNode_hEdges[vT]->del(m_hEdge_position[eH]);
188  m_H.delEdge(eH);
189  }
190 
198  inline edge newTwinEdge(edge eH, node vT) const {
199  edge fH = m_H.newEdge(eH->source(), eH->target());
200  addHEdge(fH, vT);
201  m_hEdge_twinEdge[eH] = fH;
202  m_hEdge_twinEdge[fH] = eH;
203  return fH;
204  }
205 
219  node uniteSPQR(node vB, node sT, node tT);
220 
228  node findSPQR(node vT) const;
230 
242  node findNCASPQR(node sT, node tT) const;
243 
257  SList<node>& findPathSPQR(node sH, node tH, node& rT) const;
259 
273  edge updateInsertedEdgeSPQR(node vB, edge eG);
274 
288  node updateInsertedNodeSPQR(node vB, edge eG, edge fG);
290 
291 public:
302  explicit DynamicSPQRForest(Graph& G, bool not_connected = false)
303  : DynamicSPQRForest(G, nullptr, not_connected) { }
304 
316  DynamicSPQRForest(Graph& G, node vG, bool not_connected = false)
317  : DynamicBCTree(G, vG, not_connected) {
318  init();
319  }
320 
322  for (auto pList : m_tNode_hEdges) {
323  delete pList;
324  }
325  }
326 
338  node spqrproper(edge eH) const { return m_hEdge_tNode[eH] = findSPQR(m_hEdge_tNode[eH]); }
339 
355  void createSPQR(node vB) const;
356 
364  node spqrroot(node vB) const { return m_bNode_SPQR[vB]; }
365 
373  int numberOfSNodes(node vB) const { return m_bNode_numS[vB]; }
374 
382  int numberOfPNodes(node vB) const { return m_bNode_numP[vB]; }
383 
391  int numberOfRNodes(node vB) const { return m_bNode_numR[vB]; }
392 
394  const Graph& spqrTree() const { return m_T; }
395 
397  node spqrParent(node vT) const {
398  edge p_e = m_tNode_hRefEdge[vT];
399  if (p_e == nullptr) {
400  return nullptr;
401  }
402  edge p_et = twinEdge(p_e);
403  OGDF_ASSERT(p_et != nullptr);
404  node p = m_hEdge_tNode[p_et];
405  OGDF_ASSERT(p != nullptr);
406  OGDF_ASSERT(m_T.searchEdge(vT, p) != nullptr);
407  return p;
408  }
409 
411  edge spqrParentEdge(node vT) const { return m_tNode_hRefEdge[vT]; }
412 
414  node spqrNodeOf(edge eH) const { return m_hEdge_tNode[eH]; }
415 
423  edge twinEdge(edge eH) const { return m_hEdge_twinEdge[eH]; }
424 
426 
437  TNodeType typeOfTNode(node vT) const { return m_tNode_type[vT]; }
438 
450  const List<edge>& hEdgesSPQR(node vT) const { return *m_tNode_hEdges[vT]; }
451 
464  SList<node>& findPathSPQR(node sH, node tH) const;
465 
481  edge virtualEdge(node vT, node wT) const;
483 
497  edge updateInsertedEdge(edge eG) override;
498 
513  node updateInsertedNode(edge eG, edge fG) override;
514 
516 };
517 
518 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, DynamicSPQRForest::TNodeType t);
519 
520 }
ogdf::DynamicSPQRForest::typeOfTNode
TNodeType typeOfTNode(node vT) const
Definition: DynamicSPQRForest.h:437
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::DynamicSPQRForest::DynamicSPQRForest
DynamicSPQRForest(Graph &G, bool not_connected=false)
A constructor.
Definition: DynamicSPQRForest.h:302
ogdf::DynamicSPQRForest::m_htogc
NodeArray< node > m_htogc
Auxiliary array used by createSPQR().
Definition: DynamicSPQRForest.h:132
ogdf::DynamicSPQRForest::newTwinEdge
edge newTwinEdge(edge eH, node vT) const
Creates a twin edge for eH, adds it to vT and returns it.
Definition: DynamicSPQRForest.h:198
ogdf::DynamicSPQRForest::m_tNode_hEdges
NodeArray< List< edge > * > m_tNode_hEdges
Lists of real and virtual edges belonging to SPQR-tree vertices.
Definition: DynamicSPQRForest.h:116
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
SPQRTree.h
Declaration of class SPQRTree.
ogdf::DynamicSPQRForest::DynamicSPQRForest
DynamicSPQRForest(Graph &G, node vG, bool not_connected=false)
A constructor.
Definition: DynamicSPQRForest.h:316
ogdf::DynamicSPQRForest::m_bNode_numS
NodeArray< int > m_bNode_numS
The numbers of S-components.
Definition: DynamicSPQRForest.h:82
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:833
ogdf::DynamicSPQRForest::TNodeType
TNodeType
Enumeration type for characterizing the SPQR-tree-vertices.
Definition: DynamicSPQRForest.h:52
ogdf::DynamicSPQRForest::m_hEdge_position
EdgeArray< ListIterator< edge > > m_hEdge_position
The positions of real and virtual edges in their m_tNode_hEdges lists.
Definition: DynamicSPQRForest.h:121
ogdf::DynamicSPQRForest::m_hEdge_tNode
EdgeArray< node > m_hEdge_tNode
The SPQR-tree-vertices which the real and virtual edges are belonging to.
Definition: DynamicSPQRForest.h:124
ogdf::DynamicSPQRForest::numberOfPNodes
int numberOfPNodes(node vB) const
Returns the number of P-nodes in the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:382
ogdf::DynamicSPQRForest::hEdgesSPQR
const List< edge > & hEdgesSPQR(node vT) const
Returns a linear list of the edges in m_H belonging to the triconnected component represented by a gi...
Definition: DynamicSPQRForest.h:450
ogdf::DynamicSPQRForest::spqrParentEdge
edge spqrParentEdge(node vT) const
Returns the virtual edge leading to the parents of a SPQR-tree vertex, or nullptr if vT is a root.
Definition: DynamicSPQRForest.h:411
ogdf::DynamicSPQRForest::spqrproper
node spqrproper(edge eH) const
Definition: DynamicSPQRForest.h:338
ogdf::DynamicSPQRForest::numberOfSNodes
int numberOfSNodes(node vB) const
Returns the number of S-nodes in the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:373
ogdf::DynamicSPQRForest::~DynamicSPQRForest
~DynamicSPQRForest()
Definition: DynamicSPQRForest.h:321
ogdf::DynamicSPQRForest::addHEdge
void addHEdge(edge eH, node vT) const
Adds edge eH to a vertex vT of the SPQRForest.
Definition: DynamicSPQRForest.h:174
ogdf::DynamicSPQRForest::spqrroot
node spqrroot(node vB) const
Returns the root of the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:364
ogdf::DynamicSPQRForest::delHEdge
void delHEdge(edge eH, node vT) const
Deletes edge eH from m_H and removes its connection to a vertex vT of the SPQRForest.
Definition: DynamicSPQRForest.h:186
ogdf::DynamicSPQRForest::newSPQRNode
node newSPQRNode(node vB, const TNodeType spqrNodeType) const
Creates a new node in the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:151
ogdf::SPQRTree::NodeType::PNode
@ PNode
ogdf::DynamicSPQRForest::spqrNodeOf
node spqrNodeOf(edge eH) const
The SPQR-tree-vertex which a real or virtual edge eH belongs to, if the SPQR-tree has been created us...
Definition: DynamicSPQRForest.h:414
ogdf::DynamicSPQRForest::twinEdge
edge twinEdge(edge eH) const
Returns the twin edge of a given edge of m_H, if it is virtual, or nullptr, if it is real.
Definition: DynamicSPQRForest.h:423
ogdf::DynamicSPQRForest
Dynamic SPQR-forest.
Definition: DynamicSPQRForest.h:49
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:978
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::List< edge >
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::DynamicSPQRForest::spqrParent
node spqrParent(node vT) const
Returns the parent node of a node of the SPQR-tree Graph, or nullptr if vT is a root.
Definition: DynamicSPQRForest.h:397
ogdf::DynamicSPQRForest::m_tNode_isMarked
NodeArray< bool > m_tNode_isMarked
Auxiliary array used by findNCASPQR()
Definition: DynamicSPQRForest.h:135
ogdf::DynamicSPQRForest::numberOfRNodes
int numberOfRNodes(node vB) const
Returns the number of R-nodes in the SPQR-tree for a given B-component of the BC-tree.
Definition: DynamicSPQRForest.h:391
ogdf::DynamicSPQRForest::m_bNode_SPQR
NodeArray< node > m_bNode_SPQR
Definition: DynamicSPQRForest.h:72
ogdf::DynamicSPQRForest::m_bNode_numP
NodeArray< int > m_bNode_numP
The numbers of P-components.
Definition: DynamicSPQRForest.h:92
ogdf::DynamicSPQRForest::m_hEdge_twinEdge
EdgeArray< edge > m_hEdge_twinEdge
The partners of virtual edges (nullptr if real).
Definition: DynamicSPQRForest.h:127
ogdf::DynamicSPQRForest::m_T
Graph m_T
A Graph structure containing all SPQR-trees.
Definition: DynamicSPQRForest.h:63
ogdf::graphics::init
void init()
Definition: graphics.h:446
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::DynamicSPQRForest::m_tNode_hRefEdge
NodeArray< edge > m_tNode_hRefEdge
The virtual edges leading to the parents of the SPQR-tree vertices.
Definition: DynamicSPQRForest.h:113
DynamicBCTree.h
Declaration of class DynamicBCTree.
ogdf::Graph::newNode
node newNode(int index=-1)
Creates a new node and returns it.
Definition: Graph_d.h:1056
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::Graph::searchEdge
edge searchEdge(node v, node w, bool directed=false) const
Searches and returns an edge connecting nodes v and w in time O( min(deg(v ), deg(w ))).
ogdf::DynamicSPQRForest::m_tNode_type
NodeArray< TNodeType > m_tNode_type
The types of the SPQR-tree-vertices.
Definition: DynamicSPQRForest.h:107
ogdf::SPQRTree::NodeType::RNode
@ RNode
ogdf::DynamicSPQRForest::m_bNode_numR
NodeArray< int > m_bNode_numR
The numbers of R-components.
Definition: DynamicSPQRForest.h:102
ogdf::DynamicSPQRForest::spqrTree
const Graph & spqrTree() const
Returns the SPQR-tree graph.
Definition: DynamicSPQRForest.h:394
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::DynamicBCTree
Dynamic BC-trees.
Definition: DynamicBCTree.h:54
ogdf::DynamicSPQRForest::m_tNode_owner
NodeArray< node > m_tNode_owner
The owners of the SPQR-tree-vertices in the UNION/FIND structure.
Definition: DynamicSPQRForest.h:110
ogdf::SPQRTree::NodeType::SNode
@ SNode
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709