Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
BCTree.h
Go to the documentation of this file.
1
32#pragma once
33
35#include <ogdf/basic/Graph.h>
36#include <ogdf/basic/SList.h>
37#include <ogdf/basic/basic.h>
38
39#include <iosfwd>
40
41namespace ogdf {
42template<class E>
43class List;
44
61public:
63 enum class GNodeType {
65 Normal,
67 CutVertex
68 };
69
71 enum class BNodeType {
73 BComp,
75 CComp
76 };
77
78protected:
81
89
102 mutable Graph m_H;
103
107
111
118
130
139
143
151
171
192
206
220
230
239
248
258
266
282
290
298
306
315 void init(node vG);
317
327
338
347 void biComp(adjEntry adjuG, node vG);
348
356 virtual node parent(node vB) const;
357
365 node findNCA(node uB, node vB) const;
366
368
369public:
378 explicit BCTree(Graph& G, bool not_connected = false) : BCTree(G, nullptr, not_connected) {};
379
389 BCTree(Graph& G, node vG, bool not_connected = false) : m_G(G), m_eStack(G.numberOfEdges()) {
390 if (vG == nullptr) {
391 vG = G.firstNode();
392 }
393 if (not_connected) {
394 initNotConnected(vG);
395 } else {
396 init(vG);
397 }
398 }
399
410 BCTree(Graph& G, List<node>& vG) : m_G(G), m_eStack(G.numberOfEdges()) { initNotConnected(vG); }
411
413 virtual ~BCTree() { }
414
415 BCTree(const BCTree& copy) = delete;
416 BCTree(BCTree&& move) = delete;
417 BCTree& operator=(const BCTree& copy) = delete;
418 BCTree& operator=(BCTree&& move) = delete;
419
422 const Graph& originalGraph() const { return m_G; }
423
425 const Graph& bcTree() const { return m_B; }
426
428 const Graph& auxiliaryGraph() const { return m_H; }
429
431
434 int numberOfBComps() const { return m_numB; }
435
437 int numberOfCComps() const { return m_numC; }
438
440
447 return m_bNode_type[m_hNode_bNode[m_gNode_hNode[vG]]] == BNodeType::BComp
448 ? GNodeType::Normal
449 : GNodeType::CutVertex;
450 }
451
464 node bcproper(node vG) const { return bccomp(m_gNode_hNode[vG]); }
465
473 node bcproper(edge eG) const { return bccomp(m_gEdge_hEdge[eG]); }
474
487 virtual node bccomp(node vH) const { return m_hNode_bNode[vH]; }
488
496 virtual node bccomp(edge eH) const { return m_hEdge_bNode[eH]; }
497
509 node rep(node vG) const { return m_gNode_hNode[vG]; }
510
517 edge rep(edge eG) const { return m_gEdge_hEdge[eG]; }
518
520
527 node original(node vH) const { return m_hNode_gNode[vH]; }
528
535 edge original(edge eH) const { return m_hEdge_gEdge[eH]; }
536
538
545 BNodeType typeOfBNode(node vB) const { return m_bNode_type[vB]; }
546
557 const SList<edge>& hEdges(node vB) const { return m_bNode_hEdges[vB]; }
558
566 int numberOfEdges(node vB) const { return m_bNode_hEdges[vB].size(); }
567
576 int numberOfNodes(node vB) const { return m_bNode_numNodes[vB]; }
577
579
591 node bComponent(node uG, node vG) const;
592
603
614
628 virtual node repVertex(node uG, node vB) const;
629
659 virtual node cutVertex(node uB, node vB) const;
660
662
663#ifdef OGDF_DEBUG
665 void consistencyCheck() const;
666#endif
667
668private:
669 void initBasic(node vG);
670 void initEdges();
671};
672
673OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const BCTree::BNodeType& obj);
674
675OGDF_EXPORT std::ostream& operator<<(std::ostream& os, const BCTree::GNodeType& obj);
676
677}
Declaration and implementation of ArrayBuffer class.
Includes declaration of graph class.
Declaration of singly linked lists and iterators.
Basic declarations, included by all source files.
Class for adjacency list elements.
Definition Graph_d.h:143
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
Static BC-trees.
Definition BCTree.h:60
BNodeType
Enumeration type for characterizing the BC-tree-vertices.
Definition BCTree.h:71
void initNotConnected(node vG)
Initialization for not connected graphs.
void initEdges()
NodeArray< bool > m_bNode_isMarked
Array of marks for the BC-tree-vertices.
Definition BCTree.h:150
GNodeType
Enumeration type for characterizing the vertices of the original graph.
Definition BCTree.h:63
int m_numC
The number of C-components.
Definition BCTree.h:109
node rep(node vG) const
Returns a vertex of the biconnected components graph corresponding to a given vertex of the original ...
Definition BCTree.h:509
void init(node vG)
void biComp(adjEntry adjuG, node vG)
Generates the BC-tree and the biconnected components graph recursively.
SList< node > * findPathBCTree(node sB, node tB) const
Calculates a path in the BC-tree.
int numberOfNodes(node vB) const
Returns the number of vertices belonging to the biconnected component represented by a given BC-tree-...
Definition BCTree.h:576
ArrayBuffer< adjEntry > m_eStack
Temporary stack.
Definition BCTree.h:289
int m_numB
The number of B-components.
Definition BCTree.h:106
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:464
BCTree(BCTree &&move)=delete
const Graph & bcTree() const
Returns the BC-tree graph.
Definition BCTree.h:425
int numberOfBComps() const
Returns the number of B-components.
Definition BCTree.h:434
Graph m_H
The biconnected components graph.
Definition BCTree.h:102
node original(node vH) const
Definition BCTree.h:527
void initBasic(node vG)
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:205
virtual node parent(node vB) const
BCTree(Graph &G, bool not_connected=false)
A constructor.
Definition BCTree.h:378
NodeArray< bool > m_gNode_isMarked
Definition BCTree.h:117
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:487
int m_count
Definition BCTree.h:265
Graph & m_G
The original graph.
Definition BCTree.h:80
virtual ~BCTree()
Virtual destructor.
Definition BCTree.h:413
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:557
const Graph & originalGraph() const
Returns the original graph.
Definition BCTree.h:422
NodeArray< node > m_gNode_hNode
An injective mapping vertices(G) -> vertices(H).
Definition BCTree.h:129
node findNCA(node uB, node vB) const
Calculates the nearest common ancestor of two vertices of the BC-tree.
void initNotConnected(List< node > &vG)
Initialization for not connected graphs.
node bcproper(edge eG) const
Returns the BC-tree-vertex representing the biconnected component which a given edge of the original ...
Definition BCTree.h:473
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:517
NodeArray< node > m_hNode_bNode
Definition BCTree.h:229
EdgeArray< edge > m_gEdge_hEdge
A bijective mapping edges(G) -> edges(H).
Definition BCTree.h:137
EdgeArray< edge > m_hEdge_gEdge
A bijective mapping edges(H) -> edges(G).
Definition BCTree.h:256
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:218
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:566
NodeArray< node > m_hNode_gNode
A surjective mapping vertices(H) -> vertices(G).
Definition BCTree.h:247
const Graph & auxiliaryGraph() const
Returns the biconnected components graph.
Definition BCTree.h:428
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:191
NodeArray< int > m_number
Temporary array.
Definition BCTree.h:274
NodeArray< node > m_gtoh
Temporary array.
Definition BCTree.h:297
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:170
BCTree(Graph &G, List< node > &vG)
Constructor for not connected graphs.
Definition BCTree.h:410
EdgeArray< node > m_hEdge_bNode
A surjective mapping edges(H) -> vertices(B).
Definition BCTree.h:238
node bComponent(node uG, node vG) const
NodeArray< int > m_lowpt
Temporary array.
Definition BCTree.h:281
int numberOfCComps() const
Returns the number of C-components.
Definition BCTree.h:437
virtual node cutVertex(node uB, node vB) const
Returns the copy of a cut-vertex in the biconnected components graph which belongs to a certain B-com...
SList< node > m_nodes
Temporary list.
Definition BCTree.h:305
BCTree(Graph &G, node vG, bool not_connected=false)
A constructor.
Definition BCTree.h:389
GNodeType typeOfGNode(node vG) const
Definition BCTree.h:446
BCTree & operator=(BCTree &&move)=delete
Graph m_B
The BC-tree.
Definition BCTree.h:88
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:496
BCTree(const BCTree &copy)=delete
NodeArray< BNodeType > m_bNode_type
Array that contains the type of each BC-tree-vertex.
Definition BCTree.h:142
BCTree & operator=(const BCTree &copy)=delete
SList< node > & findPath(node sG, node tG) const
Calculates a path in the BC-tree.
BNodeType typeOfBNode(node vB) const
Definition BCTree.h:545
void consistencyCheck() const
Asserts that this BCTree is consistent.
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:535
virtual node repVertex(node uG, node vB) const
Returns a vertex of the biconnected components graph corresponding to a given vertex of the original ...
Class for the representation of edges.
Definition Graph_d.h:364
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
Singly linked lists (maintaining the length of the list).
Definition SList.h:845
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:983