Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

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