Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

CPlanarSubClusteredST.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
35 #include <ogdf/basic/GraphList.h>
36 #include <ogdf/basic/List.h>
37 #include <ogdf/basic/basic.h>
39 
40 namespace ogdf {
41 namespace cluster_planarity {
42 
45 public:
47 
49  virtual void call(const ClusterGraph& CG, EdgeArray<bool>& inST);
52  virtual void call(const ClusterGraph& CG, EdgeArray<bool>& inST, EdgeArray<double>& weight);
53 
54 private:
56  void dfsBuildOriginalST(/*ClusterGraph& CG,*/
57  node v,
58  ClusterArray<EdgeArray<bool>>& treeEdges, //edges in repgraph
59  EdgeArray<bool>& inST, //original edges
60  NodeArray<bool>& visited);
61  //builds spanning tree on graph of node v in treeEdges
62  void dfsBuildSpanningTree(node v, EdgeArray<bool>& treeEdges, NodeArray<bool>& visited);
63 
68  // insert nodes for all child clusters
70  for (auto child : c->children) {
71  node v = g.newNode();
72  m_cRepNode[child] = v;
73  }
74  // insert nodes for all node entries in c
76  for (auto u : c->nodes) {
77  node v = g.newNode();
78  m_vRepNode[u] = v;
79  }
80  }
81 
84  for (edge e : CG.constGraph().edges) {
85  //insert representation in RepGraph[allocation cluster]
86  //defined by lowest common ancestor of end points
87  node u = e->source();
88  node v = e->target();
89  cluster uAncestor, vAncestor;
90  cluster allocCluster = CG.commonClusterLastAncestors(u, v, uAncestor, vAncestor);
91  m_allocCluster[e] = allocCluster;
92  //now derive the real ancestors (maybe the nodes themselves from
93  //the supplied clusters
94 
95  //Case1: both nodes in same cluster => connect the nodes in the
96  //cluster representation graph
97  if (uAncestor == vAncestor) {
98  m_repEdge[e] = RepGraph[uAncestor]->newEdge(m_vRepNode[u], m_vRepNode[v]);
99  } else {
100  OGDF_ASSERT(uAncestor != CG.rootCluster() || vAncestor != CG.rootCluster());
101  //now only one node can be directly in rootcluster
102  //this case now seems to fall together with else else...
103  if (uAncestor == CG.rootCluster()) {
104  m_repEdge[e] = RepGraph[uAncestor]->newEdge(m_vRepNode[u], m_cRepNode[vAncestor]);
105  } else if (vAncestor == CG.rootCluster()) {
106  m_repEdge[e] = RepGraph[vAncestor]->newEdge(m_cRepNode[uAncestor], m_vRepNode[v]);
107  } else {
108  OGDF_ASSERT(allocCluster != nullptr);
109  //now create edge in lowest common cluster
110  node v1, v2;
111  v1 = ((uAncestor == nullptr) ? m_vRepNode[u] : m_cRepNode[uAncestor]);
112  v2 = ((vAncestor == nullptr) ? m_vRepNode[v] : m_cRepNode[vAncestor]);
113  m_repEdge[e] = RepGraph[allocCluster]->newEdge(v1, v2);
114  }
115  }
116  }
117  }
118 
121  for (cluster c : CG.clusters) {
122  RepGraph[c] = new Graph;
123  constructRepresentationGraphNodes(CG, *RepGraph[c], c);
124  }
125  constructRepresentationGraphEdges(CG, RepGraph);
126  }
127 
129  for (cluster c : CG.clusters) {
130  delete RepGraph[c];
131  }
132  }
133 
135  void initialize(const ClusterGraph& CG);
136 
137 #if 0
138  EdgeArray<int> m_edgeStatus;
140 #endif
141 
149 #if 0
150  int m_genDebug; //only for debugging
151 #endif
152 };
153 
154 }
155 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::cluster_planarity::CPlanarSubClusteredST::initialize
void initialize(const ClusterGraph &CG)
Initializes some internally used members on CG.
Graph.h
Includes declaration of graph class.
ogdf::cluster_planarity::CPlanarSubClusteredST::constructRepresentationGraphEdges
void constructRepresentationGraphEdges(const ClusterGraph &CG, ClusterArray< Graph * > &RepGraph)
insert rep edges for all edges in clustergraph
Definition: CPlanarSubClusteredST.h:83
ogdf::cluster_planarity::CPlanarSubClusteredST::m_cRepNode
ClusterArray< node > m_cRepNode
store the representation nodes for nodes and clusters
Definition: CPlanarSubClusteredST.h:147
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::ClusterGraph::constGraph
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:804
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:311
ogdf::cluster_planarity::CPlanarSubClusteredST
Constructs a c-planar subclustered spanning tree of the input by setting edgearray values.
Definition: CPlanarSubClusteredST.h:44
ogdf::cluster_planarity::CPlanarSubClusteredST::dfsBuildSpanningTree
void dfsBuildSpanningTree(node v, EdgeArray< bool > &treeEdges, NodeArray< bool > &visited)
ogdf::ClusterElement::children
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster.
Definition: ClusterGraph.h:81
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::ClusterGraph::clusters
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:384
ogdf::cluster_planarity::CPlanarSubClusteredST::m_vRepNode
NodeArray< node > m_vRepNode
Definition: CPlanarSubClusteredST.h:148
ogdf::cluster_planarity::CPlanarSubClusteredST::deleteRepresentationGraphs
void deleteRepresentationGraphs(const ClusterGraph &CG, ClusterArray< Graph * > &RepGraph)
Definition: CPlanarSubClusteredST.h:128
GraphList.h
Decralation of GraphElement and GraphList classes.
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::cluster_planarity::CPlanarSubClusteredST::constructRepresentationGraphNodes
void constructRepresentationGraphNodes(const ClusterGraph &CG, Graph &g, cluster c)
constructs for every cluster a graph representing its main structure (children & their connections) o...
Definition: CPlanarSubClusteredST.h:67
ogdf::ClusterGraph::commonClusterLastAncestors
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:633
ogdf::ClusterGraph::rootCluster
cluster rootCluster() const
Returns the root cluster.
Definition: ClusterGraph.h:440
ogdf::Graph::edges
internal::GraphObjectContainer< EdgeElement > edges
The container containing all edge objects.
Definition: Graph_d.h:935
basic.h
Basic declarations, included by all source files.
ogdf::cluster_planarity::CPlanarSubClusteredST::m_allocCluster
EdgeArray< cluster > m_allocCluster
store the allocation cluster to avoid multiple computation
Definition: CPlanarSubClusteredST.h:143
ogdf::Graph::newNode
node newNode(int index=-1)
Creates a new node and returns it.
Definition: Graph_d.h:1064
ogdf::cluster_planarity::CPlanarSubClusteredST::CPlanarSubClusteredST
CPlanarSubClusteredST()
Definition: CPlanarSubClusteredST.h:46
ogdf::cluster_planarity::CPlanarSubClusteredST::dfsBuildOriginalST
void dfsBuildOriginalST(node v, ClusterArray< EdgeArray< bool >> &treeEdges, EdgeArray< bool > &inST, NodeArray< bool > &visited)
builds spanning tree on original graph out of repgraphs STs
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ClusterGraph.h
Derived class of GraphObserver providing additional functionality to handle clustered graphs.
ogdf::cluster_planarity::CPlanarSubClusteredST::computeRepresentationGraphs
void computeRepresentationGraphs(const ClusterGraph &CG, ClusterArray< Graph * > &RepGraph)
Computes representation graphs used for spanning tree computation.
Definition: CPlanarSubClusteredST.h:120
List.h
Declaration of doubly linked lists and iterators.
ogdf::cluster_planarity::CPlanarSubClusteredST::m_repEdge
EdgeArray< edge > m_repEdge
store the representation edge
Definition: CPlanarSubClusteredST.h:145
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:51
ogdf::ClusterElement::nodes
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
Definition: ClusterGraph.h:78
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::cluster_planarity::CPlanarSubClusteredST::call
virtual void call(const ClusterGraph &CG, EdgeArray< bool > &inST)
sets values in inST according to membership in c-planar STGraph
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716