Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

TreeLayout.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
37 #include <ogdf/basic/basic.h>
38 
39 namespace ogdf {
40 class GraphAttributes;
41 enum class Orientation;
42 template<class E>
43 class SListPure;
44 
99 public:
101  enum class RootSelectionType {
102  Source,
103  Sink,
104  ByCoord
105  };
106 
107 private:
111  double m_treeDistance;
112 
116 
117 public:
119  TreeLayout();
120 
122  TreeLayout(const TreeLayout& tl);
123 
125  ~TreeLayout() = default;
126 
142  virtual void call(GraphAttributes& GA) override;
143 
154  void callSortByPositions(GraphAttributes& GA, Graph& G);
155 
161  double siblingDistance() const { return m_siblingDistance; }
163 
165  void siblingDistance(double x) { m_siblingDistance = x; }
166 
168  double subtreeDistance() const { return m_subtreeDistance; }
169 
171  void subtreeDistance(double x) { m_subtreeDistance = x; }
172 
174  double levelDistance() const { return m_levelDistance; }
175 
177  void levelDistance(double x) { m_levelDistance = x; }
178 
180  double treeDistance() const { return m_treeDistance; }
181 
183  void treeDistance(double x) { m_treeDistance = x; }
184 
186  bool orthogonalLayout() const { return m_orthogonalLayout; }
187 
189  void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
190 
192  Orientation orientation() const { return m_orientation; }
193 
195  void orientation(Orientation orientation) { m_orientation = orientation; }
196 
198  RootSelectionType rootSelection() const { return m_selectRoot; }
199 
201  void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
202 
208  TreeLayout& operator=(const TreeLayout& tl);
210 
212 
213 private:
214  class AdjComparer;
215  struct TreeStructure;
216 
217  void adjustEdgeDirections(Graph& G, SListPure<edge>& reversedEdges, node v, node parent);
218  void setRoot(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
219  void undoReverseEdges(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
220 
221  // recursive bottom up traversal of the tree for computing
222  // preliminary x-coordinates
223  void firstWalk(TreeStructure& ts, node subtree, bool upDown);
224 
225  // space out the small subtrees on the left hand side of subtree
226  // defaultAncestor is used for all nodes with obsolete m_ancestor
227  void apportion(TreeStructure& ts, node subtree, node& defaultAncestor, bool upDown);
228 
229  // recursive top down traversal of the tree for computing final
230  // x-coordinates
231  void secondWalkX(TreeStructure& ts, node subtree, double modifierSum);
232  void secondWalkY(TreeStructure& ts, node subtree, double modifierSum);
233 
234  // compute y-coordinates and edge shapes
235  void computeYCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
236  void computeXCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
237 
238  void findMinX(GraphAttributes& AG, node root, double& minX);
239  void findMinY(GraphAttributes& AG, node root, double& minY);
240  void findMaxX(GraphAttributes& AG, node root, double& maxX);
241  void findMaxY(GraphAttributes& AG, node root, double& maxY);
242  void shiftTreeX(GraphAttributes& AG, node root, double shift);
243  void shiftTreeY(GraphAttributes& AG, node root, double shift);
244 };
245 
246 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
Graph.h
Includes declaration of graph class.
ogdf::TreeLayout::m_orthogonalLayout
bool m_orthogonalLayout
Option for orthogonal style (yes/no).
Definition: TreeLayout.h:113
ogdf::TreeLayout::m_selectRoot
RootSelectionType m_selectRoot
Option for how to determine the root.
Definition: TreeLayout.h:115
ogdf::TreeLayout::orientation
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition: TreeLayout.h:195
ogdf::TreeLayout::m_treeDistance
double m_treeDistance
The minimal distance between trees.
Definition: TreeLayout.h:111
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:186
ogdf::TreeLayout::orientation
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition: TreeLayout.h:192
ogdf::TreeLayout::m_orientation
Orientation m_orientation
Option for orientation of tree layout.
Definition: TreeLayout.h:114
ogdf::TreeLayout::subtreeDistance
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition: TreeLayout.h:171
ogdf::TreeLayout::m_siblingDistance
double m_siblingDistance
The minimal distance between siblings.
Definition: TreeLayout.h:108
ogdf::TreeLayout::treeDistance
void treeDistance(double x)
Sets the minimal required horizontal distance between trees in the forest to x.
Definition: TreeLayout.h:183
ogdf::TreeLayout::treeDistance
double treeDistance() const
Returns the minimal required horizontal distance between trees in the forest.
Definition: TreeLayout.h:180
ogdf::TreeLayout::rootSelection
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition: TreeLayout.h:198
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::TreeLayout::m_subtreeDistance
double m_subtreeDistance
The minimal distance between subtrees.
Definition: TreeLayout.h:109
ogdf::TreeLayout::levelDistance
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition: TreeLayout.h:174
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
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:201
ogdf::TreeLayout::siblingDistance
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition: TreeLayout.h:165
ogdf::TreeLayout::subtreeDistance
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition: TreeLayout.h:168
ogdf::Orientation
Orientation
Determines the orientation in hierarchical layouts.
Definition: geometry.h:55
ogdf::TreeLayout::m_levelDistance
double m_levelDistance
The minimal distance between levels.
Definition: TreeLayout.h:110
basic.h
Basic declarations, included by all source files.
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:98
ogdf::TreeLayout::levelDistance
void levelDistance(double x)
Sets the minimal required vertical distance between levels to x.
Definition: TreeLayout.h:177
ogdf::TreeLayout::RootSelectionType
RootSelectionType
Determines how to select the root of the tree.
Definition: TreeLayout.h:101
ogdf::TreeLayout::orthogonalLayout
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition: TreeLayout.h:189
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45