Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00042 #ifdef _MSC_VER
00043 #pragma once
00044 #endif
00045
00046 #ifndef OGDF_CPLANAR_SUBCLUSTERED_ST_H
00047 #define OGDF_CPLANAR_SUBCLUSTERED_ST_H
00048
00049
00050 #include <ogdf/cluster/ClusterGraph.h>
00051 #include <ogdf/cluster/ClusterArray.h>
00052 #include <ogdf/basic/EdgeArray.h>
00053
00054 namespace ogdf {
00055
00057 class CPlanarSubClusteredST
00058 {
00059
00060 public:
00061
00062 CPlanarSubClusteredST() {};
00063
00065 virtual void call(const ClusterGraph& CG, EdgeArray<bool>& inST);
00068 virtual void call(const ClusterGraph& CG,
00069 EdgeArray<bool>& inST,
00070 EdgeArray<double>& weight);
00071
00072 private:
00073
00075 void dfsBuildOriginalST(
00076 node v,
00077 ClusterArray< EdgeArray<bool> > &treeEdges,
00078 EdgeArray<bool>& inST,
00079 NodeArray<bool> &visited);
00080
00081 void dfsBuildSpanningTree(node v,
00082 EdgeArray<bool> &treeEdges,
00083 NodeArray<bool> &visited);
00084
00088 void constructRepresentationGraphNodes(const ClusterGraph& CG,
00089 Graph& g,
00090 cluster c
00091 )
00092 {
00093
00094
00095 ListConstIterator<cluster> it;
00096 for (it = c->cBegin(); it.valid(); it++)
00097 {
00098 node v = g.newNode();
00099 m_cRepNode[*it] = v;
00100 }
00101
00102 ListConstIterator<node> itn;
00103 for (itn = c->nBegin(); itn.valid(); itn++)
00104 {
00105 node v = g.newNode();
00106 m_vRepNode[*itn] = v;
00107 }
00108 }
00109
00111 void constructRepresentationGraphEdges(const ClusterGraph& CG,
00112 ClusterArray<Graph*>& RepGraph)
00113 {
00114 edge e;
00115 forall_edges(e, CG.getGraph())
00116 {
00117
00118
00119 node u = e->source();
00120 node v = e->target();
00121 cluster uAncestor, vAncestor;
00122 cluster allocCluster =
00123 CG.commonClusterLastAncestors(u,v, uAncestor, vAncestor);
00124 m_allocCluster[e] = allocCluster;
00125
00126
00127
00128
00129
00130 if (uAncestor == vAncestor)
00131 {
00132 m_repEdge[e] = RepGraph[uAncestor]->newEdge(
00133 m_vRepNode[u], m_vRepNode[v]);
00134 }
00135 else
00136 {
00137 OGDF_ASSERT(!((uAncestor == CG.rootCluster())&&
00138 (vAncestor == CG.rootCluster())))
00139
00140
00141 if (uAncestor == CG.rootCluster())
00142 {
00143 m_repEdge[e] = RepGraph[uAncestor]->newEdge(
00144 m_vRepNode[u], m_cRepNode[vAncestor]);
00145 }
00146 else if (vAncestor == CG.rootCluster())
00147 {
00148 m_repEdge[e] = RepGraph[vAncestor]->newEdge(
00149 m_cRepNode[uAncestor], m_vRepNode[v]);
00150 }
00151 else
00152 {
00153 OGDF_ASSERT(allocCluster != 0)
00154
00155 node v1, v2;
00156 v1 = ( (uAncestor == 0) ? m_vRepNode[u] :
00157 m_cRepNode[uAncestor]);
00158 v2 = ( (vAncestor == 0) ? m_vRepNode[v] :
00159 m_cRepNode[vAncestor]);
00160 m_repEdge[e] = RepGraph[allocCluster]->newEdge(v1, v2);
00161 }
00162 }
00163
00164 }
00165
00166 }
00167
00169 void computeRepresentationGraphs(const ClusterGraph& CG,
00170 ClusterArray<Graph*>& RepGraph)
00171 {
00172 cluster c;
00173 forall_clusters(c, CG)
00174 {
00175 RepGraph[c] = new Graph;
00176 constructRepresentationGraphNodes(CG, *RepGraph[c], c);
00177 }
00178 constructRepresentationGraphEdges(CG, RepGraph);
00179 }
00180
00181 void deleteRepresentationGraphs(const ClusterGraph& CG,
00182 ClusterArray<Graph*>& RepGraph)
00183 {
00184 cluster c;
00185 forall_clusters(c, CG)
00186 {
00187 if (RepGraph[c])
00188 delete RepGraph[c];
00189 }
00190
00191 }
00192
00194 void initialize(const ClusterGraph& CG);
00195
00196
00197
00198
00199
00200
00201
00203 EdgeArray<cluster> m_allocCluster;
00205 EdgeArray<edge> m_repEdge;
00207 ClusterArray<node> m_cRepNode;
00208 NodeArray<node> m_vRepNode;
00209
00210
00211
00212
00213
00214 };
00215
00216 }
00217
00218
00219 #endif