Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
TreeLayout.h
Go to the documentation of this file.
1
33#pragma once
34
36#include <ogdf/basic/SList.h>
37
38namespace ogdf {
39
94public:
96 enum class RootSelectionType {
97 Source,
98 Sink,
99 ByCoord
100 };
101
102private:
107
111
112public:
115
118
120 ~TreeLayout() = default;
121
137 virtual void call(GraphAttributes& GA) override;
138
150
157 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
205
207
208private:
209 class AdjComparer;
210 struct TreeStructure;
211
215
216 // recursive bottom up traversal of the tree for computing
217 // preliminary x-coordinates
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
223
224 // recursive top down traversal of the tree for computing final
225 // x-coordinates
228
229 // compute y-coordinates and edge shapes
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}
Declaration of interface for layout algorithms (class LayoutModule)
Declaration of singly linked lists and iterators.
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Interface of general layout algorithms.
Class for the representation of nodes.
Definition Graph_d.h:177
Singly linked lists.
Definition SList.h:179
The tree layout algorithm.
Definition TreeLayout.h:93
double m_siblingDistance
The minimal distance between siblings.
Definition TreeLayout.h:103
void shiftTreeX(GraphAttributes &AG, node root, double shift)
RootSelectionType
Determines how to select the root of the tree.
Definition TreeLayout.h:96
void shiftTreeY(GraphAttributes &AG, node root, double shift)
void secondWalkX(TreeStructure &ts, node subtree, double modifierSum)
void treeDistance(double x)
Sets the minimal required horizontal distance between trees in the forest to x.
Definition TreeLayout.h:178
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition TreeLayout.h:193
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition TreeLayout.h:160
void apportion(TreeStructure &ts, node subtree, node &defaultAncestor, bool upDown)
virtual void call(GraphAttributes &GA) override
Calls tree layout for graph attributes GA.
double m_levelDistance
The minimal distance between levels.
Definition TreeLayout.h:105
void levelDistance(double x)
Sets the minimal required vertical distance between levels to x.
Definition TreeLayout.h:172
void firstWalk(TreeStructure &ts, node subtree, bool upDown)
bool orthogonalLayout() const
Returns whether orthogonal edge routing style is used.
Definition TreeLayout.h:181
void findMaxY(GraphAttributes &AG, node root, double &maxY)
void findMinX(GraphAttributes &AG, node root, double &minX)
TreeLayout(const TreeLayout &tl)
Copy constructor.
RootSelectionType m_selectRoot
Option for how to determine the root.
Definition TreeLayout.h:110
~TreeLayout()=default
Destructor.
void findMinY(GraphAttributes &AG, node root, double &minY)
double m_treeDistance
The minimal distance between trees.
Definition TreeLayout.h:106
double siblingDistance() const
Returns the the minimal required horizontal distance between siblings.
Definition TreeLayout.h:157
void undoReverseEdges(GraphAttributes &AG, Graph &tree, SListPure< edge > &reversedEdges)
TreeLayout & operator=(const TreeLayout &tl)
Assignment operator.
double levelDistance() const
Returns the minimal required vertical distance between levels.
Definition TreeLayout.h:169
void findMaxX(GraphAttributes &AG, node root, double &maxX)
TreeLayout()
Creates an instance of tree layout and sets options to default values.
Orientation m_orientation
Option for orientation of tree layout.
Definition TreeLayout.h:109
void adjustEdgeDirections(Graph &G, SListPure< edge > &reversedEdges, node v, node parent)
void computeXCoordinatesAndEdgeShapes(node root, GraphAttributes &AG)
double treeDistance() const
Returns the minimal required horizontal distance between trees in the forest.
Definition TreeLayout.h:175
void secondWalkY(TreeStructure &ts, node subtree, double modifierSum)
bool m_orthogonalLayout
Option for orthogonal style (yes/no).
Definition TreeLayout.h:108
void rootSelection(RootSelectionType rootSelection)
Sets the option that determines how the root is selected to rootSelection.
Definition TreeLayout.h:196
void setRoot(GraphAttributes &AG, Graph &tree, SListPure< edge > &reversedEdges)
Orientation orientation() const
Returns the option that determines the orientation of the layout.
Definition TreeLayout.h:187
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition TreeLayout.h:190
double m_subtreeDistance
The minimal distance between subtrees.
Definition TreeLayout.h:104
void computeYCoordinatesAndEdgeShapes(node root, GraphAttributes &AG)
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition TreeLayout.h:163
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition TreeLayout.h:166
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition TreeLayout.h:184
void callSortByPositions(GraphAttributes &GA, Graph &G)
Calls tree layout for graph attributes GA.
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Orientation
Determines the orientation in hierarchical layouts.
Definition geometry.h:47