Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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>(SPQRTree::NodeType::SNode),
54  PComp = static_cast<int>(SPQRTree::NodeType::PNode),
55  RComp = static_cast<int>(SPQRTree::NodeType::RNode)
56  };
57 
58 protected:
60  mutable Graph m_T;
61 
70 
80 
90 
101 
105 
108 
111 
115 
119 
122 
126 
130 
134 
136  void init();
137 
153  void createSPQR(node vB) const;
154 
165  inline node newSPQRNode(node vB, const TNodeType spqrNodeType) const {
166  node vT = m_T.newNode();
167  m_tNode_owner[vT] = vT;
168  m_tNode_type[vT] = spqrNodeType;
169  m_tNode_hEdges[vT] = new List<edge>;
170 
171  if (spqrNodeType == TNodeType::PComp) {
172  m_bNode_numP[vB]++;
173  } else if (spqrNodeType == TNodeType::SComp) {
174  m_bNode_numS[vB]++;
175  } else if (spqrNodeType == TNodeType::RComp) {
176  m_bNode_numR[vB]++;
177  }
178 
179  return vT;
180  }
181 
188  inline void addHEdge(edge eH, node vT) const {
189  m_hEdge_position[eH] = m_tNode_hEdges[vT]->pushBack(eH);
190  m_hEdge_tNode[eH] = vT;
191  }
192 
200  inline void delHEdge(edge eH, node vT) const {
201  m_tNode_hEdges[vT]->del(m_hEdge_position[eH]);
202  m_H.delEdge(eH);
203  }
204 
212  inline edge newTwinEdge(edge eH, node vT) const {
213  edge fH = m_H.newEdge(eH->source(), eH->target());
214  addHEdge(fH, vT);
215  m_hEdge_twinEdge[eH] = fH;
216  m_hEdge_twinEdge[fH] = eH;
217  return fH;
218  }
219 
233  node uniteSPQR(node vB, node sT, node tT);
234 
242  node findSPQR(node vT) const;
244 
256  node findNCASPQR(node sT, node tT) const;
257 
271  SList<node>& findPathSPQR(node sH, node tH, node& rT) const;
273 
287  edge updateInsertedEdgeSPQR(node vB, edge eG);
288 
302  node updateInsertedNodeSPQR(node vB, edge eG, edge fG);
304 
305 public:
315  explicit DynamicSPQRForest(Graph& G) : DynamicBCTree(G) { init(); }
316 
317  ~DynamicSPQRForest() { for (auto pList : m_tNode_hEdges) { delete pList; } }
318 
334  node spqrproper(edge eH) const { return m_hEdge_tNode[eH] = findSPQR(m_hEdge_tNode[eH]); }
335 
343  edge twinEdge(edge eH) const { return m_hEdge_twinEdge[eH]; }
345 
356  TNodeType typeOfTNode(node vT) const { return m_tNode_type[vT]; }
357 
369  const List<edge>& hEdgesSPQR(node vT) const { return *m_tNode_hEdges[vT]; }
370 
383  SList<node>& findPathSPQR(node sH, node tH) const;
384 
400  edge virtualEdge(node vT, node wT) const;
402 
416  edge updateInsertedEdge(edge eG) override;
417 
432  node updateInsertedNode(edge eG, edge fG) override;
433 
435 };
436 
437 }
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:328
NodeArray< TNodeType > m_tNode_type
The types of the SPQR-tree-vertices.
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Dynamic BC-trees.
Definition: DynamicBCTree.h:54
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
void init()
Definition: graphics.h:472
NodeArray< node > m_tNode_owner
The owners of the SPQR-tree-vertices in the UNION/FIND structure.
Singly linked lists (maintaining the length of the list).
Definition: SList.h:773
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
void delHEdge(edge eH, node vT) const
Deletes edge eH from m_H and removes its connection to a vertex vT of the SPQRForest.
Dynamic SPQR-forest.
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.
NodeArray< List< edge > * > m_tNode_hEdges
Lists of real and virtual edges belonging to SPQR-tree vertices.
EdgeArray< node > m_hEdge_tNode
The SPQR-tree-vertices which the real and virtual edges are belonging to.
Class for the representation of edges.
Definition: Graph_d.h:292
void addHEdge(edge eH, node vT) const
Adds edge eH to a vertex vT of the SPQRForest.
node spqrproper(edge eH) const
DynamicSPQRForest(Graph &G)
A constructor.
Class for the representation of nodes.
Definition: Graph_d.h:169
Declaration of class SPQRTree.
NodeArray< int > m_bNode_numR
The numbers of R-components.
NodeArray< node > m_htogc
Auxiliary array used by createSPQR().
TNodeType typeOfTNode(node vT) const
NodeArray< int > m_bNode_numP
The numbers of P-components.
NodeArray< bool > m_tNode_isMarked
Auxiliary array used by findNCASPQR()
Declaration of class DynamicBCTree.
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...
edge newTwinEdge(edge eH, node vT) const
Creates a twin edge for eH, adds it to vT and returns it.
NodeArray< int > m_bNode_numS
The numbers of S-components.
NodeArray< node > m_bNode_SPQR
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:326
The namespace for all OGDF objects.
EdgeArray< ListIterator< edge > > m_hEdge_position
The positions of real and virtual edges in their m_tNode_hEdges lists.
EdgeArray< edge > m_hEdge_twinEdge
The partners of virtual edges (nullptr if real).
node newNode()
Creates a new node and returns it.
Graph m_T
A Graph structure containing all SPQR-trees.
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...
NodeArray< edge > m_tNode_hRefEdge
The virtual edges leading to the parents of the SPQR-tree vertices.
TNodeType
Enumeration type for characterizing the SPQR-tree-vertices.