Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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 
120  ~TreeLayout() = default;
121 
137  virtual void call(GraphAttributes &GA) override;
138 
149  void callSortByPositions(GraphAttributes &GA, Graph &G);
150 
151 
157  double siblingDistance() const { return m_siblingDistance; }
159 
161  void siblingDistance(double x) { m_siblingDistance = x; }
162 
164  double subtreeDistance() const { return m_subtreeDistance; }
165 
167  void subtreeDistance(double x) { m_subtreeDistance = x; }
168 
170  double levelDistance() const { return m_levelDistance; }
171 
173  void levelDistance(double x) { m_levelDistance = x; }
174 
176  double treeDistance() const { return m_treeDistance; }
177 
179  void treeDistance(double x) { m_treeDistance = x; }
180 
182  bool orthogonalLayout() const { return m_orthogonalLayout; }
183 
185  void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
186 
188  Orientation orientation() const { return m_orientation; }
189 
191  void orientation(Orientation orientation) { m_orientation = orientation; }
192 
194  RootSelectionType rootSelection() const { return m_selectRoot; }
195 
197  void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
198 
199 
205  TreeLayout &operator=(const TreeLayout &tl);
207 
209 
210 private:
211  class AdjComparer;
212  struct TreeStructure;
213 
214  void adjustEdgeDirections(Graph &G, SListPure<edge> &reversedEdges, node v, node parent);
215  void setRoot(GraphAttributes &AG, Graph &tree, SListPure<edge> &reversedEdges);
216  void undoReverseEdges(GraphAttributes &AG, Graph &tree, SListPure<edge> &reversedEdges);
217 
218  // recursive bottom up traversal of the tree for computing
219  // preliminary x-coordinates
220  void firstWalk(TreeStructure &ts, node subtree, bool upDown);
221 
222  // space out the small subtrees on the left hand side of subtree
223  // defaultAncestor is used for all nodes with obsolete m_ancestor
224  void apportion(
225  TreeStructure &ts,
226  node subtree,
227  node &defaultAncestor,
228  bool upDown);
229 
230  // recursive top down traversal of the tree for computing final
231  // x-coordinates
232  void secondWalkX(TreeStructure &ts, node subtree, double modifierSum);
233  void secondWalkY(TreeStructure &ts, node subtree, double modifierSum);
234 
235  // compute y-coordinates and edge shapes
236  void computeYCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
237  void computeXCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
238 
239  void findMinX(GraphAttributes &AG, node root, double &minX);
240  void findMinY(GraphAttributes &AG, node root, double &minY);
241  void findMaxX(GraphAttributes &AG, node root, double &maxX);
242  void findMaxY(GraphAttributes &AG, node root, double &maxY);
243  void shiftTreeX(GraphAttributes &AG, node root, double shift);
244  void shiftTreeY(GraphAttributes &AG, node root, double shift);
245 };
246 
247 }
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:176
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition: TreeLayout.h:185
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
bool orthogonalLayout() const
Returns whether orthogonal edge routing style is used.
Definition: TreeLayout.h:182
#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:173
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition: TreeLayout.h:170
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition: TreeLayout.h:191
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:197
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:169
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:161
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition: TreeLayout.h:164
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition: TreeLayout.h:188
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition: TreeLayout.h:167
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:179
The namespace for all OGDF objects.
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition: TreeLayout.h:194
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)