Open
Graph Drawing
Framework

 v.2012.07
 

RadialTreeLayout.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2566 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-07 23:10:08 +0200 (Sa, 07. Jul 2012) $
7  ***************************************************************/
8 
48 #ifdef _MSC_VER
49 #pragma once
50 #endif
51 
52 #ifndef OGDF_RADIAL_TREE_LAYOUT_H
53 #define OGDF_RADIAL_TREE_LAYOUT_H
54 
56 #include <ogdf/basic/SList.h>
57 
58 
59 namespace ogdf {
60 
61 
63 
83 {
84 public:
89  rootIsCenter
90  };
91 
92 private:
93  double m_levelDistance;
95 
97 
99 
105 
108 
111 
113  double m_outerRadius;
114 
115  struct Group
116  {
118 
121  double m_sumD;
122  double m_sumW;
123  double m_leftAdd;
124  double m_rightAdd;
125 
127  m_data = data;
128  m_leafGroup = (v->degree() == 1);
129  m_nodes.pushBack(v);
130  m_sumD = m_data->diameter()[v] + m_data->levelDistance();
131  m_sumW = m_data->leaves()[v];
132  m_leftAdd = m_rightAdd = 0.0;
133  }
134 
135  bool isSameType(node v) const {
136  return (m_leafGroup == (v->degree() == 1));
137  }
138 
139  void append(node v) {
140  m_nodes.pushBack(v);
141  m_sumD += m_data->diameter()[v] + m_data->levelDistance();
142  m_sumW += m_data->leaves()[v];
143  }
144 
145  double add() const { return m_leftAdd + m_rightAdd; }
146  node leftVertex () const { return m_nodes.front(); }
147  node rightVertex() const { return m_nodes.back (); }
148  };
149 
150  class Grouping : public List<Group>
151  {
152  public:
153  void computeAdd(double &D, double &W);
154  };
155 
157 
158 public:
161 
164 
165  // destructor
166  ~RadialTreeLayout();
167 
169  RadialTreeLayout &operator=(const RadialTreeLayout &tl);
170 
172 
179  void call(GraphAttributes &GA);
180 
181 
182  // option that determines the minimal vertical distance
183  // required between levels
184 
186  double levelDistance() const { return m_levelDistance; }
187 
189  void levelDistance(double x) { m_levelDistance = x; }
190 
191  // option that determines the minimal horizontal distance
192  // required between trees in the forest
193 
195  double connectedComponentDistance() const { return m_connectedComponentDistance; }
196 
198  void connectedComponentDistance(double x) { m_connectedComponentDistance = x; }
199 
200  // option that determines if the root is on the top or on the bottom
201 
203  RootSelectionType rootSelection() const { return m_selectRoot; }
204 
206  void rootSelection(RootSelectionType sel) { m_selectRoot = sel; }
207 
208  const NodeArray<double> &diameter() const { return m_diameter; }
209  const NodeArray<double> &leaves() const { return m_leaves; }
210 
211 private:
212  void FindRoot(const Graph &G);
213  void ComputeLevels(const Graph &G);
214  void ComputeDiameters(GraphAttributes &AG);
215  void ComputeAngles(const Graph &G);
216  void ComputeCoordinates(GraphAttributes &AG);
217  void ComputeGrouping(int i);
218 
220 };
221 
222 } // end namespace ogdf
223 
224 #endif
225