Open
Graph Drawing
Framework

 v.2012.05
 

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