Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

TreeLayout.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 #include <ogdf/basic/SList.h>
37 
38 namespace ogdf {
39 
94 public:
96  enum class RootSelectionType {
97  Source,
98  Sink,
99  ByCoord
100  };
101 
102 private:
106  double m_treeDistance;
107 
111 
112 public:
114  TreeLayout();
115 
117  TreeLayout(const TreeLayout &tl);
118 
119  // destructor
120  ~TreeLayout();
121 
122 
138  virtual void call(GraphAttributes &GA) override;
139 
150  void callSortByPositions(GraphAttributes &GA, Graph &G);
151 
152 
158  double siblingDistance() const { return m_siblingDistance; }
160 
162  void siblingDistance(double x) { m_siblingDistance = x; }
163 
165  double subtreeDistance() const { return m_subtreeDistance; }
166 
168  void subtreeDistance(double x) { m_subtreeDistance = x; }
169 
171  double levelDistance() const { return m_levelDistance; }
172 
174  void levelDistance(double x) { m_levelDistance = x; }
175 
177  double treeDistance() const { return m_treeDistance; }
178 
180  void treeDistance(double x) { m_treeDistance = x; }
181 
183  bool orthogonalLayout() const { return m_orthogonalLayout; }
184 
186  void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
187 
189  Orientation orientation() const { return m_orientation; }
190 
192  void orientation(Orientation orientation) { m_orientation = orientation; }
193 
195  RootSelectionType rootSelection() const { return m_selectRoot; }
196 
198  void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
199 
200 
206  TreeLayout &operator=(const TreeLayout &tl);
208 
210 
211 private:
212  class AdjComparer;
213  struct TreeStructure;
214 
215  void adjustEdgeDirections(Graph &G, SListPure<edge> &reversedEdges, node v, node parent);
216  void setRoot(GraphAttributes &AG, Graph &tree, SListPure<edge> &reversedEdges);
217  void undoReverseEdges(GraphAttributes &AG, Graph &tree, SListPure<edge> &reversedEdges);
218 
219  // recursive bottom up traversal of the tree for computing
220  // preliminary x-coordinates
221  void firstWalk(TreeStructure &ts, node subtree, bool upDown);
222 
223  // space out the small subtrees on the left hand side of subtree
224  // defaultAncestor is used for all nodes with obsolete m_ancestor
225  void apportion(
226  TreeStructure &ts,
227  node subtree,
228  node &defaultAncestor,
229  bool upDown);
230 
231  // recursive top down traversal of the tree for computing final
232  // x-coordinates
233  void secondWalkX(TreeStructure &ts, node subtree, double modifierSum);
234  void secondWalkY(TreeStructure &ts, node subtree, double modifierSum);
235 
236  // compute y-coordinates and edge shapes
237  void computeYCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
238  void computeXCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
239 
240  void findMinX(GraphAttributes &AG, node root, double &minX);
241  void findMinY(GraphAttributes &AG, node root, double &minY);
242  void findMaxX(GraphAttributes &AG, node root, double &maxX);
243  void findMaxY(GraphAttributes &AG, node root, double &maxY);
244  void shiftTreeX(GraphAttributes &AG, node root, double shift);
245  void shiftTreeY(GraphAttributes &AG, node root, double shift);
246 };
247 
248 } // end namespace ogdf
Declaration of singly linked lists and iterators.
double m_siblingDistance
The minimal distance between siblings.
Definition: TreeLayout.h:103
double treeDistance() const
Returns the minimal required horizontal distance between trees in the forest.
Definition: TreeLayout.h:177
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition: TreeLayout.h:186
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
bool orthogonalLayout() const
Returns whether orthogonal edge routing style is used.
Definition: TreeLayout.h:183
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Singly linked lists.
Definition: SList.h:38
void levelDistance(double x)
Sets the minimal required vertical distance between levels to x.
Definition: TreeLayout.h:174
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition: TreeLayout.h:171
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition: TreeLayout.h:192
Orientation
Determines the orientation in hierarchical layouts.
Definition: geometry.h:46
double m_levelDistance
The minimal distance between levels.
Definition: TreeLayout.h:105
Stores additional attributes of a graph (like layout information).
void rootSelection(RootSelectionType rootSelection)
Sets the option that determines how the root is selected to rootSelection.
Definition: TreeLayout.h:198
double m_treeDistance
The minimal distance between trees.
Definition: TreeLayout.h:106
Declaration of interface for layout algorithms (class LayoutModule)
Class for the representation of nodes.
Definition: Graph_d.h:167
RootSelectionType m_selectRoot
Option for how to determine the root.
Definition: TreeLayout.h:110
Orientation m_orientation
Option for orientation of tree layout.
Definition: TreeLayout.h:109
The tree layout algorithm.
Definition: TreeLayout.h:93
Interface of general layout algorithms.
Definition: LayoutModule.h:44
RootSelectionType
Determines how to select the root of the tree.
Definition: TreeLayout.h:96
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition: TreeLayout.h:162
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition: TreeLayout.h:165
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition: TreeLayout.h:189
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition: TreeLayout.h:168
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
void treeDistance(double x)
Sets the minimal required horizontal distance between trees in the forest to x.
Definition: TreeLayout.h:180
The namespace for all OGDF objects.
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition: TreeLayout.h:195
double m_subtreeDistance
The minimal distance between subtrees.
Definition: TreeLayout.h:104
bool m_orthogonalLayout
Option for orthogonal style (yes/no).
Definition: TreeLayout.h:108
int orientation(const DPoint &p, const DPoint &q, const DPoint &r)