Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

DynamicSPQRForest.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/basic.h>
39 
40 #include <iosfwd>
41 
42 namespace ogdf {
43 template<class E>
44 class SList;
45 
57 public:
59  enum class TNodeType {
60  SComp = static_cast<int>(
62  PComp = static_cast<int>(
64  RComp = static_cast<int>(
66  };
67 
68 protected:
70  mutable Graph m_T;
71 
80 
90 
100 
111 
115 
118 
121 
125 
129 
132 
136 
140 
144 
146  void init();
147 
158  inline node newSPQRNode(node vB, const TNodeType spqrNodeType) const {
159  node vT = m_T.newNode();
160  m_tNode_owner[vT] = vT;
161  m_tNode_type[vT] = spqrNodeType;
162  m_tNode_hEdges[vT] = new List<edge>;
163 
164  if (spqrNodeType == TNodeType::PComp) {
165  m_bNode_numP[vB]++;
166  } else if (spqrNodeType == TNodeType::SComp) {
167  m_bNode_numS[vB]++;
168  } else if (spqrNodeType == TNodeType::RComp) {
169  m_bNode_numR[vB]++;
170  }
171 
172  return vT;
173  }
174 
181  inline void addHEdge(edge eH, node vT) const {
182  m_hEdge_position[eH] = m_tNode_hEdges[vT]->pushBack(eH);
183  m_hEdge_tNode[eH] = vT;
184  }
185 
193  inline void delHEdge(edge eH, node vT) const {
194  m_tNode_hEdges[vT]->del(m_hEdge_position[eH]);
195  m_H.delEdge(eH);
196  }
197 
205  inline edge newTwinEdge(edge eH, node vT) const {
206  edge fH = m_H.newEdge(eH->source(), eH->target());
207  addHEdge(fH, vT);
208  m_hEdge_twinEdge[eH] = fH;
209  m_hEdge_twinEdge[fH] = eH;
210  return fH;
211  }
212 
226  node uniteSPQR(node vB, node sT, node tT);
227 
235  node findSPQR(node vT) const;
237 
249  node findNCASPQR(node sT, node tT) const;
250 
264  SList<node>& findPathSPQR(node sH, node tH, node& rT) const;
266 
280  edge updateInsertedEdgeSPQR(node vB, edge eG);
281 
295  node updateInsertedNodeSPQR(node vB, edge eG, edge fG);
297 
298 public:
309  explicit DynamicSPQRForest(Graph& G, bool not_connected = false)
310  : DynamicSPQRForest(G, nullptr, not_connected) { }
311 
323  DynamicSPQRForest(Graph& G, node vG, bool not_connected = false)
324  : DynamicBCTree(G, vG, not_connected) {
325  init();
326  }
327 
329  for (auto pList : m_tNode_hEdges) {
330  delete pList;
331  }
332  }
333 
345  node spqrproper(edge eH) const { return m_hEdge_tNode[eH] = findSPQR(m_hEdge_tNode[eH]); }
346 
362  void createSPQR(node vB) const;
363 
371  node spqrroot(node vB) const { return m_bNode_SPQR[vB]; }
372 
380  int numberOfSNodes(node vB) const { return m_bNode_numS[vB]; }
381 
389  int numberOfPNodes(node vB) const { return m_bNode_numP[vB]; }
390 
398  int numberOfRNodes(node vB) const { return m_bNode_numR[vB]; }
399 
401  const Graph& spqrTree() const { return m_T; }
402 
404  node spqrParent(node vT) const {
405  edge p_e = m_tNode_hRefEdge[vT];
406  if (p_e == nullptr) {
407  return nullptr;
408  }
409  edge p_et = twinEdge(p_e);
410  OGDF_ASSERT(p_et != nullptr);
411  node p = m_hEdge_tNode[p_et];
412  OGDF_ASSERT(p != nullptr);
413  OGDF_ASSERT(m_T.searchEdge(vT, p) != nullptr);
414  return p;
415  }
416 
418  edge spqrParentEdge(node vT) const { return m_tNode_hRefEdge[vT]; }
419 
421  node spqrNodeOf(edge eH) const { return m_hEdge_tNode[eH]; }
422 
430  edge twinEdge(edge eH) const { return m_hEdge_twinEdge[eH]; }
431 
433 
444  TNodeType typeOfTNode(node vT) const { return m_tNode_type[vT]; }
445 
457  const List<edge>& hEdgesSPQR(node vT) const { return *m_tNode_hEdges[vT]; }
458 
471  SList<node>& findPathSPQR(node sH, node tH) const;
472 
488  edge virtualEdge(node vT, node wT) const;
490 
504  edge updateInsertedEdge(edge eG) override;
505 
520  node updateInsertedNode(edge eG, edge fG) override;
521 
523 };
524 
525 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, DynamicSPQRForest::TNodeType t);
526 
527 }
ogdf::DynamicSPQRForest::typeOfTNode
TNodeType typeOfTNode(node vT) const
Definition: DynamicSPQRForest.h:444
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::DynamicSPQRForest::DynamicSPQRForest
DynamicSPQRForest(Graph &G, bool not_connected=false)
A constructor.
Definition: DynamicSPQRForest.h:309
ogdf::DynamicSPQRForest::m_htogc
NodeArray< node > m_htogc
Auxiliary array used by createSPQR().
Definition: DynamicSPQRForest.h:139
Graph.h
Includes declaration of graph class.
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:205
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:123
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
SPQRTree.h
Declaration of class SPQRTree.
ogdf::DynamicSPQRForest::DynamicSPQRForest
DynamicSPQRForest(Graph &G, node vG, bool not_connected=false)
A constructor.
Definition: DynamicSPQRForest.h:323
ogdf::DynamicSPQRForest::m_bNode_numS
NodeArray< int > m_bNode_numS
The numbers of S-components.
Definition: DynamicSPQRForest.h:89
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::DynamicSPQRForest::TNodeType
TNodeType
Enumeration type for characterizing the SPQR-tree-vertices.
Definition: DynamicSPQRForest.h:59
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:128
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:131
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:389
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:457
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:418
ogdf::DynamicSPQRForest::spqrproper
node spqrproper(edge eH) const
Definition: DynamicSPQRForest.h:345
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:380
ogdf::DynamicSPQRForest::~DynamicSPQRForest
~DynamicSPQRForest()
Definition: DynamicSPQRForest.h:328
ogdf::DynamicSPQRForest::addHEdge
void addHEdge(edge eH, node vT) const
Adds edge eH to a vertex vT of the SPQRForest.
Definition: DynamicSPQRForest.h:181
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:371
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:193
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:158
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:421
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:430
ogdf::DynamicSPQRForest
Dynamic SPQR-forest.
Definition: DynamicSPQRForest.h:56
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:983
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
ogdf::List< edge >
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::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:404
ogdf::DynamicSPQRForest::m_tNode_isMarked
NodeArray< bool > m_tNode_isMarked
Auxiliary array used by findNCASPQR()
Definition: DynamicSPQRForest.h:142
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:398
ogdf::DynamicSPQRForest::m_bNode_SPQR
NodeArray< node > m_bNode_SPQR
Definition: DynamicSPQRForest.h:79
ogdf::DynamicSPQRForest::m_bNode_numP
NodeArray< int > m_bNode_numP
The numbers of P-components.
Definition: DynamicSPQRForest.h:99
ogdf::DynamicSPQRForest::m_hEdge_twinEdge
EdgeArray< edge > m_hEdge_twinEdge
The partners of virtual edges (nullptr if real).
Definition: DynamicSPQRForest.h:134
ogdf::DynamicSPQRForest::m_T
Graph m_T
A Graph structure containing all SPQR-trees.
Definition: DynamicSPQRForest.h:70
ogdf::graphics::init
void init()
Definition: graphics.h:450
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::DynamicSPQRForest::m_tNode_hRefEdge
NodeArray< edge > m_tNode_hRefEdge
The virtual edges leading to the parents of the SPQR-tree vertices.
Definition: DynamicSPQRForest.h:120
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:1064
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
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 ))).
List.h
Declaration of doubly linked lists and iterators.
ogdf::DynamicSPQRForest::m_tNode_type
NodeArray< TNodeType > m_tNode_type
The types of the SPQR-tree-vertices.
Definition: DynamicSPQRForest.h:114
ogdf::SPQRTree::NodeType::RNode
@ RNode
ogdf::DynamicSPQRForest::m_bNode_numR
NodeArray< int > m_bNode_numR
The numbers of R-components.
Definition: DynamicSPQRForest.h:109
ogdf::DynamicSPQRForest::spqrTree
const Graph & spqrTree() const
Returns the SPQR-tree graph.
Definition: DynamicSPQRForest.h:401
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::DynamicBCTree
Dynamic BC-trees.
Definition: DynamicBCTree.h:56
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:117
ogdf::SPQRTree::NodeType::SNode
@ SNode
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716