Open
Graph Drawing
Framework

 v.2010.10
 

BalloonLayout.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  
00057 /*
00058  * The layout is computed by first computing a spanning tree
00059  * of the graph that is then used to derive the vertices' coordinates.
00060  * First, the radii at each vertex are computed.
00061  * Then, depending on the embedding option, the order of the 
00062  * edges around each vertex is optimized to maximize angular
00063  * resolution and to minimize the aspect ratio.
00064  * 
00065  * Finally, the layout is shifted into the positive quadrant
00066  * of the cartesian plane
00067  * */
00068 #ifdef _MSC_VER
00069 #pragma once
00070 #endif
00071 
00072 #ifndef OGDF_BALLOON_LAYOUT_H_
00073 #define OGDF_BALLOON_LAYOUT_H_
00074 
00075 #include <ogdf/module/LayoutModule.h>
00076 #include <ogdf/basic/List.h>
00077 
00078 
00079 namespace ogdf {
00080 
00081 class OGDF_EXPORT BalloonLayout : public LayoutModule
00082 {
00083  public:
00084     //Root may be defined by center of the graph
00085     //Directed cases: source/sink
00086     enum RootSelection {rootCenter, rootHighestDegree};
00087     //either keep the given embedding or optimize
00088     //the order wrto angular resolution and minimum aspect ratio
00089     enum ChildOrder {orderFixed, orderOptimized};
00090     //compute tree by different methods
00091     enum TreeComputation {treeBfs, treeDfs, treeBfsRandom};
00093     BalloonLayout();
00094     virtual ~BalloonLayout();
00096     BalloonLayout &operator=(const BalloonLayout &bl);
00097     
00099     virtual void call(GraphAttributes & AG);
00100     
00104     virtual void callFractal(GraphAttributes & AG, double ratio = 0.3)
00105     {
00106         bool even = getEvenAngles();
00107         setEvenAngles(true);
00108         call(AG);
00109         setEvenAngles(even);
00110     }
00111     
00113     void setEvenAngles(bool b) {m_evenAngles = b;}
00115     bool getEvenAngles() {return m_evenAngles;}
00116     
00117     
00118     
00119  protected:
00123     void computeTree(const Graph &G);
00125     void computeBFSTree(const Graph &G, node v);
00128     void selectRoot(const Graph &G);
00129     //------------------------------------------------
00135     #ifdef OGDF_DEBUG
00136     void computeRadii(GraphAttributes &AG);
00137     #else
00138     void computeRadii(const GraphAttributes &AG);
00139     #endif
00140 
00141     void computeAngles(const Graph &G);
00143     void computeCoordinates(GraphAttributes &AG);
00144     
00145  private:
00146     NodeArray<double> m_radius; 
00147     NodeArray<double> m_oRadius; 
00148     NodeArray<double> m_maxChildRadius; 
00149     NodeArray<node>   m_parent; 
00150     NodeArray<int>    m_childCount; 
00151     NodeArray<double> m_angle; 
00152     NodeArray<double> m_estimate; 
00153     NodeArray<double> m_size;   
00154    
00155     NodeArray< List<node> > m_childList;
00156     #ifdef OGDF_DEBUG
00157 
00158     void checkTree(const Graph &G, bool treeRoot = true); 
00159     EdgeArray<bool> *m_treeEdge; 
00160     #endif
00161     
00162     //-----------------------
00163     //optimization parameters    
00164     RootSelection     m_rootSelection; 
00165     node              m_treeRoot; 
00166     node              m_root;     
00167     
00168     double            m_estimateFactor; 
00169                                         //estimate to compute radius.
00170     double            m_fractalRatio;   
00171     
00172     ChildOrder        m_childOrder; 
00173     TreeComputation   m_treeComputation; 
00174     bool              m_evenAngles; 
00175     
00176     void check(Graph &G); 
00177     
00178     OGDF_NEW_DELETE
00179 }; //class BalloonLayout
00180 
00181 }//end namespace ogdf
00182 #endif /*BALLOONLAYOUT_H_*/