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/EdgeArray.h>
38 #include <ogdf/basic/GraphCopy.h>
39 #include <ogdf/basic/NodeArray.h>
40 
41 #include <ostream>
42 
43 namespace ogdf {
44 
49  explicit Triconnectivity(Graph* G);
50 
51 public:
56  explicit Triconnectivity(const Graph& G) : Triconnectivity(new GraphCopySimple(G)) {
57  m_deleteGraph = true;
58  };
59 
65  explicit Triconnectivity(Graph& G, bool modifyG = false)
66  : Triconnectivity(modifyG ? &G : new GraphCopySimple(G)) {
67  m_deleteGraph = !modifyG;
68  };
69 
77  Triconnectivity(const Graph& G, bool& isTric, node& s1, node& s2);
78 
79  Triconnectivity(const Triconnectivity&) = delete;
80 
81  ~Triconnectivity();
82 
84  enum class CompType { bond, polygon, triconnected };
85 
87  struct CompStruct {
90 
92  m_edges.pushBack(e);
93  return *this;
94  }
95 
97  m_edges.pushBack(e);
98  m_type = (m_edges.size() >= 4) ? CompType::triconnected : CompType::polygon;
99  }
100  };
101 
107 
112 
117  bool checkComp() const;
118 
119 private:
120  bool checkSepPair(edge eVirt) const;
121 
122  void clearStructures();
123 
126  void splitMultiEdges();
127 
129  int *m_TSTACK_h, *m_TSTACK_a, *m_TSTACK_b;
130  int m_top;
131 
133  void TSTACK_push(int h, int a, int b) {
134  m_TSTACK_h[++m_top] = h;
135  m_TSTACK_a[m_top] = a;
136  m_TSTACK_b[m_top] = b;
137  }
138 
140  void TSTACK_pushEOS() { m_TSTACK_a[++m_top] = -1; }
141 
143  bool TSTACK_notEOS() { return m_TSTACK_a[m_top] != -1; }
144 
146  CompStruct& newComp() { return m_component[m_numComp++]; }
147 
150  CompStruct& C = m_component[m_numComp++];
151  C.m_type = t;
152  return C;
153  }
154 
156  enum class EdgeType { unseen, tree, frond, removed };
157 
159  void DFS1(node v, node u);
161  void DFS1(node v, node u, node& s1);
162 
164  void buildAcceptableAdjStruct();
166  void DFS2();
167  void pathFinder(node v);
168 
170 
174  bool pathSearch(node init_v, bool fail_fast, node& s1, node& s2);
176  void afterRecursivePathSearch(const node v, const int vnum, const int outv,
177  const ListIterator<edge> it, const edge e, const node w, int wnum);
179  bool afterRecursivePathSearch(const node v, const int vnum, const int outv, const edge e,
180  const node w, const int wnum, node& s1, node& s2);
181 
183  void assembleTriconnectedComponents();
184 
186  void printOs(edge e) const;
187  void printStacks() const;
188 
190  int high(node v) { return (m_HIGHPT[v].empty()) ? 0 : m_HIGHPT[v].front(); }
191 
192  void delHigh(edge e) {
193  ListIterator<int> it = m_IN_HIGH[e];
194  if (it.valid()) {
195  node v = e->target();
196  m_HIGHPT[v].del(it);
197  }
198  }
199 
201  template<typename T>
202  T GCoriginal(T n) const {
203  if (m_deleteGraph) {
204  // TODO use common superclass of all GraphCopies
205  return dynamic_cast<GraphCopySimple*>(m_pG)->original(n);
206  } else {
207  return n;
208  }
209  }
210 
227 
230  bool m_newPath;
232 };
233 
234 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, Triconnectivity::CompType type);
235 
236 }
ogdf::ArrayBuffer< edge >
ogdf::Triconnectivity::m_ESTACK
ArrayBuffer< edge > m_ESTACK
stack of currently active edges
Definition: Triconnectivity.h:226
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::Triconnectivity::m_IN_ADJ
EdgeArray< ListIterator< edge > > m_IN_ADJ
pointer to element in adjacency list containing e
Definition: Triconnectivity.h:224
ogdf::Triconnectivity::m_NUMBER
NodeArray< int > m_NUMBER
(first) dfs-number of v
Definition: Triconnectivity.h:211
ogdf::Triconnectivity::m_A
NodeArray< List< edge > > m_A
adjacency list of v
Definition: Triconnectivity.h:219
ogdf::Triconnectivity::m_numCount
int m_numCount
counter for dfs-traversal
Definition: Triconnectivity.h:229
ogdf::Triconnectivity::m_FATHER
NodeArray< node > m_FATHER
father of v in palm tree
Definition: Triconnectivity.h:217
ogdf::Triconnectivity::m_ND
NodeArray< int > m_ND
number of descendants in palm tree
Definition: Triconnectivity.h:214
ogdf::Triconnectivity::TSTACK_push
void TSTACK_push(int h, int a, int b)
push a triple on TSTACK
Definition: Triconnectivity.h:133
ogdf::Triconnectivity::delHigh
void delHigh(edge e)
Definition: Triconnectivity.h:192
ogdf::Triconnectivity::TSTACK_pushEOS
void TSTACK_pushEOS()
push end-of-stack marker on TSTACK
Definition: Triconnectivity.h:140
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:143
ogdf::Triconnectivity::m_DEGREE
NodeArray< int > m_DEGREE
degree of v
Definition: Triconnectivity.h:215
ogdf::Triconnectivity::m_TSTACK_h
int * m_TSTACK_h
stack of triples
Definition: Triconnectivity.h:129
ogdf::GraphCopySimple
Copies of graphs with mapping between nodes and edges.
Definition: GraphCopy.h:254
ogdf::Triconnectivity::m_pG
Graph * m_pG
modifiable copy of G also containing virtual edges
Definition: Triconnectivity.h:103
ogdf::Triconnectivity::CompType
CompType
type of split-components / triconnected components
Definition: Triconnectivity.h:84
ogdf::Triconnectivity::m_NODEAT
Array< node > m_NODEAT
node with number i
Definition: Triconnectivity.h:216
ogdf::Triconnectivity::high
int high(node v)
returns high(v) value
Definition: Triconnectivity.h:190
ogdf::Triconnectivity::m_IN_HIGH
EdgeArray< ListIterator< int > > m_IN_HIGH
pointer to element in HIGHPT list containing e
Definition: Triconnectivity.h:225
ogdf::Triconnectivity::m_LOWPT1
NodeArray< int > m_LOWPT1
Definition: Triconnectivity.h:212
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::Triconnectivity::CompStruct::finishTricOrPoly
void finishTricOrPoly(edge e)
Definition: Triconnectivity.h:96
ogdf::Array
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:214
EdgeArray.h
Declaration and implementation of EdgeArray class.
ogdf::Triconnectivity::m_top
int m_top
Definition: Triconnectivity.h:130
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
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:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::Triconnectivity::m_component
Array< CompStruct > m_component
array of components
Definition: Triconnectivity.h:105
NodeArray.h
Declaration and implementation of NodeArray class.
ogdf::Triconnectivity::m_TREE_ARC
NodeArray< edge > m_TREE_ARC
tree arc entering v
Definition: Triconnectivity.h:222
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:56
ogdf::Triconnectivity::Triconnectivity
Triconnectivity(Graph &G, bool modifyG=false)
Divides G into triconnected components.
Definition: Triconnectivity.h:65
ogdf::Triconnectivity::m_numComp
int m_numComp
number of components
Definition: Triconnectivity.h:111
ogdf::Triconnectivity::m_HIGHPT
NodeArray< List< int > > m_HIGHPT
list of fronds entering v in the order they are visited
Definition: Triconnectivity.h:223
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:146
ogdf::Triconnectivity::m_LOWPT2
NodeArray< int > m_LOWPT2
Definition: Triconnectivity.h:213
ogdf::Triconnectivity::m_START
EdgeArray< bool > m_START
edge starts a path
Definition: Triconnectivity.h:221
ogdf::Triconnectivity::CompStruct::m_type
CompType m_type
Definition: Triconnectivity.h:89
ogdf::Triconnectivity::m_newPath
bool m_newPath
true iff we start a new path
Definition: Triconnectivity.h:230
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
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:231
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:202
ogdf::Triconnectivity::CompStruct::operator<<
CompStruct & operator<<(edge e)
Definition: Triconnectivity.h:91
ogdf::Triconnectivity::m_NEWNUM
NodeArray< int > m_NEWNUM
(second) dfs-number of v
Definition: Triconnectivity.h:220
ogdf::List::size
int size() const
Returns the number of elements in the list.
Definition: List.h:1478
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::Triconnectivity::m_TYPE
EdgeArray< EdgeType > m_TYPE
type of edge e
Definition: Triconnectivity.h:218
ogdf::Triconnectivity::EdgeType
EdgeType
type of edges with respect to palm tree
Definition: Triconnectivity.h:156
ogdf::Triconnectivity
realizes Hopcroft/Tarjan algorithm for finding the triconnected components of a biconnected multi-gra...
Definition: Triconnectivity.h:48
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::Triconnectivity::CompStruct
representation of a component
Definition: Triconnectivity.h:87
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::Triconnectivity::newComp
CompStruct & newComp(CompType t)
create a new empty component of type t
Definition: Triconnectivity.h:149
ogdf::Triconnectivity::m_start
node m_start
start node of dfs traversal
Definition: Triconnectivity.h:228
ogdf::Triconnectivity::TSTACK_notEOS
bool TSTACK_notEOS()
returns true iff end-of-stack marker is not on top of TSTACK
Definition: Triconnectivity.h:143
ogdf::Triconnectivity::CompStruct::m_edges
List< edge > m_edges
Definition: Triconnectivity.h:88
ogdf::List::pushBack
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: List.h:1537
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709