Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

RadialTreeLayout.h
Go to the documentation of this file.
1 
36 #pragma once
37 
39 #include <ogdf/basic/SList.h>
40 
41 
42 namespace ogdf {
43 
44 
46 
66 {
67 public:
69  enum class RootSelectionType {
70  Source,
71  Sink,
72  Center
73  };
74 
75 private:
76  double m_levelDistance;
78 
80 
82 
88 
91 
94 
96  double m_outerRadius;
97 
98  struct Group
99  {
101 
104  double m_sumD;
105  double m_sumW;
106  double m_leftAdd;
107  double m_rightAdd;
108 
110  m_data = data;
111  m_leafGroup = (v->degree() == 1);
112  m_nodes.pushBack(v);
113  m_sumD = m_data->diameter()[v] + m_data->levelDistance();
114  m_sumW = m_data->leaves()[v];
115  m_leftAdd = m_rightAdd = 0.0;
116  }
117 
118  bool isSameType(node v) const {
119  return m_leafGroup == (v->degree() == 1);
120  }
121 
122  void append(node v) {
123  m_nodes.pushBack(v);
124  m_sumD += m_data->diameter()[v] + m_data->levelDistance();
125  m_sumW += m_data->leaves()[v];
126  }
127 
128  double add() const { return m_leftAdd + m_rightAdd; }
129  node leftVertex () const { return m_nodes.front(); }
130  node rightVertex() const { return m_nodes.back (); }
131  };
132 
133  class Grouping : public List<Group>
134  {
135  public:
136  void computeAdd(double &D, double &W);
137  };
138 
140 
141 public:
144 
147 
148  // destructor
149  ~RadialTreeLayout();
150 
152  RadialTreeLayout &operator=(const RadialTreeLayout &tl);
153 
155 
162  virtual void call(GraphAttributes &GA) override;
163 
164 
165  // option that determines the minimal vertical distance
166  // required between levels
167 
169  double levelDistance() const { return m_levelDistance; }
170 
172  void levelDistance(double x) { m_levelDistance = x; }
173 
174  // option that determines the minimal horizontal distance
175  // required between trees in the forest
176 
178  double connectedComponentDistance() const { return m_connectedComponentDistance; }
179 
181  void connectedComponentDistance(double x) { m_connectedComponentDistance = x; }
182 
183  // option that determines if the root is on the top or on the bottom
184 
186  RootSelectionType rootSelection() const { return m_selectRoot; }
187 
189  void rootSelection(RootSelectionType sel) { m_selectRoot = sel; }
190 
191  const NodeArray<double> &diameter() const { return m_diameter; }
192  const NodeArray<double> &leaves() const { return m_leaves; }
193 
194 private:
195  void FindRoot(const Graph &G);
196  void ComputeLevels(const Graph &G);
197  void ComputeDiameters(GraphAttributes &AG);
198  void ComputeAngles(const Graph &G);
199  void ComputeCoordinates(GraphAttributes &AG);
200  void ComputeGrouping(int i);
201 
203 };
204 
205 } // end namespace ogdf
Declaration of singly linked lists and iterators.
The parameterized class Array implements dynamic arrays of type E.
Definition: Array.h:56
double m_outerRadius
The radius of circle bounding the drawing.
RootSelectionType
Selection strategies for root of the tree.
NodeArray< double > m_wedge
The wedge reserved for subtree.
const_reference back() const
Returns a reference to the last element.
Definition: SList.h:256
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
NodeArray< Grouping > m_grouping
void rootSelection(RootSelectionType sel)
Sets the option rootSelection to sel.
RootSelectionType rootSelection() const
Returns the option rootSelection.
Singly linked lists.
Definition: SList.h:38
int degree() const
Returns the degree of the node (indegree + outdegree).
Definition: Graph_d.h:208
NodeArray< int > m_level
The level of a node.
NodeArray< double > m_leaves
The weighted number of leaves in subtree.
NodeArray< double > m_diameter
The diameter of a circle bounding a node.
The radial tree layout algorithm.
NodeArray< double > m_angle
The angle of node center (for placement).
iterator pushBack(const E &x)
Adds element x at the end of the list.
Definition: SList.h:455
Stores additional attributes of a graph (like layout information).
Array< double > m_width
The width of a circle.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
node m_root
The root of the tree.
void levelDistance(double x)
Sets the option levelDistance to x.
NodeArray< node > m_parent
The parent of a node (0 if root).
Group(RadialTreeLayout *data, node v)
int m_numLevels
The number of levels (root is on level 0).
Declaration of interface for layout algorithms (class LayoutModule)
Class for the representation of nodes.
Definition: Graph_d.h:167
const_reference front() const
Returns a reference to the first element.
Definition: SList.h:238
#define OGDF_NEW_DELETE
Makes the class use OGDF&#39;s memory allocator.
Definition: memory.h:84
const NodeArray< double > & leaves() const
const NodeArray< double > & diameter() const
void connectedComponentDistance(double x)
Sets the option connectedComponentDistance to x.
Interface of general layout algorithms.
Definition: LayoutModule.h:44
double m_levelDistance
The minimal distance between levels.
double levelDistance() const
Returns the option levelDistance.
Array< SListPure< node > > m_nodes
The nodes at a level.
Array< double > m_radius
The width of a level.
The namespace for all OGDF objects.
RootSelectionType m_selectRoot
Specifies how to determine the root.
double m_connectedComponentDistance
The minimal distance between trees.
double connectedComponentDistance() const
Returns the option connectedComponentDistance.