Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Triconnectivity.h
Go to the documentation of this file.
1 
34 #pragma once
35 
36 #include <ogdf/basic/Array.h>
37 #include <ogdf/basic/ArrayBuffer.h>
38 #include <ogdf/basic/Graph.h>
39 #include <ogdf/basic/GraphCopy.h>
40 #include <ogdf/basic/List.h>
41 #include <ogdf/basic/basic.h>
42 
43 #include <ostream>
44 
45 namespace ogdf {
46 
51  explicit Triconnectivity(Graph* G);
52 
53 public:
58  explicit Triconnectivity(const Graph& G) : Triconnectivity(new GraphCopySimple(G)) {
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 
81  Triconnectivity(const Triconnectivity&) = delete;
82 
83  ~Triconnectivity();
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 
121 private:
122  bool checkSepPair(edge eVirt) const;
123 
124  void clearStructures();
125 
128  void splitMultiEdges();
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 
166  void buildAcceptableAdjStruct();
168  void DFS2();
169  void pathFinder(node v);
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 
185  void assembleTriconnectedComponents();
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 
232  bool m_newPath;
234 };
235 
236 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, Triconnectivity::CompType type);
237 
238 }
ogdf::ArrayBuffer< edge >
ogdf::Triconnectivity::m_ESTACK
ArrayBuffer< edge > m_ESTACK
stack of currently active edges
Definition: Triconnectivity.h:228
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ArrayBuffer.h
Declaration and implementation of ArrayBuffer class.
ogdf::Triconnectivity::m_IN_ADJ
EdgeArray< ListIterator< edge > > m_IN_ADJ
pointer to element in adjacency list containing e
Definition: Triconnectivity.h:226
Graph.h
Includes declaration of graph class.
ogdf::Triconnectivity::m_NUMBER
NodeArray< int > m_NUMBER
(first) dfs-number of v
Definition: Triconnectivity.h:213
ogdf::Triconnectivity::m_A
NodeArray< List< edge > > m_A
adjacency list of v
Definition: Triconnectivity.h:221
ogdf::Triconnectivity::m_numCount
int m_numCount
counter for dfs-traversal
Definition: Triconnectivity.h:231
ogdf::Triconnectivity::m_FATHER
NodeArray< node > m_FATHER
father of v in palm tree
Definition: Triconnectivity.h:219
ogdf::Triconnectivity::m_ND
NodeArray< int > m_ND
number of descendants in palm tree
Definition: Triconnectivity.h:216
ogdf::Triconnectivity::TSTACK_push
void TSTACK_push(int h, int a, int b)
push a triple on TSTACK
Definition: Triconnectivity.h:135
ogdf::Triconnectivity::delHigh
void delHigh(edge e)
Definition: Triconnectivity.h:194
ogdf::Triconnectivity::TSTACK_pushEOS
void TSTACK_pushEOS()
push end-of-stack marker on TSTACK
Definition: Triconnectivity.h:142
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:153
ogdf::Triconnectivity::m_DEGREE
NodeArray< int > m_DEGREE
degree of v
Definition: Triconnectivity.h:217
ogdf::Triconnectivity::m_TSTACK_h
int * m_TSTACK_h
stack of triples
Definition: Triconnectivity.h:131
ogdf::GraphCopySimple
Copies of graphs with mapping between nodes and edges.
Definition: GraphCopy.h:261
ogdf::Triconnectivity::m_pG
Graph * m_pG
modifiable copy of G also containing virtual edges
Definition: Triconnectivity.h:105
ogdf::Triconnectivity::CompType
CompType
type of split-components / triconnected components
Definition: Triconnectivity.h:86
ogdf::Triconnectivity::m_NODEAT
Array< node > m_NODEAT
node with number i
Definition: Triconnectivity.h:218
ogdf::Triconnectivity::high
int high(node v)
returns high(v) value
Definition: Triconnectivity.h:192
ogdf::Triconnectivity::m_IN_HIGH
EdgeArray< ListIterator< int > > m_IN_HIGH
pointer to element in HIGHPT list containing e
Definition: Triconnectivity.h:227
ogdf::Triconnectivity::m_LOWPT1
NodeArray< int > m_LOWPT1
Definition: Triconnectivity.h:214
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::Triconnectivity::CompStruct::finishTricOrPoly
void finishTricOrPoly(edge e)
Definition: Triconnectivity.h:98
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:219
ogdf::Triconnectivity::m_top
int m_top
Definition: Triconnectivity.h:132
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
GraphCopy.h
Declaration of graph copy classes.
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::Triconnectivity::m_component
Array< CompStruct > m_component
array of components
Definition: Triconnectivity.h:107
ogdf::Triconnectivity::m_TREE_ARC
NodeArray< edge > m_TREE_ARC
tree arc entering v
Definition: Triconnectivity.h:224
ogdf::EdgeStandardType::tree
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
ogdf::Triconnectivity::Triconnectivity
Triconnectivity(const Graph &G)
Divides G into triconnected components.
Definition: Triconnectivity.h:58
ogdf::Triconnectivity::Triconnectivity
Triconnectivity(Graph &G, bool modifyG=false)
Divides G into triconnected components.
Definition: Triconnectivity.h:67
ogdf::Triconnectivity::m_numComp
int m_numComp
number of components
Definition: Triconnectivity.h:113
ogdf::Triconnectivity::m_HIGHPT
NodeArray< List< int > > m_HIGHPT
list of fronds entering v in the order they are visited
Definition: Triconnectivity.h:225
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
Array.h
Declaration and implementation of Array class and Array algorithms.
ogdf::Triconnectivity::newComp
CompStruct & newComp()
create a new empty component
Definition: Triconnectivity.h:148
ogdf::Triconnectivity::m_LOWPT2
NodeArray< int > m_LOWPT2
Definition: Triconnectivity.h:215
ogdf::Triconnectivity::m_START
EdgeArray< bool > m_START
edge starts a path
Definition: Triconnectivity.h:223
ogdf::Triconnectivity::CompStruct::m_type
CompType m_type
Definition: Triconnectivity.h:91
ogdf::Triconnectivity::m_newPath
bool m_newPath
true iff we start a new path
Definition: Triconnectivity.h:232
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
List.h
Declaration of doubly linked lists and iterators.
ogdf::Triconnectivity::m_deleteGraph
bool m_deleteGraph
whether the Graph(Copy) was created by us and should thus be deleted in the destructor
Definition: Triconnectivity.h:233
ogdf::Triconnectivity::GCoriginal
T GCoriginal(T n) const
returns m_pG.original(n) if m_pG is a GraphCopySimple, otherwise n itself
Definition: Triconnectivity.h:204
ogdf::Triconnectivity::CompStruct::operator<<
CompStruct & operator<<(edge e)
Definition: Triconnectivity.h:93
ogdf::Triconnectivity::m_NEWNUM
NodeArray< int > m_NEWNUM
(second) dfs-number of v
Definition: Triconnectivity.h:222
ogdf::List::size
int size() const
Returns the number of elements in the list.
Definition: List.h:1488
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:51
ogdf::Triconnectivity::m_TYPE
EdgeArray< EdgeType > m_TYPE
type of edge e
Definition: Triconnectivity.h:220
ogdf::Triconnectivity::EdgeType
EdgeType
type of edges with respect to palm tree
Definition: Triconnectivity.h:158
ogdf::Triconnectivity
realizes Hopcroft/Tarjan algorithm for finding the triconnected components of a biconnected multi-gra...
Definition: Triconnectivity.h:50
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
ogdf::Triconnectivity::CompStruct
representation of a component
Definition: Triconnectivity.h:89
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::Triconnectivity::newComp
CompStruct & newComp(CompType t)
create a new empty component of type t
Definition: Triconnectivity.h:151
ogdf::Triconnectivity::m_start
node m_start
start node of dfs traversal
Definition: Triconnectivity.h:230
ogdf::Triconnectivity::TSTACK_notEOS
bool TSTACK_notEOS()
returns true iff end-of-stack marker is not on top of TSTACK
Definition: Triconnectivity.h:145
ogdf::Triconnectivity::CompStruct::m_edges
List< edge > m_edges
Definition: Triconnectivity.h:90
ogdf::List::pushBack
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1547
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716