Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ConnectedSubgraph.h
Go to the documentation of this file.
1
32#pragma once
33
36
37namespace ogdf {
38namespace embedder {
39
40template<class T>
42public:
43 //constructor
45
61
82
102
111 static void call(const Graph& G, Graph& SG, const node& nG, const NodeArray<T>& nodeLengthG,
113 node nSG;
115 }
116
132
154
170 static void call(const Graph& G, Graph& SG, const node& nG, node& nSG,
174
185 static void call(const Graph& G, Graph& SG, const node& nG, NodeArray<node>& nSG_to_nG,
187
205
206private:
230};
231
232template<class T>
238 node nSG = SG.newNode();
240 nG_to_nSG[nG] = nSG;
241 nSG_to_nG[nSG] = nG;
242 nodeVisited[nG] = true;
243
244 for (adjEntry adj : nG->adjEntries) {
245 edge eG = adj->theEdge();
246 if (!nodeVisited[eG->source()]) {
247 recursion(SG, nodeVisited, edgeVisited, eG->source(), nodeLengthG, nodeLengthSG,
249 } else if (!nodeVisited[eG->target()]) {
250 recursion(SG, nodeVisited, edgeVisited, eG->target(), nodeLengthG, nodeLengthSG,
252 }
253 if (!edgeVisited[eG]) {
254 edge eSG = SG.newEdge(nG_to_nSG[eG->source()], nG_to_nSG[eG->target()]);
256 eG_to_eSG[eG] = eSG;
257 eSG_to_eG[eSG] = eG;
258 edgeVisited[eG] = true;
259 }
260 }
261}
262
263template<class T>
268 SG.clear();
269
272
273#if 0
274 const int n = G.numberOfNodes();
275 const int m = G.numberOfEdges();
276
277 bool* nodeVisited = new bool[n];
278 bool* edgeVisited = new bool[m];
279 for (int i = 0; i < n; i++)
280 nodeVisited[i] = false;
281 for (int i = 0; i < m; i++)
282 edgeVisited[i] = false;
283#endif
284 nSG_to_nG.init(SG);
285 eSG_to_eG.init(SG);
286 nodeLengthSG.init(SG);
287 edgeLengthSG.init(SG);
288 nG_to_nSG.init(G);
289 eG_to_eSG.init(G);
290
293 nSG = nG_to_nSG[nG];
294
295#if 0
296 delete[] nodeVisited;
297 delete[] edgeVisited;
298#endif
299}
300
301template<class T>
304 SG.clear();
305
308
309#if 0
310 bool* nodeVisited = new bool[G.numberOfNodes()];
311 bool* edgeVisited = new bool[G.numberOfEdges()];
312 for (int i = 0; i < G.numberOfNodes(); i++)
313 nodeVisited[i] = false;
314 for (int i = 0; i < G.numberOfEdges(); i++)
315 edgeVisited[i] = false;
316#endif
317 nSG_to_nG.init(SG);
318 eSG_to_eG.init(SG);
323 nG_to_nSG.init(G);
324 eG_to_eSG.init(G);
325
328
329#if 0
330 delete[] nodeVisited;
331 delete[] edgeVisited;
332#endif
333}
334
335}
336}
Declaration and implementation of EdgeArray class.
Declaration and implementation of NodeArray class.
Class for adjacency list elements.
Definition Graph_d.h:79
Dynamic arrays indexed with edges.
Definition EdgeArray.h:125
Class for the representation of edges.
Definition Graph_d.h:300
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Dynamic arrays indexed with nodes.
Definition NodeArray.h:125
Class for the representation of nodes.
Definition Graph_d.h:177
static void call(const Graph &G, Graph &SG, const node &nG, node &nSG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG, const EdgeArray< T > &edgeLengthG, EdgeArray< T > &edgeLengthSG)
Computes a connected subgraph SG of G containing node nG.
static void recursion(Graph &SG, NodeArray< bool > &nodeVisited, EdgeArray< bool > &edgeVisited, const node &nG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG, const EdgeArray< T > &edgeLengthG, EdgeArray< T > &edgeLengthSG, NodeArray< node > &nSG_to_nG, EdgeArray< edge > &eSG_to_eG, NodeArray< node > &nG_to_nSG, EdgeArray< edge > &eG_to_eSG)
Copies to SG node nG and recursively all adjacent edges and nodes.
static void call(const Graph &G, Graph &SG, const node &nG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG, const EdgeArray< T > &edgeLengthG, EdgeArray< T > &edgeLengthSG)
Computes a connected subgraph SG of G containing node nG.
static void call(const Graph &G, Graph &SG, const node &nG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG)
Computes a connected subgraph SG of G containing node nG.
static void call(const Graph &G, Graph &SG, const node &nG, node &nSG, NodeArray< node > &nSG_to_nG, EdgeArray< edge > &eSG_to_eG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG, const EdgeArray< T > &edgeLengthG, EdgeArray< T > &edgeLengthSG)
Computes a connected subgraph SG of G containing node nG.
static void call(const Graph &G, Graph &SG, const node &nG, NodeArray< node > &nSG_to_nG)
Computes a connected subgraph SG of G containing node nG.
static void call(const Graph &G, Graph &SG, const node &nG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG, NodeArray< node > &nG_to_nSG)
Computes a connected subgraph SG of G containing node nG.
static void call(const Graph &G, Graph &SG, const node &nG, node &nSG, const NodeArray< T > &nodeLengthG, NodeArray< T > &nodeLengthSG)
Computes a connected subgraph SG of G containing node nG.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.