Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

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 
156  double siblingDistance() const { return m_siblingDistance; }
158 
160  void siblingDistance(double x) { m_siblingDistance = x; }
161 
163  double subtreeDistance() const { return m_subtreeDistance; }
164 
166  void subtreeDistance(double x) { m_subtreeDistance = x; }
167 
169  double levelDistance() const { return m_levelDistance; }
170 
172  void levelDistance(double x) { m_levelDistance = x; }
173 
175  double treeDistance() const { return m_treeDistance; }
176 
178  void treeDistance(double x) { m_treeDistance = x; }
179 
181  bool orthogonalLayout() const { return m_orthogonalLayout; }
182 
184  void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
185 
187  Orientation orientation() const { return m_orientation; }
188 
190  void orientation(Orientation orientation) { m_orientation = orientation; }
191 
193  RootSelectionType rootSelection() const { return m_selectRoot; }
194 
196  void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
197 
203  TreeLayout& operator=(const TreeLayout& tl);
205 
207 
208 private:
209  class AdjComparer;
210  struct TreeStructure;
211 
212  void adjustEdgeDirections(Graph& G, SListPure<edge>& reversedEdges, node v, node parent);
213  void setRoot(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
214  void undoReverseEdges(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
215 
216  // recursive bottom up traversal of the tree for computing
217  // preliminary x-coordinates
218  void firstWalk(TreeStructure& ts, node subtree, bool upDown);
219 
220  // space out the small subtrees on the left hand side of subtree
221  // defaultAncestor is used for all nodes with obsolete m_ancestor
222  void apportion(TreeStructure& ts, node subtree, node& defaultAncestor, bool upDown);
223 
224  // recursive top down traversal of the tree for computing final
225  // x-coordinates
226  void secondWalkX(TreeStructure& ts, node subtree, double modifierSum);
227  void secondWalkY(TreeStructure& ts, node subtree, double modifierSum);
228 
229  // compute y-coordinates and edge shapes
230  void computeYCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
231  void computeXCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
232 
233  void findMinX(GraphAttributes& AG, node root, double& minX);
234  void findMinY(GraphAttributes& AG, node root, double& minY);
235  void findMaxX(GraphAttributes& AG, node root, double& maxX);
236  void findMaxY(GraphAttributes& AG, node root, double& maxY);
237  void shiftTreeX(GraphAttributes& AG, node root, double shift);
238  void shiftTreeY(GraphAttributes& AG, node root, double shift);
239 };
240 
241 }
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:66
ogdf::TreeLayout::m_orthogonalLayout
bool m_orthogonalLayout
Option for orthogonal style (yes/no).
Definition: TreeLayout.h:108
ogdf::TreeLayout::m_selectRoot
RootSelectionType m_selectRoot
Option for how to determine the root.
Definition: TreeLayout.h:110
ogdf::TreeLayout::orientation
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition: TreeLayout.h:190
ogdf::TreeLayout::m_treeDistance
double m_treeDistance
The minimal distance between trees.
Definition: TreeLayout.h:106
LayoutModule.h
Declaration of interface for layout algorithms (class LayoutModule)
ogdf::TreeLayout::orthogonalLayout
bool orthogonalLayout() const
Returns whether orthogonal edge routing style is used.
Definition: TreeLayout.h:181
ogdf::TreeLayout::orientation
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition: TreeLayout.h:187
ogdf::TreeLayout::m_orientation
Orientation m_orientation
Option for orientation of tree layout.
Definition: TreeLayout.h:109
SList.h
Declaration of singly linked lists and iterators.
ogdf::TreeLayout::subtreeDistance
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition: TreeLayout.h:166
ogdf::TreeLayout::m_siblingDistance
double m_siblingDistance
The minimal distance between siblings.
Definition: TreeLayout.h:103
ogdf::TreeLayout::treeDistance
void treeDistance(double x)
Sets the minimal required horizontal distance between trees in the forest to x.
Definition: TreeLayout.h:178
ogdf::TreeLayout::treeDistance
double treeDistance() const
Returns the minimal required horizontal distance between trees in the forest.
Definition: TreeLayout.h:175
ogdf::TreeLayout::rootSelection
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition: TreeLayout.h:193
ogdf::SListPure
Singly linked lists.
Definition: SList.h:39
ogdf::TreeLayout::m_subtreeDistance
double m_subtreeDistance
The minimal distance between subtrees.
Definition: TreeLayout.h:104
ogdf::TreeLayout::levelDistance
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition: TreeLayout.h:169
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::orientation
int orientation(const DPoint &p, const DPoint &q, const DPoint &r)
ogdf::TreeLayout::rootSelection
void rootSelection(RootSelectionType rootSelection)
Sets the option that determines how the root is selected to rootSelection.
Definition: TreeLayout.h:196
ogdf::TreeLayout::siblingDistance
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition: TreeLayout.h:160
ogdf::TreeLayout::subtreeDistance
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition: TreeLayout.h:163
ogdf::Orientation
Orientation
Determines the orientation in hierarchical layouts.
Definition: geometry.h:48
ogdf::TreeLayout::m_levelDistance
double m_levelDistance
The minimal distance between levels.
Definition: TreeLayout.h:105
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::TreeLayout
The tree layout algorithm.
Definition: TreeLayout.h:93
ogdf::TreeLayout::levelDistance
void levelDistance(double x)
Sets the minimal required vertical distance between levels to x.
Definition: TreeLayout.h:172
ogdf::TreeLayout::RootSelectionType
RootSelectionType
Determines how to select the root of the tree.
Definition: TreeLayout.h:96
ogdf::TreeLayout::orthogonalLayout
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition: TreeLayout.h:184
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:44