Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

CPlanarSubClusteredST.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 #include <ogdf/basic/EdgeArray.h>
37 
38 namespace ogdf {
39 namespace cluster_planarity {
40 
43 {
44 public:
46 
48  virtual void call(const ClusterGraph& CG, EdgeArray<bool>& inST);
51  virtual void call(const ClusterGraph& CG,
52  EdgeArray<bool>& inST,
53  EdgeArray<double>& weight);
54 
55 private:
56 
58  void dfsBuildOriginalST(/*ClusterGraph& CG,*/
59  node v,
60  ClusterArray< EdgeArray<bool> > &treeEdges, //edges in repgraph
61  EdgeArray<bool>& inST, //original edges
62  NodeArray<bool> &visited);
63  //builds spanning tree on graph of node v in treeEdges
65  EdgeArray<bool> &treeEdges,
66  NodeArray<bool> &visited);
67 
72  Graph& g,
73  cluster c)
74  {
75 
76  // insert nodes for all child clusters
78  for (auto child : c->children) {
79  node v = g.newNode();
80  m_cRepNode[child] = v;
81  }
82  // insert nodes for all node entries in c
84  for (auto u : c->nodes) {
85  node v = g.newNode();
86  m_vRepNode[u] = v;
87  }
88  }
89 
92  ClusterArray<Graph*>& RepGraph)
93  {
94  for(edge e : CG.constGraph().edges)
95  {
96  //insert representation in RepGraph[allocation cluster]
97  //defined by lowest common ancestor of end points
98  node u = e->source();
99  node v = e->target();
100  cluster uAncestor, vAncestor;
101  cluster allocCluster =
102  CG.commonClusterLastAncestors(u,v, uAncestor, vAncestor);
103  m_allocCluster[e] = allocCluster;
104  //now derive the real ancestors (maybe the nodes themselves from
105  //the supplied clusters
106 
107  //Case1: both nodes in same cluster => connect the nodes in the
108  //cluster representation graph
109  if (uAncestor == vAncestor)
110  {
111  m_repEdge[e] = RepGraph[uAncestor]->newEdge(
112  m_vRepNode[u], m_vRepNode[v]);
113  } else {
114  OGDF_ASSERT(uAncestor != CG.rootCluster()
115  || vAncestor != CG.rootCluster());
116  //now only one node can be directly in rootcluster
117  //this case now seems to fall together with else else...
118  if (uAncestor == CG.rootCluster())
119  {
120  m_repEdge[e] = RepGraph[uAncestor]->newEdge(
121  m_vRepNode[u], m_cRepNode[vAncestor]);
122  } else if (vAncestor == CG.rootCluster()) {
123  m_repEdge[e] = RepGraph[vAncestor]->newEdge(
124  m_cRepNode[uAncestor], m_vRepNode[v]);
125  } else {
126  OGDF_ASSERT(allocCluster != nullptr);
127  //now create edge in lowest common cluster
128  node v1, v2;
129  v1 = ( (uAncestor == nullptr) ? m_vRepNode[u] :
130  m_cRepNode[uAncestor]);
131  v2 = ( (vAncestor == nullptr) ? m_vRepNode[v] :
132  m_cRepNode[vAncestor]);
133  m_repEdge[e] = RepGraph[allocCluster]->newEdge(v1, v2);
134  }
135  }
136  }
137  }
138 
141  ClusterArray<Graph*>& RepGraph)
142  {
143  for(cluster c : CG.clusters) {
144  RepGraph[c] = new Graph;
145  constructRepresentationGraphNodes(CG, *RepGraph[c], c);
146  }
147  constructRepresentationGraphEdges(CG, RepGraph);
148  }
149 
151  ClusterArray<Graph*>& RepGraph)
152  {
153  for(cluster c : CG.clusters) {
154  delete RepGraph[c];
155  }
156  }
157 
159  void initialize(const ClusterGraph& CG);
160 
161 #if 0
162  EdgeArray<int> m_edgeStatus;
164 #endif
165 
173 #if 0
174  int m_genDebug; //only for debugging
175 #endif
176 };
177 
178 }
179 }
void constructRepresentationGraphNodes(const ClusterGraph &CG, Graph &g, cluster c)
constructs for every cluster a graph representing its main structure (children & their connections) o...
cluster commonClusterLastAncestors(node v, node w, cluster &c1, cluster &c2) const
Returns the lowest common cluster lca and the highest ancestors on the path to lca.
Definition: ClusterGraph.h:580
void computeRepresentationGraphs(const ClusterGraph &CG, ClusterArray< Graph *> &RepGraph)
Computes representation graphs used for spanning tree computation.
void initialize(const ClusterGraph &CG)
Initializes some internally used members on CG.
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
EdgeArray< cluster > m_allocCluster
store the allocation cluster to avoid multiple computation
Constructs a c-planar subclustered spanning tree of the input by setting edgearray values...
ClusterArray< node > m_cRepNode
store the representation nodes for nodes and clusters
void dfsBuildOriginalST(node v, ClusterArray< EdgeArray< bool > > &treeEdges, EdgeArray< bool > &inST, NodeArray< bool > &visited)
builds spanning tree on original graph out of repgraphs STs
cluster rootCluster() const
Returns the root cluster.
Definition: ClusterGraph.h:400
Representation of clustered graphs.
Definition: ClusterGraph.h:291
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:568
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster...
Definition: ClusterGraph.h:74
Declaration and implementation of EdgeArray class.
Class for the representation of edges.
Definition: Graph_d.h:292
Dynamic arrays indexed with clusters.
Definition: ClusterArray.h:110
Class for the representation of nodes.
Definition: Graph_d.h:169
Encapsulates a pointer to a list element.
Definition: List.h:42
void dfsBuildSpanningTree(node v, EdgeArray< bool > &treeEdges, NodeArray< bool > &visited)
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:733
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
void constructRepresentationGraphEdges(const ClusterGraph &CG, ClusterArray< Graph *> &RepGraph)
insert rep edges for all edges in clustergraph
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
Definition: ClusterGraph.h:71
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:336
EdgeArray< edge > m_repEdge
store the representation edge
Declaration and implementation of ClusterArray class.
The namespace for all OGDF objects.
node newNode()
Creates a new node and returns it.
void deleteRepresentationGraphs(const ClusterGraph &CG, ClusterArray< Graph *> &RepGraph)
virtual void call(const ClusterGraph &CG, EdgeArray< bool > &inST)
sets values in inST according to membership in c-planar STGraph
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41