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