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
35#include <ogdf/basic/Graph.h>
37#include <ogdf/basic/basic.h>
38
39namespace ogdf {
40class GraphAttributes;
41enum class Orientation;
42template<class E>
43class SListPure;
44
99public:
101 enum class RootSelectionType {
102 Source,
103 ByCoord
104 };
105
106private:
111
115
116public:
119
122
124 ~TreeLayout() = default;
125
141 virtual void call(GraphAttributes& GA) override;
142
154
161 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
209
211
212private:
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
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}
Includes declaration of graph class.
Declaration of interface for layout algorithms (class LayoutModule)
Basic declarations, included by all source files.
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Interface of general layout algorithms.
Class for the representation of nodes.
Definition Graph_d.h:241
Singly linked lists.
Definition SList.h:191
The tree layout algorithm.
Definition TreeLayout.h:98
double m_siblingDistance
The minimal distance between siblings.
Definition TreeLayout.h:107
void shiftTreeX(GraphAttributes &AG, node root, double shift)
RootSelectionType
Determines how to select the root of the tree.
Definition TreeLayout.h:101
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:182
RootSelectionType rootSelection() const
Returns the option that determines how the root is selected.
Definition TreeLayout.h:197
void siblingDistance(double x)
Sets the the minimal required horizontal distance between siblings to x.
Definition TreeLayout.h:164
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:109
void levelDistance(double x)
Sets the minimal required vertical distance between levels to x.
Definition TreeLayout.h:176
void firstWalk(TreeStructure &ts, node subtree, bool upDown)
bool orthogonalLayout() const
Returns whether orthogonal edge routing style is used.
Definition TreeLayout.h:185
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:114
~TreeLayout()=default
Destructor.
void findMinY(GraphAttributes &AG, node root, double &minY)
double m_treeDistance
The minimal distance between trees.
Definition TreeLayout.h:110
double siblingDistance() const
Returns the the minimal required horizontal distance between siblings.
Definition TreeLayout.h:161
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:173
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:113
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:179
void secondWalkY(TreeStructure &ts, node subtree, double modifierSum)
bool m_orthogonalLayout
Option for orthogonal style (yes/no).
Definition TreeLayout.h:112
void rootSelection(RootSelectionType rootSelection)
Sets the option that determines how the root is selected to rootSelection.
Definition TreeLayout.h:200
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:191
void orientation(Orientation orientation)
Sets the option that determines the orientation of the layout to orientation.
Definition TreeLayout.h:194
double m_subtreeDistance
The minimal distance between subtrees.
Definition TreeLayout.h:108
void computeYCoordinatesAndEdgeShapes(node root, GraphAttributes &AG)
double subtreeDistance() const
Returns the minimal required horizontal distance between subtrees.
Definition TreeLayout.h:167
void subtreeDistance(double x)
Sets the minimal required horizontal distance between subtrees to x.
Definition TreeLayout.h:170
void orthogonalLayout(bool b)
Sets the option for orthogonal edge routing style to b.
Definition TreeLayout.h:188
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 dynamic library (shared object / DLL),...
Definition config.h:117
The namespace for all OGDF objects.
Orientation
Determines the orientation in hierarchical layouts.
Definition geometry.h:55