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  ByCoord
104  };
105 
106 private:
110  double m_treeDistance;
111 
115 
116 public:
118  TreeLayout();
119 
121  TreeLayout(const TreeLayout& tl);
122 
124  ~TreeLayout() = default;
125 
141  virtual void call(GraphAttributes& GA) override;
142 
153  void callSortByPositions(GraphAttributes& GA, Graph& G);
154 
160  double siblingDistance() const { return m_siblingDistance; }
162 
164  void siblingDistance(double x) { m_siblingDistance = x; }
165 
167  double subtreeDistance() const { return m_subtreeDistance; }
168 
170  void subtreeDistance(double x) { m_subtreeDistance = x; }
171 
173  double levelDistance() const { return m_levelDistance; }
174 
176  void levelDistance(double x) { m_levelDistance = x; }
177 
179  double treeDistance() const { return m_treeDistance; }
180 
182  void treeDistance(double x) { m_treeDistance = x; }
183 
185  bool orthogonalLayout() const { return m_orthogonalLayout; }
186 
188  void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
189 
191  Orientation orientation() const { return m_orientation; }
192 
194  void orientation(Orientation orientation) { m_orientation = orientation; }
195 
197  RootSelectionType rootSelection() const { return m_selectRoot; }
198 
200  void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
201 
207  TreeLayout& operator=(const TreeLayout& tl);
209 
211 
212 private:
213  class AdjComparer;
214  struct TreeStructure;
215 
216  void adjustEdgeDirections(Graph& G, SListPure<edge>& reversedEdges, node v, node parent);
217  void setRoot(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
218  void undoReverseEdges(GraphAttributes& AG, Graph& tree, SListPure<edge>& reversedEdges);
219 
220  // recursive bottom up traversal of the tree for computing
221  // preliminary x-coordinates
222  void firstWalk(TreeStructure& ts, node subtree, bool upDown);
223 
224  // space out the small subtrees on the left hand side of subtree
225  // defaultAncestor is used for all nodes with obsolete m_ancestor
226  void apportion(TreeStructure& ts, node subtree, node& defaultAncestor, bool upDown);
227 
228  // recursive top down traversal of the tree for computing final
229  // x-coordinates
230  void secondWalkX(TreeStructure& ts, node subtree, double modifierSum);
231  void secondWalkY(TreeStructure& ts, node subtree, double modifierSum);
232 
233  // compute y-coordinates and edge shapes
234  void computeYCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
235  void computeXCoordinatesAndEdgeShapes(node root, GraphAttributes& AG);
236 
237  void findMinX(GraphAttributes& AG, node root, double& minX);
238  void findMinY(GraphAttributes& AG, node root, double& minY);
239  void findMaxX(GraphAttributes& AG, node root, double& maxX);
240  void findMaxY(GraphAttributes& AG, node root, double& maxY);
241  void shiftTreeX(GraphAttributes& AG, node root, double shift);
242  void shiftTreeY(GraphAttributes& AG, node root, double shift);
243 };
244 
245 }
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:112
ogdf::TreeLayout::m_selectRoot
RootSelectionType m_selectRoot
Option for how to determine the root.
Definition: TreeLayout.h:114
ogdf::TreeLayout::orientation
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition: TreeLayout.h:194
ogdf::TreeLayout::m_treeDistance
double m_treeDistance
The minimal distance between trees.
Definition: TreeLayout.h:110
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:185
ogdf::TreeLayout::orientation
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition: TreeLayout.h:191
ogdf::TreeLayout::m_orientation
Orientation m_orientation
Option for orientation of tree layout.
Definition: TreeLayout.h:113
ogdf::TreeLayout::subtreeDistance
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition: TreeLayout.h:170
ogdf::TreeLayout::m_siblingDistance
double m_siblingDistance
The minimal distance between siblings.
Definition: TreeLayout.h:107
ogdf::TreeLayout::treeDistance
void treeDistance(double x)
Sets the minimal required horizontal distance between trees in the forest to x.
Definition: TreeLayout.h:182
ogdf::TreeLayout::treeDistance
double treeDistance() const
Returns the minimal required horizontal distance between trees in the forest.
Definition: TreeLayout.h:179
ogdf::TreeLayout::rootSelection
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition: TreeLayout.h:197
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::TreeLayout::m_subtreeDistance
double m_subtreeDistance
The minimal distance between subtrees.
Definition: TreeLayout.h:108
ogdf::TreeLayout::levelDistance
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition: TreeLayout.h:173
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:866
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:200
ogdf::TreeLayout::siblingDistance
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition: TreeLayout.h:164
ogdf::TreeLayout::subtreeDistance
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition: TreeLayout.h:167
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:109
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 dynamic library (shared object / DLL),...
Definition: config.h:117
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:176
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:188
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:241
ogdf::LayoutModule
Interface of general layout algorithms.
Definition: LayoutModule.h:45