The tree layout algorithm. More...
#include <ogdf/tree/TreeLayout.h>
Inheritance diagram for ogdf::TreeLayout:Public Types | |
| enum class | RootSelectionType { Source , ByCoord } |
| Determines how to select the root of the tree. More... | |
Public Member Functions | |
| TreeLayout () | |
| Creates an instance of tree layout and sets options to default values. | |
| TreeLayout (const TreeLayout &tl) | |
| Copy constructor. | |
| ~TreeLayout ()=default | |
| Destructor. | |
Algorithm call | |
| virtual void | call (GraphAttributes &GA) override |
Calls tree layout for graph attributes GA. | |
| void | callSortByPositions (GraphAttributes &GA, Graph &G) |
Calls tree layout for graph attributes GA. | |
Optional parameters | |
| double | siblingDistance () const |
| Returns the the minimal required horizontal distance between siblings. | |
| void | siblingDistance (double x) |
Sets the the minimal required horizontal distance between siblings to x. | |
| double | subtreeDistance () const |
| Returns the minimal required horizontal distance between subtrees. | |
| void | subtreeDistance (double x) |
Sets the minimal required horizontal distance between subtrees to x. | |
| double | levelDistance () const |
| Returns the minimal required vertical distance between levels. | |
| void | levelDistance (double x) |
Sets the minimal required vertical distance between levels to x. | |
| double | treeDistance () const |
| Returns the minimal required horizontal distance between trees in the forest. | |
| void | treeDistance (double x) |
Sets the minimal required horizontal distance between trees in the forest to x. | |
| bool | orthogonalLayout () const |
| Returns whether orthogonal edge routing style is used. | |
| void | orthogonalLayout (bool b) |
Sets the option for orthogonal edge routing style to b. | |
| Orientation | orientation () const |
| Returns the option that determines the orientation of the layout. | |
| void | orientation (Orientation orientation) |
Sets the option that determines the orientation of the layout to orientation. | |
| RootSelectionType | rootSelection () const |
| Returns the option that determines how the root is selected. | |
| void | rootSelection (RootSelectionType rootSelection) |
Sets the option that determines how the root is selected to rootSelection. | |
Operators | |
| TreeLayout & | operator= (const TreeLayout &tl) |
| Assignment operator. | |
Public Member Functions inherited from ogdf::LayoutModule | |
| LayoutModule () | |
| Initializes a layout module. | |
| virtual | ~LayoutModule () |
| void | operator() (GraphAttributes &GA) |
Computes a layout of graph GA. | |
Private Member Functions | |
| void | adjustEdgeDirections (Graph &G, SListPure< edge > &reversedEdges, node v, node parent) |
| void | apportion (TreeStructure &ts, node subtree, node &defaultAncestor, bool upDown) |
| void | computeXCoordinatesAndEdgeShapes (node root, GraphAttributes &AG) |
| void | computeYCoordinatesAndEdgeShapes (node root, GraphAttributes &AG) |
| void | findMaxX (GraphAttributes &AG, node root, double &maxX) |
| void | findMaxY (GraphAttributes &AG, node root, double &maxY) |
| void | findMinX (GraphAttributes &AG, node root, double &minX) |
| void | findMinY (GraphAttributes &AG, node root, double &minY) |
| void | firstWalk (TreeStructure &ts, node subtree, bool upDown) |
| void | secondWalkX (TreeStructure &ts, node subtree, double modifierSum) |
| void | secondWalkY (TreeStructure &ts, node subtree, double modifierSum) |
| void | setRoot (GraphAttributes &AG, Graph &tree, SListPure< edge > &reversedEdges) |
| void | shiftTreeX (GraphAttributes &AG, node root, double shift) |
| void | shiftTreeY (GraphAttributes &AG, node root, double shift) |
| void | undoReverseEdges (GraphAttributes &AG, Graph &tree, SListPure< edge > &reversedEdges) |
Private Attributes | |
| double | m_levelDistance |
| The minimal distance between levels. | |
| Orientation | m_orientation |
| Option for orientation of tree layout. | |
| bool | m_orthogonalLayout |
| Option for orthogonal style (yes/no). | |
| RootSelectionType | m_selectRoot |
| Option for how to determine the root. | |
| double | m_siblingDistance |
| The minimal distance between siblings. | |
| double | m_subtreeDistance |
| The minimal distance between subtrees. | |
| double | m_treeDistance |
| The minimal distance between trees. | |
The tree layout algorithm.
The class TreeLayout represents the improved version of the tree layout algorithm by Walker presented in:
Christoph Buchheim, Michael Jünger, Sebastian Leipert: Drawing rooted trees in linear time. Software: Practice and Experience 36(6), pp. 651-665, 2006.
The algorithm also allows to lay out a forest, i.e., a collection of trees.
Tree layout provides various optional parameters.
| Option | Type | Default | Description |
|---|---|---|---|
| siblingDistance | double | 20.0 | The horizontal spacing between adjacent sibling nodes. |
| subtreeDistance | double | 20.0 | The horizontal spacing between adjacent subtrees. |
| levelDistance | double | 50.0 | The vertical spacing between adjacent levels. |
| treeDistance | double | 50.0 | The horizontal spacing between adjacent trees in a forest. |
| orthogonalLayout | bool | false | Determines whether edges are routed in an orthogonal or straight-line fashion. |
| orientation | Orientation | Orientation::topToBottom | Determines if the tree is laid out in a top-to-bottom, bottom-to-top, left-to-right, or right-to-left fashion. |
| selectRoot | RootSelectionType | RootSelectionType::Source | Determines how to select the root of the tree(s). Possible selection strategies are to take a (unique) source in the graph, or to use the coordinates and to select the topmost node for top-to-bottom orientation, etc. |
The spacing between nodes is determined by the siblingDistance, subtreeDistance, levelDistance, and treeDistance. The layout style is determined by orthogonalLayout and orientation; the root of the tree is selected according to the selection strategy given by selectRoot.
Definition at line 98 of file TreeLayout.h.
|
strong |
Determines how to select the root of the tree.
| Enumerator | |
|---|---|
| Source | Select a source in the graph. |
| ByCoord | Use the coordinates, e.g., select the topmost node if orientation is topToBottom. |
Definition at line 101 of file TreeLayout.h.
| ogdf::TreeLayout::TreeLayout | ( | ) |
Creates an instance of tree layout and sets options to default values.
| ogdf::TreeLayout::TreeLayout | ( | const TreeLayout & | tl | ) |
Copy constructor.
|
default |
Destructor.
|
private |
|
private |
|
overridevirtual |
Calls tree layout for graph attributes GA.
The order of children is given by the adjacency lists. The successor of the unique in-edge of a non-root node leads to its leftmost child; the leftmost child of the root is given by its first adjacency entry.
| GA | is the input graph and will also be assigned the layout information. |
Implements ogdf::LayoutModule.
| void ogdf::TreeLayout::callSortByPositions | ( | GraphAttributes & | GA, |
| Graph & | G | ||
| ) |
Calls tree layout for graph attributes GA.
Sorts the adjacency entries according to the positions of adjacent vertices in GA.
| GA | is the input graph and will also be assigned the layout information. |
| G | is the graph associated with GA. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Returns the minimal required vertical distance between levels.
Definition at line 173 of file TreeLayout.h.
|
inline |
Sets the minimal required vertical distance between levels to x.
Definition at line 176 of file TreeLayout.h.
| TreeLayout & ogdf::TreeLayout::operator= | ( | const TreeLayout & | tl | ) |
Assignment operator.
|
inline |
Returns the option that determines the orientation of the layout.
Definition at line 191 of file TreeLayout.h.
|
inline |
Sets the option that determines the orientation of the layout to orientation.
Definition at line 194 of file TreeLayout.h.
|
inline |
Returns whether orthogonal edge routing style is used.
Definition at line 185 of file TreeLayout.h.
|
inline |
Sets the option for orthogonal edge routing style to b.
Definition at line 188 of file TreeLayout.h.
|
inline |
Returns the option that determines how the root is selected.
Definition at line 197 of file TreeLayout.h.
|
inline |
Sets the option that determines how the root is selected to rootSelection.
Definition at line 200 of file TreeLayout.h.
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
Returns the the minimal required horizontal distance between siblings.
Definition at line 161 of file TreeLayout.h.
|
inline |
Sets the the minimal required horizontal distance between siblings to x.
Definition at line 164 of file TreeLayout.h.
|
inline |
Returns the minimal required horizontal distance between subtrees.
Definition at line 167 of file TreeLayout.h.
|
inline |
Sets the minimal required horizontal distance between subtrees to x.
Definition at line 170 of file TreeLayout.h.
|
inline |
Returns the minimal required horizontal distance between trees in the forest.
Definition at line 179 of file TreeLayout.h.
|
inline |
Sets the minimal required horizontal distance between trees in the forest to x.
Definition at line 182 of file TreeLayout.h.
|
private |
|
private |
The minimal distance between levels.
Definition at line 109 of file TreeLayout.h.
|
private |
Option for orientation of tree layout.
Definition at line 113 of file TreeLayout.h.
|
private |
Option for orthogonal style (yes/no).
Definition at line 112 of file TreeLayout.h.
|
private |
Option for how to determine the root.
Definition at line 114 of file TreeLayout.h.
|
private |
The minimal distance between siblings.
Definition at line 107 of file TreeLayout.h.
|
private |
The minimal distance between subtrees.
Definition at line 108 of file TreeLayout.h.
|
private |
The minimal distance between trees.
Definition at line 110 of file TreeLayout.h.