Open
Graph Drawing
Framework

 v.2010.10
 

CconnectClusterPlanarEmbed.h

Go to the documentation of this file.
00001 /*
00002  * $Revision: 2027 $
00003  * 
00004  * last checkin:
00005  *   $Author: gutwenger $ 
00006  *   $Date: 2010-09-01 11:55:17 +0200 (Wed, 01 Sep 2010) $ 
00007  ***************************************************************/
00008  
00054 #ifdef _MSC_VER
00055 #pragma once
00056 #endif
00057 
00058 #ifndef OGDF_CCONNECT_CLUSTER_PLANAR_EMBED_H
00059 #define OGDF_CCONNECT_CLUSTER_PLANAR_EMBED_H
00060 
00061 
00062 #include <ogdf/internal/planarity/EmbedPQTree.h>
00063 #include <ogdf/cluster/ClusterArray.h>
00064 #include <ogdf/basic/Stack.h>
00065 #include <ogdf/internal/cluster/ClusterPQContainer.h>
00066 
00067 namespace ogdf {
00068 
00069 class OGDF_EXPORT CconnectClusterPlanarEmbed {
00070 
00071 
00072 public:
00073 
00074 
00075     enum ccErrorCode {none = 0, 
00076                       nonConnected = 1, 
00077                       nonCConnected = 2, 
00078                       nonPlanar = 3,
00079                       nonCPlanar = 4
00080     };
00081     ccErrorCode errCode() {return m_errorCode;}
00082 
00083 
00084     //*************************************************************************
00085     // Constructor
00086     CconnectClusterPlanarEmbed();
00087 
00088     // Destructor
00089     virtual ~CconnectClusterPlanarEmbed();
00090 
00091     // Tests if a ClusterGraph is C-planar and embedds it.
00092     virtual bool embed(ClusterGraph &C,Graph &G);
00093 
00094     // Tests if a ClusterGraph is C-planar and embedds it.
00095     // Specifies reason for non planarity
00096     virtual bool embed(ClusterGraph &C,Graph &G, char (&code)[124]);
00097 
00098 
00099 private:
00100 
00101     bool planarityTest(ClusterGraph &C,
00102                        cluster &act,
00103                        Graph &G);
00104 
00105     bool preProcess(ClusterGraph &Ccopy,Graph &Gcopy);
00106 
00107     bool preparation(Graph &subGraph,cluster &origCluster,node superSink);
00108 
00109     bool doEmbed(Graph           *biconComp,
00110                  NodeArray<int>  &numbering,            
00111                  cluster         &origCluster,
00112                  node             superSink,
00113                  Graph           &subGraph, 
00114                  EdgeArray<edge> &tableEdgesBiComp2SubGraph,
00115                  EdgeArray<edge> &tableEdgesSubGraph2BiComp,
00116                  NodeArray<node> &tableNodesBiComp2SubGraph);
00117 
00118 
00119 
00120 
00121     void entireEmbed(Graph &biconComp,
00122                      NodeArray<SListPure<adjEntry> > &entireEmbedding,
00123                      NodeArray<SListIterator<adjEntry> > &adjMarker,
00124                      NodeArray<bool> &mark,
00125                      node v);
00126 
00127     void recursiveEmbed(ClusterGraph &Ccopy,Graph &Gcopy);
00128 
00129     void prepareParallelEdges(Graph &G);
00130 
00131 
00132     void constructWheelGraph(ClusterGraph &C,
00133                              Graph &G,
00134                              cluster &parent,
00135                              cluster &origCl,
00136                              EmbedPQTree* T,
00137                              EdgeArray<node> &outgoingTable,
00138                              node superSink);
00139 
00140     void hubControl(Graph &G,NodeArray<bool> &hubs);
00141 
00142     void nonPlanarCleanup(ClusterGraph &Ccopy,Graph &Gcopy);
00143 
00144     void copyEmbedding(ClusterGraph &Ccopy,Graph &Gcopy,ClusterGraph &C,Graph &G);
00145 
00146 //---------------------------------------------------------
00147 // private member variables for testing a cluster graph
00148 //---------------------------------------------------------
00149 
00150     // Stores for every cluster the PQTree corresponding
00151     // to the biconnected component containing the outgoing
00152     // edges of the cluster.
00153     ClusterArray<EmbedPQTree*> m_clusterPQTree; 
00154 
00155     //save errorcode for postprocessing if not c-planar
00156     ccErrorCode m_errorCode;
00157     // For debugging purposes. Stores the reason for 
00158     // non cluster planarity.
00159     char errorCode[124];
00160     
00161 
00162     //private Members for handling parallel edges
00163     EdgeArray<ListPure<edge> >  m_parallelEdges;
00164     EdgeArray<bool>             m_isParallel;
00165     int m_parallelCount;
00166 
00167 
00168 
00169 //---------------------------------------------------------
00170 // private member variables for embedding a cluster graph
00171 //---------------------------------------------------------
00172 
00173     ClusterGraph *m_instance; //The graph that has to be embedded
00174 
00175 
00176     // Stores for every cluster the (partial) embedding of the
00177     // biconnected components not having outgoing
00178     // edges of the cluster.
00179     // The NodeArrays are associated with the subgraphs.
00180     // The ClusterArray is associtated with the original graph.
00181     ClusterArray<NodeArray<SListPure<adjEntry> >*> m_clusterEmbedding;
00182 
00183     // Stores for every cluster the subgraph constructed to test 
00184     // the planarity of the cluster
00185     // The ClusterArray is associated with the original graph.
00186     ClusterArray<Graph*>                m_clusterSubgraph; 
00187 
00188     // Marks for every subgraph of a cluster the nodes that are
00189     // hubs as true. 
00190     // The NodeArrays are associated with the subgraphs.
00191     // The ClusterArray is associated with the original graph.
00192     ClusterArray<NodeArray<bool> *>     m_clusterSubgraphHubs;
00193 
00194 
00195     // Stores for every node of every subgraph of a cluster 
00196     // if this node belongs to a wheel graph, corresponding to
00197     // a child cluster 
00198     // The NodeArrays are associated with the subgraphs.
00199     // The ClusterArray is associated with the original graph.
00200     ClusterArray<NodeArray<cluster> *>  m_clusterSubgraphWheelGraph;
00201 
00202 
00203     // Stores for every mode of every subgraph of a cluster its 
00204     // corresponding node on the original graph G, if there exists one.
00205     ClusterArray<NodeArray<node> *>     m_clusterNodeTableNew2Orig;
00206 
00207 
00208     ClusterArray<ClusterGraph*>         m_clusterClusterGraph; 
00209     ClusterArray<ClusterArray<cluster>*>m_clusterClusterTableOrig2New; 
00210     
00211     // When constructing a wheel graph, we store here for 
00212     // every wheel graph node the corresponding cluster
00213     // Array is associated with the cluster graph copy.
00214     NodeArray<cluster>                  m_wheelGraphNodes;
00215 
00216     // Stores for every node in the current graph, if
00217     // it is a hub.
00218     // Array is associated with the cluster graph copy.
00219     NodeArray<bool>                     m_currentHubs;
00220 
00221 
00222     // Stores for every cluster of Ccopy the corresponding cluster 
00223     // in the original graph. A key variable, since we track
00224     // all information via the original clusters.
00225     ClusterArray<cluster>   m_clusterTableCopy2Orig;
00226 
00227     // Needed to construct the ClusterArray m_clusterTableCopy2Orig.
00228     ClusterArray<cluster>   m_clusterTableOrig2Copy;
00229 
00230     // Stores for every subgraph the super sink of the subgraph.
00231     ClusterArray<node>      m_clusterSuperSink;
00232 
00233 
00234     // Stores for every node in Gcopy its corresponding node 
00235     // in the original graph unless the node belongs to 
00236     // a wheel graph. 
00237     // The NodeArray is associated with Gcopy.
00238     NodeArray<node>         m_nodeTableCopy2Orig;
00239     
00240     // Needed to construct the NodeArray m_nodeTableCopy2Orig.
00241     NodeArray<node>         m_nodeTableOrig2Copy;
00242 
00243 
00244     EdgeArray<Stack<edge>*> m_outgoingEdgesAnker;
00245     ClusterArray<EdgeArray<Stack<edge>*>*> m_clusterOutgoingEdgesAnker;
00246 
00247     // Stores for every original cluster all information on
00248     // the PQ-Tree that is necessary to construct the embedding.
00249     ClusterArray<ClusterPQContainer> m_clusterPQContainer;
00250 
00251     // Stores the clusters in calling order of the testing algorithm
00252     // The stack stores the clusters of the original graph.
00253     // Needed for recursive embed.
00254     Stack<cluster> m_callStack;
00255     
00256     // Is true for every original cluster, if the cluster does not
00257     // have a correspondand in the copy of the cluster graph.
00258     // This is the case if:
00259     // a. cluster is son of root cluster and does have exactly one
00260     //    childcluster and no nodes;
00261     // b. recursive version of a;
00262     // c. cluster does have no child clusters and no nodes;
00263     // d. recursive version of c.
00264     ClusterArray<bool> m_unsatisfiedCluster;
00265 
00266 
00267 };
00268 
00269 } // end namespace ogdf
00270 
00271 
00272 #endif