Open
Graph Drawing
Framework

 v.2012.05
 

GEMLayout.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  
00046 #ifdef _MSC_VER
00047 #pragma once
00048 #endif
00049 
00050 #ifndef OGDF_FAST_LAYOUT_H
00051 #define OGDF_FAST_LAYOUT_H
00052 
00053 #include <ogdf/module/LayoutModule.h>
00054 #include <ogdf/basic/Math.h>
00055 
00056 
00057 namespace ogdf {
00058 
00059     class OGDF_EXPORT GraphCopy;
00060     class OGDF_EXPORT GraphCopyAttributes;
00061 
00062 //---------------------------------------------------------
00063 // GEMLayout
00064 //
00065 // Fast force-directed layout algorithm. See
00066 // - A. Frick, A. Ludwig, H. Mehldau: "A Fast Adaptive 
00067 //   Layout Algorithm for Undirected Graphs"
00068 //  
00069 //---------------------------------------------------------
00070 
00072 
00127 class OGDF_EXPORT GEMLayout : public LayoutModule
00128 {
00129 
00130     // algorithm parameters (see below)
00131 
00132     int m_numberOfRounds;           
00133     double m_minimalTemperature;    
00134     double m_initialTemperature;    
00135     double m_gravitationalConstant; 
00136     double m_desiredLength;         
00137     double m_maximalDisturbance;    
00138     double m_rotationAngle;         
00139     double m_oscillationAngle;      
00140     double m_rotationSensitivity;   
00141     double m_oscillationSensitivity;
00142     int m_attractionFormula;        
00143     double m_minDistCC;             
00144     double m_pageRatio;             
00145 
00146     // node data used by the algorithm
00147 
00148     NodeArray<double> m_impulseX; 
00149     NodeArray<double> m_impulseY; 
00150     NodeArray<double> m_localTemperature; 
00151     NodeArray<double> m_skewGauge; 
00152 
00153     // other data used by the algorithm
00154 
00155     double m_barycenterX; 
00156     double m_barycenterY; 
00157     double m_newImpulseX; 
00158     double m_newImpulseY; 
00159     double m_globalTemperature; 
00160     double m_cos; 
00161     double m_sin; 
00162 
00163 public:
00164 
00166     GEMLayout();
00167 
00169     GEMLayout(const GEMLayout &fl);
00170 
00171     // destructor
00172     ~GEMLayout();
00173 
00175     GEMLayout &operator=(const GEMLayout &fl);
00176 
00178     void call(GraphAttributes &GA);
00179 
00181     int numberOfRounds() const { return m_numberOfRounds; }
00182 
00184     void numberOfRounds(int n) {
00185         m_numberOfRounds = (n < 0) ? 0 : n;
00186     }
00187 
00189     double minimalTemperature() const { return m_minimalTemperature; }
00190 
00192     void minimalTemperature(double x) { 
00193         m_minimalTemperature = (x < 0) ? 0 : x; 
00194     }
00195 
00197     double initialTemperature() const { return m_initialTemperature; }
00198 
00200     void initialTemperature(double x) { 
00201         m_initialTemperature = (x < m_minimalTemperature) ? m_minimalTemperature : x; 
00202     }
00203 
00205     double gravitationalConstant() const { return m_gravitationalConstant; }
00206 
00209     void gravitationalConstant(double x) { 
00210         m_gravitationalConstant = (x < 0) ? 0 : x; 
00211     }
00212 
00214     double desiredLength() const { return m_desiredLength; }
00215 
00217     void desiredLength(double x) {
00218         m_desiredLength = (x < 0) ? 0 : x; 
00219     }
00220 
00222     double maximalDisturbance() const { return m_maximalDisturbance; }
00223 
00225     void maximalDisturbance(double x) {
00226         m_maximalDisturbance = (x < 0) ? 0 : x; 
00227     }
00228 
00230     double rotationAngle() const { return m_rotationAngle; }
00231 
00233     void rotationAngle(double x) { 
00234         if(x < 0) x = 0;
00235         if(x > Math::pi / 2.0) x = Math::pi / 2.0;
00236         m_rotationAngle = x; 
00237     }
00238 
00240     double oscillationAngle() const { return m_oscillationAngle; }
00241 
00243     void oscillationAngle(double x) { 
00244         if(x < 0) x = 0;
00245         if(x > Math::pi / 2.0) x = Math::pi / 2.0;
00246         m_oscillationAngle = x; 
00247     }
00248 
00250     double rotationSensitivity() const { return m_rotationSensitivity; }
00251 
00253     void rotationSensitivity(double x) { 
00254         if(x < 0) x = 0;
00255         if(x > 1) x = 1;
00256         m_rotationSensitivity = x; 
00257     }
00258 
00260     double oscillationSensitivity() const { return m_oscillationSensitivity; }
00261 
00263     void oscillationSensitivity(double x) { 
00264         if(x < 0) x = 0;
00265         if(x > 1) x = 1;
00266         m_oscillationSensitivity = x; 
00267     }
00268 
00270     int attractionFormula() const { return m_attractionFormula; }
00271 
00273     void attractionFormula(int n) { 
00274         if(n == 1 || n == 2) m_attractionFormula = n;
00275     }
00276 
00278     double minDistCC() const { return m_minDistCC; }
00279 
00281     void minDistCC(double x) { m_minDistCC = x; }
00282 
00284     double pageRatio() const { return m_pageRatio; }
00285 
00287     void pageRatio(double x) { m_pageRatio = x; }
00288 
00289 
00290 private:
00292     double length(double x,double y = 0) const {
00293         return sqrt(x * x + y * y);
00294     }
00295 
00297     double weight(node v) const {
00298         return (double)(v->degree()) / 2.5 + 1.0;
00299     }
00300 
00302     void computeImpulse(GraphCopy &GC, GraphCopyAttributes &AGC,node v);
00303 
00305     void updateNode(GraphCopy &GC, GraphCopyAttributes &AGC,node v);
00306 
00307     OGDF_NEW_DELETE
00308 };
00309 
00310 } // end namespace ogdf
00311 
00312 #endif
00313