Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

BCTree.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/EdgeArray.h>
35 #include <ogdf/basic/NodeArray.h>
36 #include <ogdf/basic/SList.h>
37 
38 namespace ogdf {
39 
56 public:
58  enum class GNodeType {
60  Normal,
62  CutVertex
63  };
64 
66  enum class BNodeType {
68  BComp,
70  CComp
71  };
72 
73 protected:
76 
84 
97  mutable Graph m_H;
98 
101  int m_numB;
102 
104  int m_numC;
106 
113 
125 
134 
138 
146 
166 
187 
201 
215 
225 
234 
243 
253 
260  int m_count;
261 
277 
285 
293 
301 
310  void init(node vG);
312 
321  void initNotConnected(node vG);
322 
332  void initNotConnected(List<node>& vG);
333 
342  void biComp(adjEntry adjuG, node vG);
343 
351  virtual node parent(node vB) const;
352 
360  node findNCA(node uB, node vB) const;
361 
363 
364 public:
373  explicit BCTree(Graph& G, bool not_connected = false) : BCTree(G, nullptr, not_connected) {};
374 
384  BCTree(Graph& G, node vG, bool not_connected = false) : m_G(G), m_eStack(G.numberOfEdges()) {
385  if (vG == nullptr) {
386  vG = G.firstNode();
387  }
388  if (not_connected) {
389  initNotConnected(vG);
390  } else {
391  init(vG);
392  }
393  }
394 
405  BCTree(Graph& G, List<node>& vG) : m_G(G), m_eStack(G.numberOfEdges()) { initNotConnected(vG); }
406 
408  virtual ~BCTree() { }
409 
410  BCTree(const BCTree& copy) = delete;
411  BCTree(BCTree&& move) = delete;
412  BCTree& operator=(const BCTree& copy) = delete;
413  BCTree& operator=(BCTree&& move) = delete;
414 
417  const Graph& originalGraph() const { return m_G; }
418 
420  const Graph& bcTree() const { return m_B; }
421 
423  const Graph& auxiliaryGraph() const { return m_H; }
424 
426 
429  int numberOfBComps() const { return m_numB; }
430 
432  int numberOfCComps() const { return m_numC; }
433 
435 
442  return m_bNode_type[m_hNode_bNode[m_gNode_hNode[vG]]] == BNodeType::BComp
443  ? GNodeType::Normal
444  : GNodeType::CutVertex;
445  }
446 
459  node bcproper(node vG) const { return bccomp(m_gNode_hNode[vG]); }
460 
468  node bcproper(edge eG) const { return bccomp(m_gEdge_hEdge[eG]); }
469 
482  virtual node bccomp(node vH) const { return m_hNode_bNode[vH]; }
483 
491  virtual node bccomp(edge eH) const { return m_hEdge_bNode[eH]; }
492 
504  node rep(node vG) const { return m_gNode_hNode[vG]; }
505 
512  edge rep(edge eG) const { return m_gEdge_hEdge[eG]; }
513 
515 
522  node original(node vH) const { return m_hNode_gNode[vH]; }
523 
530  edge original(edge eH) const { return m_hEdge_gEdge[eH]; }
531 
533 
540  BNodeType typeOfBNode(node vB) const { return m_bNode_type[vB]; }
541 
552  const SList<edge>& hEdges(node vB) const { return m_bNode_hEdges[vB]; }
553 
561  int numberOfEdges(node vB) const { return m_bNode_hEdges[vB].size(); }
562 
571  int numberOfNodes(node vB) const { return m_bNode_numNodes[vB]; }
572 
574 
586  node bComponent(node uG, node vG) const;
587 
597  SList<node>& findPath(node sG, node tG) const;
598 
608  SList<node>* findPathBCTree(node sB, node tB) const;
609 
623  virtual node repVertex(node uG, node vB) const;
624 
654  virtual node cutVertex(node uB, node vB) const;
655 
657 
658 #ifdef OGDF_DEBUG
659  void consistencyCheck() const;
661 #endif
662 
663 private:
664  void initBasic(node vG);
665  void initEdges();
666 };
667 
668 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const BCTree::BNodeType& obj);
669 
670 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const BCTree::GNodeType& obj);
671 
672 }
ogdf::ArrayBuffer
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition: Array.h:46
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::BCTree::bcTree
const Graph & bcTree() const
Returns the BC-tree graph.
Definition: BCTree.h:420
ogdf::BCTree::numberOfCComps
int numberOfCComps() const
Returns the number of C-components.
Definition: BCTree.h:432
ogdf::BCTree::m_hNode_gNode
NodeArray< node > m_hNode_gNode
A surjective mapping vertices(H) -> vertices(G).
Definition: BCTree.h:242
ogdf::BCTree
Static BC-trees.
Definition: BCTree.h:55
ogdf::BCTree::original
node original(node vH) const
Definition: BCTree.h:522
ogdf::BCTree::GNodeType
GNodeType
Enumeration type for characterizing the vertices of the original graph.
Definition: BCTree.h:58
ogdf::BCTree::m_bNode_hEdges
NodeArray< SList< edge > > m_bNode_hEdges
Array that contains for each BC-tree-vertex a linear list of the edges of the biconnected components ...
Definition: BCTree.h:200
ogdf::BCTree::m_count
int m_count
Definition: BCTree.h:260
ogdf::BCTree::m_gNode_hNode
NodeArray< node > m_gNode_hNode
An injective mapping vertices(G) -> vertices(H).
Definition: BCTree.h:124
ogdf::BCTree::m_hEdge_gEdge
EdgeArray< edge > m_hEdge_gEdge
A bijective mapping edges(H) -> edges(G).
Definition: BCTree.h:251
ogdf::BCTree::m_bNode_hParNode
NodeArray< node > m_bNode_hParNode
Array that contains for each BC-tree-vertex the representant of itself within the subgraph in the bic...
Definition: BCTree.h:186
ogdf::BCTree::rep
edge rep(edge eG) const
Returns the edge of the biconnected components graph corresponding to a given edge of the original gr...
Definition: BCTree.h:512
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:833
ogdf::BCTree::auxiliaryGraph
const Graph & auxiliaryGraph() const
Returns the biconnected components graph.
Definition: BCTree.h:423
ogdf::BCTree::numberOfBComps
int numberOfBComps() const
Returns the number of B-components.
Definition: BCTree.h:429
ogdf::BCTree::m_bNode_hRefNode
NodeArray< node > m_bNode_hRefNode
Array that contains for each BC-tree-vertex the representantive of its parent within the subgraph in ...
Definition: BCTree.h:165
ogdf::BCTree::bcproper
node bcproper(edge eG) const
Returns the BC-tree-vertex representing the biconnected component which a given edge of the original ...
Definition: BCTree.h:468
ogdf::BCTree::bcproper
node bcproper(node vG) const
Returns a BC-tree-vertex representing a biconnected component which a given vertex of the original gr...
Definition: BCTree.h:459
ogdf::BCTree::BCTree
BCTree(Graph &G, List< node > &vG)
Constructor for not connected graphs.
Definition: BCTree.h:405
ogdf::BCTree::typeOfBNode
BNodeType typeOfBNode(node vB) const
Definition: BCTree.h:540
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::BCTree::m_number
NodeArray< int > m_number
Temporary array.
Definition: BCTree.h:269
ogdf::BCTree::m_lowpt
NodeArray< int > m_lowpt
Temporary array.
Definition: BCTree.h:276
Minisat::Internal::copy
static void copy(const T &from, T &to)
Definition: Alg.h:61
ogdf::BCTree::m_bNode_type
NodeArray< BNodeType > m_bNode_type
Array that contains the type of each BC-tree-vertex.
Definition: BCTree.h:137
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:243
SList.h
Declaration of singly linked lists and iterators.
ogdf::BCTree::m_B
Graph m_B
The BC-tree.
Definition: BCTree.h:83
ogdf::BCTree::m_hNode_bNode
NodeArray< node > m_hNode_bNode
Definition: BCTree.h:224
EdgeArray.h
Declaration and implementation of EdgeArray class.
ogdf::BCTree::m_numC
int m_numC
The number of C-components.
Definition: BCTree.h:104
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::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
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::BCTree::m_gtoh
NodeArray< node > m_gtoh
Temporary array.
Definition: BCTree.h:292
ogdf::BCTree::m_gEdge_hEdge
EdgeArray< edge > m_gEdge_hEdge
A bijective mapping edges(G) -> edges(H).
Definition: BCTree.h:132
ogdf::BCTree::m_gNode_isMarked
NodeArray< bool > m_gNode_isMarked
Definition: BCTree.h:112
ogdf::BCTree::typeOfGNode
GNodeType typeOfGNode(node vG) const
Definition: BCTree.h:441
ogdf::BCTree::m_hEdge_bNode
EdgeArray< node > m_hEdge_bNode
A surjective mapping edges(H) -> vertices(B).
Definition: BCTree.h:233
NodeArray.h
Declaration and implementation of NodeArray class.
ogdf::BCTree::rep
node rep(node vG) const
Returns a vertex of the biconnected components graph corresponding to a given vertex of the original ...
Definition: BCTree.h:504
ogdf::BCTree::BCTree
BCTree(Graph &G, node vG, bool not_connected=false)
A constructor.
Definition: BCTree.h:384
ogdf::BCTree::~BCTree
virtual ~BCTree()
Virtual destructor.
Definition: BCTree.h:408
ogdf::graphics::init
void init()
Definition: graphics.h:446
ogdf::BCTree::numberOfEdges
int numberOfEdges(node vB) const
Returns the number of edges belonging to the biconnected component represented by a given BC-tree-ver...
Definition: BCTree.h:561
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::BCTree::m_G
Graph & m_G
The original graph.
Definition: BCTree.h:75
ogdf::BCTree::hEdges
const SList< edge > & hEdges(node vB) const
Returns a linear list of the edges of the biconnected components graph belonging to the biconnected c...
Definition: BCTree.h:552
ogdf::BCTree::numberOfNodes
int numberOfNodes(node vB) const
Returns the number of vertices belonging to the biconnected component represented by a given BC-tree-...
Definition: BCTree.h:571
ogdf::BCTree::original
edge original(edge eH) const
Returns the edge of the original graph which a given edge of the biconnected components graph is corr...
Definition: BCTree.h:530
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::BCTree::m_bNode_isMarked
NodeArray< bool > m_bNode_isMarked
Array of marks for the BC-tree-vertices.
Definition: BCTree.h:145
ogdf::BCTree::m_bNode_numNodes
NodeArray< int > m_bNode_numNodes
Array that contains for each BC-tree-vertex the number of vertices belonging to the biconnected compo...
Definition: BCTree.h:213
ogdf::BCTree::BNodeType
BNodeType
Enumeration type for characterizing the BC-tree-vertices.
Definition: BCTree.h:66
ogdf::BCTree::originalGraph
const Graph & originalGraph() const
Returns the original graph.
Definition: BCTree.h:417
ogdf::BCTree::m_numB
int m_numB
The number of B-components.
Definition: BCTree.h:101
ogdf::BCTree::m_eStack
ArrayBuffer< adjEntry > m_eStack
Temporary stack.
Definition: BCTree.h:284
ogdf::BCTree::m_nodes
SList< node > m_nodes
Temporary list.
Definition: BCTree.h:300
ogdf::BCTree::bccomp
virtual node bccomp(edge eH) const
Returns the BC-tree-vertex representing the biconnected component which a given edge of the auxiliary...
Definition: BCTree.h:491
ogdf::BCTree::m_H
Graph m_H
The biconnected components graph.
Definition: BCTree.h:97
ogdf::BCTree::bccomp
virtual node bccomp(node vH) const
Returns a BC-tree-vertex representing a biconnected component which a given vertex of the auxiliary g...
Definition: BCTree.h:482
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::BCTree::BCTree
BCTree(Graph &G, bool not_connected=false)
A constructor.
Definition: BCTree.h:373
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709