Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Triconnectivity.h
Go to the documentation of this file.
1
34#pragma once
35
36#include <ogdf/basic/Array.h>
38#include <ogdf/basic/Graph.h>
40#include <ogdf/basic/List.h>
41#include <ogdf/basic/basic.h>
42
43#include <ostream>
44
45namespace ogdf {
46
51 explicit Triconnectivity(Graph* G);
52
53public:
59 m_deleteGraph = true;
60 };
61
67 explicit Triconnectivity(Graph& G, bool modifyG = false)
68 : Triconnectivity(modifyG ? &G : new GraphCopySimple(G)) {
69 m_deleteGraph = !modifyG;
70 };
71
79 Triconnectivity(const Graph& G, bool& isTric, node& s1, node& s2);
80
82
84
86 enum class CompType { bond, polygon, triconnected };
87
89 struct CompStruct {
92
94 m_edges.pushBack(e);
95 return *this;
96 }
97
99 m_edges.pushBack(e);
100 m_type = (m_edges.size() >= 4) ? CompType::triconnected : CompType::polygon;
101 }
102 };
103
109
114
119 bool checkComp() const;
120
121private:
122 bool checkSepPair(edge eVirt) const;
123
125
129
131 int *m_TSTACK_h, *m_TSTACK_a, *m_TSTACK_b;
132 int m_top;
133
135 void TSTACK_push(int h, int a, int b) {
136 m_TSTACK_h[++m_top] = h;
137 m_TSTACK_a[m_top] = a;
138 m_TSTACK_b[m_top] = b;
139 }
140
142 void TSTACK_pushEOS() { m_TSTACK_a[++m_top] = -1; }
143
145 bool TSTACK_notEOS() { return m_TSTACK_a[m_top] != -1; }
146
148 CompStruct& newComp() { return m_component[m_numComp++]; }
149
152 CompStruct& C = m_component[m_numComp++];
153 C.m_type = t;
154 return C;
155 }
156
158 enum class EdgeType { unseen, tree, frond, removed };
159
161 void DFS1(node v, node u);
163 void DFS1(node v, node u, node& s1);
164
168 void DFS2();
170
172
176 bool pathSearch(node init_v, bool fail_fast, node& s1, node& s2);
178 void afterRecursivePathSearch(const node v, const int vnum, const int outv,
179 const ListIterator<edge> it, const edge e, const node w, int wnum);
181 bool afterRecursivePathSearch(const node v, const int vnum, const int outv, const edge e,
182 const node w, const int wnum, node& s1, node& s2);
183
186
188 void printOs(edge e) const;
189 void printStacks() const;
190
192 int high(node v) { return (m_HIGHPT[v].empty()) ? 0 : m_HIGHPT[v].front(); }
193
194 void delHigh(edge e) {
195 ListIterator<int> it = m_IN_HIGH[e];
196 if (it.valid()) {
197 node v = e->target();
198 m_HIGHPT[v].del(it);
199 }
200 }
201
203 template<typename T>
204 T GCoriginal(T n) const {
205 if (m_deleteGraph) {
206 // TODO use common superclass of all GraphCopies
207 return dynamic_cast<GraphCopySimple*>(m_pG)->original(n);
208 } else {
209 return n;
210 }
211 }
212
229
234};
235
236OGDF_EXPORT std::ostream& operator<<(std::ostream& os, Triconnectivity::CompType type);
237
238}
Declaration and implementation of Array class and Array algorithms.
Declaration and implementation of ArrayBuffer class.
Includes declaration of graph class.
Declaration of graph copy classes.
Declaration of doubly linked lists and iterators.
Basic declarations, included by all source files.
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
Definition ArrayBuffer.h:64
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:219
Class for the representation of edges.
Definition Graph_d.h:364
node target() const
Returns the target node of the edge.
Definition Graph_d.h:402
Copies of graphs with mapping between nodes and edges.
Definition GraphCopy.h:260
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
int size() const
Returns the number of elements in the list.
Definition List.h:1488
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition List.h:1547
Encapsulates a pointer to a list element.
Definition List.h:113
bool valid() const
Returns true iff the iterator points to an element.
Definition List.h:153
Class for the representation of nodes.
Definition Graph_d.h:241
realizes Hopcroft/Tarjan algorithm for finding the triconnected components of a biconnected multi-gra...
bool afterRecursivePathSearch(const node v, const int vnum, const int outv, const edge e, const node w, const int wnum, node &s1, node &s2)
pathSearch() helper for the fail-fast version
EdgeArray< bool > m_START
edge starts a path
void splitMultiEdges()
splits bundles of multi-edges into bonds and creates a new virtual edge in GC.
void assembleTriconnectedComponents()
merges split-components into triconnected components
NodeArray< List< edge > > m_A
adjacency list of v
EdgeArray< ListIterator< int > > m_IN_HIGH
pointer to element in HIGHPT list containing e
NodeArray< int > m_LOWPT1
T GCoriginal(T n) const
returns m_pG.original(n) if m_pG is a GraphCopySimple, otherwise n itself
ArrayBuffer< edge > m_ESTACK
stack of currently active edges
Graph * m_pG
modifiable copy of G also containing virtual edges
node m_start
start node of dfs traversal
void printStacks() const
EdgeType
type of edges with respect to palm tree
Triconnectivity(Graph &G, bool modifyG=false)
Divides G into triconnected components.
EdgeArray< ListIterator< edge > > m_IN_ADJ
pointer to element in adjacency list containing e
bool m_deleteGraph
whether the Graph(Copy) was created by us and should thus be deleted in the destructor
CompStruct & newComp()
create a new empty component
NodeArray< int > m_DEGREE
degree of v
CompStruct & newComp(CompType t)
create a new empty component of type t
CompType
type of split-components / triconnected components
Triconnectivity(const Graph &G)
Divides G into triconnected components.
int m_numComp
number of components
bool checkSepPair(edge eVirt) const
void DFS1(node v, node u)
first dfs traversal
Triconnectivity(const Graph &G, bool &isTric, node &s1, node &s2)
Tests G for triconnectivity.
NodeArray< node > m_FATHER
father of v in palm tree
int m_numCount
counter for dfs-traversal
Triconnectivity(const Triconnectivity &)=delete
void buildAcceptableAdjStruct()
constructs ordered adjaceny lists
void DFS2()
the second dfs traversal
bool TSTACK_notEOS()
returns true iff end-of-stack marker is not on top of TSTACK
void pathFinder(node v)
Array< node > m_NODEAT
node with number i
int high(node v)
returns high(v) value
Array< CompStruct > m_component
array of components
bool pathSearch(node init_v, bool fail_fast, node &s1, node &s2)
finding of split components
NodeArray< int > m_NUMBER
(first) dfs-number of v
void TSTACK_push(int h, int a, int b)
push a triple on TSTACK
bool m_newPath
true iff we start a new path
void DFS1(node v, node u, node &s1)
special version for triconnectivity test
NodeArray< int > m_ND
number of descendants in palm tree
EdgeArray< EdgeType > m_TYPE
type of edge e
void TSTACK_pushEOS()
push end-of-stack marker on TSTACK
NodeArray< edge > m_TREE_ARC
tree arc entering v
bool checkComp() const
Checks if computed triconnected components are correct.
NodeArray< List< int > > m_HIGHPT
list of fronds entering v in the order they are visited
void afterRecursivePathSearch(const node v, const int vnum, const int outv, const ListIterator< edge > it, const edge e, const node w, int wnum)
pathSearch() helper for the non-fail-fast version
void printOs(edge e) const
debugging stuff
NodeArray< int > m_LOWPT2
NodeArray< int > m_NEWNUM
(second) dfs-number of v
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.
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition Array.h:983
representation of a component