Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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 (it = c->cBegin(); it.valid(); ++it)
79  {
80  node v = g.newNode();
81  m_cRepNode[*it] = v;
82  }//for
83  //insert nodes for all node entries in c
85  for (itn = c->nBegin(); itn.valid(); ++itn)
86  {
87  node v = g.newNode();
88  m_vRepNode[*itn] = v;
89  }//for
90  }//constructRepresentationGraphNodes
91 
94  ClusterArray<Graph*>& RepGraph)
95  {
96  for(edge e : CG.constGraph().edges)
97  {
98  //insert representation in RepGraph[allocation cluster]
99  //defined by lowest common ancestor of end points
100  node u = e->source();
101  node v = e->target();
102  cluster uAncestor, vAncestor;
103  cluster allocCluster =
104  CG.commonClusterLastAncestors(u,v, uAncestor, vAncestor);
105  m_allocCluster[e] = allocCluster;
106  //now derive the real ancestors (maybe the nodes themselves from
107  //the supplied clusters
108 
109  //Case1: both nodes in same cluster => connect the nodes in the
110  //cluster representation graph
111  if (uAncestor == vAncestor)
112  {
113  m_repEdge[e] = RepGraph[uAncestor]->newEdge(
114  m_vRepNode[u], m_vRepNode[v]);
115  }//if
116  else
117  {
118  OGDF_ASSERT(uAncestor != CG.rootCluster()
119  || vAncestor != CG.rootCluster());
120  //now only one node can be directly in rootcluster
121  //this case now seems to fall together with else else...
122  if (uAncestor == CG.rootCluster())
123  {
124  m_repEdge[e] = RepGraph[uAncestor]->newEdge(
125  m_vRepNode[u], m_cRepNode[vAncestor]);
126  }//if u in rootcluster
127  else if (vAncestor == CG.rootCluster())
128  {
129  m_repEdge[e] = RepGraph[vAncestor]->newEdge(
130  m_cRepNode[uAncestor], m_vRepNode[v]);
131  }//if v in rootcluster
132  else
133  {
134  OGDF_ASSERT(allocCluster != nullptr);
135  //now create edge in lowest common cluster
136  node v1, v2;
137  v1 = ( (uAncestor == nullptr) ? m_vRepNode[u] :
138  m_cRepNode[uAncestor]);
139  v2 = ( (vAncestor == nullptr) ? m_vRepNode[v] :
140  m_cRepNode[vAncestor]);
141  m_repEdge[e] = RepGraph[allocCluster]->newEdge(v1, v2);
142  }
143  }//else
144 
145  }//foralledges
146  //m_repEdge
147  }//constructRepresentationGraphEdges
148 
151  ClusterArray<Graph*>& RepGraph)
152  {
153  for(cluster c : CG.clusters) {
154  RepGraph[c] = new Graph;
155  constructRepresentationGraphNodes(CG, *RepGraph[c], c);
156  }
157  constructRepresentationGraphEdges(CG, RepGraph);
158  }//computeRepresentationGraphs
159 
161  ClusterArray<Graph*>& RepGraph)
162  {
163  for(cluster c : CG.clusters) {
164  delete RepGraph[c];
165  }
166 
167  }//deleteRepresentationGraphs
168 
170  void initialize(const ClusterGraph& CG);
171 
172 #if 0
173  EdgeArray<int> m_edgeStatus;
175 #endif
176 
184 #if 0
185  int m_genDebug; //only for debugging
186 #endif
187 };
188 
189 }
190 }
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...
ListConstIterator< node > nBegin() const
Returns the first element in list of child nodes.
Definition: ClusterGraph.h:202
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
EdgeArray< cluster > m_allocCluster
store the allocation cluster to avoid multiple computation
static const int Graph
Definition: GmlParser.h:59
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:548
Declaration and implementation of EdgeArray class.
Class for the representation of edges.
Definition: Graph_d.h:291
Dynamic arrays indexed with clusters.
Definition: ClusterArray.h:110
Class for the representation of nodes.
Definition: Graph_d.h:167
Encapsulates a pointer to a list element.
Definition: List.h:41
void dfsBuildSpanningTree(node v, EdgeArray< bool > &treeEdges, NodeArray< bool > &visited)
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:736
ListConstIterator< ClusterElement * > cBegin() const
Returns the first element in the list of child clusters.
Definition: ClusterGraph.h:193
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
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)
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:112
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