Open
Graph Drawing
Framework

 v.2012.05
 

PlanarAugmentation.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  
00042 #ifdef _MSC_VER
00043 #pragma once
00044 #endif
00045 
00046 #ifndef OGDF_PLANAR_AUGMENTATION_H
00047 #define OGDF_PLANAR_AUGMENTATION_H
00048 
00049 #include <ogdf/module/AugmentationModule.h>
00050 #include <ogdf/basic/List.h>
00051 #include <ogdf/decomposition/DynamicBCTree.h>
00052 
00053 namespace ogdf {
00054 
00055 
00056 enum paStopCause {paPlanarity, paCDegree, paBDegree, paRoot};
00057 
00058 
00059 class PlanarAugmentation;
00060 class labelStruct;
00061 
00062 
00063 typedef labelStruct* label;
00064 
00072 class labelStruct {
00073 
00074 friend class OGDF_EXPORT PlanarAugmentation;
00075 friend class OGDF_EXPORT PlanarAugmentationFix;
00076 
00077 private:
00078 
00085     node m_parent;
00089     node m_head;
00093     List<node> m_pendants;
00098     paStopCause m_stopCause;
00099 
00100 public:
00101     labelStruct(node parent, node cutvertex, paStopCause sc = paBDegree) {
00102         m_parent = parent;
00103         m_head = cutvertex;
00104         m_stopCause = sc;
00105     };
00106 
00107     bool isBLabel() {
00108         return (m_parent != 0);
00109     };
00110 
00111     bool isCLabel() {
00112         return (m_parent == 0);
00113     };
00114 
00116     node getPendant(int nr) {
00117         return (nr < m_pendants.size()) ? (*(m_pendants.get(nr))) : 0;
00118     };
00119 
00120     node getFirstPendant() {
00121         return (m_pendants.size() > 0) ? m_pendants.front() : 0;
00122     };
00123 
00124     node getLastPendant() {
00125         return (m_pendants.size() > 0) ? m_pendants.back() : 0;
00126     };
00127     
00129     int size() {
00130         return m_pendants.size();
00131     };
00132     
00133     void removePendant(node pendant);
00134 
00135     void removePendant(ListIterator<node> it){
00136         m_pendants.del(it);
00137     };
00138 
00139     void removeFirstPendant() {
00140         if (m_pendants.size() > 0){
00141             m_pendants.popFront();
00142         }
00143     };
00144     
00145     void addPendant(node pendant) {
00146         m_pendants.pushBack(pendant);
00147     };
00148 
00149     void deleteAllPendants() {
00150         m_pendants.clear();
00151     };
00152 
00154     node parent() {
00155         return (m_parent != 0) ? m_parent : m_head;
00156     };
00157 
00159     node head() {
00160         return m_head;
00161     };
00162     
00163     void setParent(node newParent){
00164         m_parent = newParent;
00165     }
00166     
00167     void setHead(node newHead){
00168         m_head = newHead;
00169     }
00170     
00171     paStopCause stopCause(){
00172         return m_stopCause; 
00173     }
00174     
00175     void stopCause(paStopCause sc){
00176         m_stopCause = sc;   
00177     }
00178 
00179     OGDF_NEW_DELETE
00180 }; // class labelStruct
00181 
00182 
00183 
00200 class OGDF_EXPORT PlanarAugmentation : public AugmentationModule {
00201 
00202 public:
00204     PlanarAugmentation() { }
00205 
00206     ~PlanarAugmentation() { }
00207 
00208 protected:
00215     void doCall(Graph& G, List<edge>& L);
00216 
00217     
00218 private:
00222     int m_nPlanarityTests;
00223     
00227     Graph* m_pGraph;
00231     DynamicBCTree* m_pBCTree;
00232     
00236     List<edge>* m_pResult;
00237     
00241     List<label> m_labels;
00245     List<node> m_pendants;
00246 
00250     List<node> m_pendantsToDel;
00251     
00255     NodeArray<label> m_belongsTo;
00259     NodeArray< ListIterator<label> > m_isLabel;
00260 
00268     NodeArray< SList<adjEntry> > m_adjNonChildren;  
00269 
00270 
00271 private:
00272 
00276     void augment();
00277     
00282     void makeConnectedByPendants();
00283 
00291     void reduceChain(node p, label labelOld = 0);
00292 
00302     paStopCause followPath(node v, node& last);
00303 
00310     bool planarityCheck(node v1, node v2);
00311     
00319     node adjToCutvertex(node v, node cutvertex = 0);
00320     
00325     node findLastBefore(node pendant, node ancestor);
00326 
00331     void deletePendant(node p, bool removeFromLabel = true);
00335     void addPendant(node p, label& l);
00336     
00342     edge connectPendants(node pendant1, node pendant2);
00346     void removeAllPendants(label& l);
00347 
00351     void joinPendants(label& l);
00352 
00356     void connectInsideLabel(label& l);
00357 
00363     ListIterator<label> insertLabel(label l);
00364 
00368     void deleteLabel(label& l, bool removePendants = true);
00369 
00374     void connectLabels(label first, label second);
00375 
00379     label newLabel(node cutvertex, node p, paStopCause whyStop);
00380 
00390     bool findMatching(label& first, label& second);
00391     
00396     bool connectCondition(label a, label b);
00397 
00404     void updateAdjNonChildren(node newBlock, SList<node>& path);
00405 
00409     void modifyBCRoot(node oldRoot, node newRoot);
00410 
00416     void updateNewEdges(const SList<edge> &newEdges);
00417 
00421     void terminate();
00422     
00423 };  // class PlanarAugmentation
00424 
00425 
00426 } // namespace ogdf
00427 
00428 #endif