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