A tree layout algorithm that arranges the subtrees of the tree in a radial fashion.
Remarks
Layout Style
RadialTreeLayout is designed to arrange directed and undirected tree graphs. Subtrees rooted at a node are placed in a radial fashion around their root node. All direct children of one node can be placed on a common circle around their parent node (depending on the alignment policy). Therefore, subtrees look like balloons or stars, especially if subtrees have similar sizes. The edges of the tree are drawn as straight lines.
Concept
The algorithm executes the following steps:
- Select a root node according to the specified policy.
- Determine the placement of subtrees around the root using a bottom-up recursive approach (starting with leaf nodes).
- For a leaf node: calculate the convex hull of the node.
- For a non-leaf node: arrange the children rooted at the node. Children are sorted according to a specified ordering policy and a distance to their parent is chosen. This distance will be chosen such that subtrees rooted at the current node fit into the preferred sector angle. The sector angle defines how much radial space a subtree occupies around its parent; it is computed using the convex hull of subtrees.
Finally, the convex hull of the subtree rooted at the current node is updated in order to include all the convex hulls of child nodes. This is possible, because distances and sectors of the child subtrees are now known.
- Assign the actual coordinates of nodes, again using a recursive approach (starting with the root node).
Features
The algorithm features integrated edge labeling as well as node labeling. Edge labels and node labels are placed automatically without generating overlaps with other labels or graph elements. There are different ways to place node labels. Edge labeling will take the settings of EdgeLabelPreferredPlacement into account.
Defining a preferred sector angle has a great influence on the layout style. Subtrees rooted at a node get a certain amount of radial space to be placed around the parent node, such that a preferred angle close to 360
degrees will generate drawings where subtrees look like balloons, while an angle close to 180
degrees could be chosen to get drawings where subtrees look like semicircles.
Since it is computationally not very complex, RadialTreeLayout is very well suited for large tree graphs. It performs well even for huge graphs.
nodeTypes are considered such that the type of the nodes is used as a criterion for sorting the child nodes of a local root node, with the effect that nodes of the same type are placed consecutively, if possible. If defined, the childOrder is stronger than the node type criterion. However, the node types are considered more important than the childOrderingPolicy.
This layout algorithm can only handle graphs with a tree structure. To make it applicable to general graphs, the treeReductionStage is used by default. This stage will temporarily remove some edges of the input graph until a tree is obtained. These edges will later be reinserted and routed separately.
This layout algorithm handles port placement constraints by applying the PortPlacementStage as a postprocessing step.
Layout Stages
This class provides a configurable pipeline that contains various ILayoutStages. Each ILayoutStage can incorporate preprocessing or postprocessing steps into the layout calculation to streamline the input graph and enhance the resulting layout. Additionally, custom ILayoutStages can be added and executed either before or after the predefined ones.
The following default ILayoutStages are included:
- PortPlacementStage: Assigns edges to ports.
- GroupHidingStage: Removes group nodes and their adjacent edges before layout processing, and reinserts them afterward. The property hidingEmptyGroupNodes is set to
false
and resetEdgePaths is set totrue
. - SubgraphLayoutStage: Filters a graph to include only specific nodes and edges from a subgraph while maintaining the positions of excluded elements. Note: This stage is disabled by default.
- ComponentLayout: Arranges graph components with customizable styles. The property style is set to circular component arrangement style.
- GenericLabeling: Efficiently places node and edge labels. The property fillEmptyScope is set to
false
and stopDuration is set to ZERO. - OrientationStage: Changes the layout orientation in four possible directions, with or without mirroring on the x or y-axis.
- SelfLoopRouter: Routes self-loops in a graph, allowing for either orthogonal or rounded routing styles.
- ParallelEdgeRouter: Routes multiple edges between the same nodes in parallel.
- TreeReductionStage: Temporarily reduces general graphs to tree structures, allowing them to be processed by a tree layout algorithm. The property nonTreeEdgeRouter is set to a StraightLineEdgeRouter instance.
With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.
Performance
The RadialTreeLayout algorithm is a fast algorithm that is generally well-suited to handle even large graphs.
With disconnected graphs that contain large unconnected components, it can be beneficial to change the component arrangement style of the used componentLayout from the default style PACKED_CIRCLE to the faster ROWS style.
Default Values of Properties
allowOverlaps | false | Nodes are not allowed to overlap. |
chainStraighteningMode | false | There is no guarantee that chains are drawn straight. |
compactnessFactor | 0.5 | A factor offering good balance between compactness and runtime. |
edgeLabelPlacement | INTEGRATED
| Edge labels are placed by the layout algorithm. |
minimumEdgeLength | 40 | |
minimumNodeDistance | 10 | |
nodeLabelPlacement | CONSIDER
| Node labels are considered by this algorithm. |
preferredChildSectorAngle | 340 | |
preferredRootSectorAngle | 360 |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new RadialTreeLayout instance with default settings.
Parameters
A map of options to pass to the method.
- childOrderingPolicy - ChildOrderingPolicy
- The child ordering policy for sorting the child nodes around their parents. This option sets the childOrderingPolicy property on the created object.
- minimumNodeDistance - number
- The minimum distance to be kept between the nodes in the tree. This option sets the minimumNodeDistance property on the created object.
- rootSelectionPolicy - RootSelectionPolicy
- The root node selection policy of this layout algorithm. This option sets the rootSelectionPolicy property on the created object.
- preferredChildSectorAngle - number
- The preferred radial amount (sector) in degrees that child nodes may in total occupy around their parent node. This option sets the preferredChildSectorAngle property on the created object.
- preferredRootSectorAngle - number
- The preferred radial amount (sector) in degrees that child nodes may in total occupy around the global root. This option sets the preferredRootSectorAngle property on the created object.
- allowOverlaps - boolean
- Whether or not (partially) overlapping nodes are allowed. This option sets the allowOverlaps property on the created object.
- compactnessFactor - number
- The compactness factor for the layout. This option sets the compactnessFactor property on the created object.
- minimumEdgeLength - number
- The minimum length that this layout algorithm assigns to edges of the graph. This option sets the minimumEdgeLength property on the created object.
- childAlignmentPolicy - ChildAlignmentPolicy
- The child alignment policy for this layout algorithm. This option sets the childAlignmentPolicy property on the created object.
- nodeLabelPlacement - RadialNodeLabelPlacement
- How the layout algorithm handles node labels. This option sets the nodeLabelPlacement property on the created object.
- edgeLabelPlacement - EdgeLabelPlacement
- How the layout handles the position of edge labels. This option sets the edgeLabelPlacement property on the created object.
- nodeLabelSpacing - number
- The distance between node labels belonging to the same node. This option sets the nodeLabelSpacing property on the created object.
- edgeLabelSpacing - number
- The distance between edge labels belonging to the same edge as well as the distance of the edge labels to the target node of the edge. This option sets the edgeLabelSpacing property on the created object.
- chainStraighteningMode - boolean
- Whether or not chains are drawn straight. This option sets the chainStraighteningMode property on the created object.
Properties
Gets or sets whether or not (partially) overlapping nodes are allowed.
Remarks
Default Value
false
.Nodes are not allowed to overlap.
Property Value
true
if node overlaps are allowed, false
otherwiseSee Also
Sample Graphs
Gets or sets whether or not chains are drawn straight.
Remarks
A chain is defined as a tree node with exactly one child node. If this feature is enabled, then the incoming edge and outgoing edge of the chain will have the same orientation, i.e., the whole chain looks straight.
Straightening all chains can lead to smoother, more symmetric results.
Default Value
false
.There is no guarantee that chains are drawn straight.
Property Value
true
if chains are drawn straight, false
otherwise.See Also
Sample Graphs
Gets or sets the child alignment policy for this layout algorithm.
Remarks
Default Value
COMPACT.Property Value
See Also
Gets or sets the child ordering policy for sorting the child nodes around their parents.
Remarks
Default Value
COMPACT.Property Value
See Also
Gets or sets the compactness factor for the layout.
Remarks
Smaller values may result in less compact drawings, larger values in more compact drawings.
The algorithm tries to optimize the child node arrangement around each tree node such that each subtree is as close to its root as possible, while still fitting into the preferred sector angle and not overlapping with adjacent subtrees.
Low compactness factor values induce the optimization procedure to be less strict and accept less optimal results, while high factor values mean that the optimization will only stop when being nearly optimal. Thus, higher values lead to a potentially higher runtime.
The compactness factor needs to lie in the interval [0, 1]
.
Default Value
0.5
.A factor offering good balance between compactness and runtime.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the factor is smaller than
0.0
or greater than1.0
See Also
Gets the ComponentLayout from the layoutStages of this instance.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- If there is no instance of the respective type in the
See Also
Gets or sets how the layout handles the position of edge labels.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets the distance between edge labels belonging to the same edge as well as the distance of the edge labels to the target node of the edge.
Remarks
Default Value
4.0
.Labels are close together and close to targets.
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given label spacing value is negative
See Also
Sample Graphs
0
, labels will touch each other and the target node.Gets the mutable stack of ILayoutStage that will be applied to this layout.
Gets or sets the minimum length that this layout algorithm assigns to edges of the graph.
Remarks
A lower minimum edge length allows generally more compact layouts. It has the highest effect if most nodes of the graph have a low degree, as the minimum can potentially be met for such graphs.
The minimum length must be non-negative.
Default Value
40
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given length is negative
See Also
Sample Graphs
Gets or sets the minimum distance to be kept between the nodes in the tree.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given minimum distance is negative
See Also
Sample Graphs
Gets or sets how the layout algorithm handles node labels.
Default Value
Property Value
- IGNORE if node labels should be ignored during the layout process.
- CONSIDER if node label positions relative to their owner should be maintained and considered for the placement of other graph elements to avoid overlaps.
- HORIZONTAL if horizontal node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- RAY_LIKE if ray-like node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- RAY_LIKE_LEAVES if a mix of horizontal and ray-like node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- GENERIC if the node labels should be placed by the GenericLabeling algorithm subsequently.
See Also
Sample Graphs
Gets or sets the distance between node labels belonging to the same node.
Remarks
It also defines the distance between labels and the node they belong to in case of label placement outside of the node (e.g. for ray-like label placement).
The spacing must have a non-negative value.
Default Value
4.0
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given spacing value is negative
See Also
Sample Graphs
0
, node labels will be maximally close to each other and to their node.Gets the ParallelEdgeRouter from the layoutStages of this instance.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- If there is no instance of the respective type in the
See Also
Gets or sets the preferred radial amount (sector) in degrees that child nodes may in total occupy around their parent node.
Remarks
The sector angle controls the degree to which the child nodes may radiate from the center of layout. A value close to 360
means that the child nodes may radiate in (almost) any direction from their parent node, edge lengths can in consequence stay rather small. On the other hand, a small value means that children are restricted to a small angle; thus, edge lengths (and drawings) may become large.
The minimum allowed sector angle is 1
and the maximum allowed value is 359
.
Default Value
340
.Property Value
[1,359]
Throws
- Exception({ name: 'ArgumentError' })
- if the given angle is smaller than
1
or larger than359
See Also
Sample Graphs
360
is needed.Gets or sets the preferred radial amount (sector) in degrees that child nodes may in total occupy around the global root.
Remarks
This property allows to separately control the sector angle for the designated root node of the tree, while preferredChildSectorAngle controls the angles of all child nodes. The root node will be determined depending on the rootSelectionPolicy.
The minimum allowed root sector angle is 1
and the maximum allowed value is 360
.
Default Value
360
.Property Value
[1,360]
Throws
- Exception({ name: 'ArgumentError' })
- if the given angle is smaller than
1
or larger than360
See Also
Sample Graphs
Gets or sets the root node selection policy of this layout algorithm.
Remarks
The policy determines which node is chosen as (virtual) tree root during the layout process.
To define a custom root node instead of using the predefined policies, utilize the property treeRoot. In this case, the value of rootSelectionPolicy will be ignored.
Default Value
DIRECTED_ROOT.Property Value
See Also
Gets the SelfLoopRouter from the layoutStages of this instance.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- If there is no instance of the respective type in the
See Also
Gets the TreeReductionStage from the layoutStages of this instance.
Remarks
Throws
- Exception({ name: 'InvalidOperationError' })
- If there is no instance of the respective type in the
See Also
Methods
Calculates a radial tree layout of the graph.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Arranges the given graph as a tree graph in a radial-tree-like fashion.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The input graph
Throws
- Exception({ name: 'ArgumentError' })
- If the given graph is not a tree
createLayoutData
(graph: LayoutGraph) : RadialTreeLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the RadialTreeLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪RadialTreeLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given RadialTreeLayout.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the RadialTreeLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪RadialTreeLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given RadialTreeLayout.
LayoutExecutor
type is available at runtime.Returns the preferred radial amount (sector) in degrees that child nodes may in total occupy around the given node.
Remarks
The sector angle controls the degree to which the child nodes may radiate from the center of layout. A value close to 360
means that the child nodes may radiate in (almost) any direction from their parent node, edge lengths can in consequence stay rather small. On the other hand, a small value means that children are restricted to a small angle; thus, edges lengths (and drawings) may become large.
This method returns the preferred root sector if node root
was selected as global root node (rootSelectionPolicy ). Otherwise, it either returns preferredChildSectorAngle or if the given node has an outdegree equal to 2
, it returns the minimum of preferredChildSectorAngle and 180
.
This method may be overridden to provide a custom child sector function.
Parameters
A map of options to pass to the method.
- root - LayoutNode
- the node to get the preferred sector angle for
Returns
- ↪number
- the preferred sector angle for
root
in degrees
See Also
Constants
A data key for marking nodes whose child nodes should be placed in an interleaved fashion.
Remarks
Nodes in the RadialTreeLayout can be arranged around their parents in two different ways: either alternating between two layers, or all on a single layer. If you want only the children of specific parents to be distributed on two layers, use this data key to mark them. Unmarked parents will have their child nodes arranged on a single layer.
Assign true
to a node if its children should be placed in an interleaved fashion, or false
otherwise.
This IMapper<K,V> allows to individually configure the interleaving feature for each node in the graph.
See Also
A data key for specifying a comparison instance that determines the order of the outgoing edges for each node of the tree individually.
See Also
A data key for marking the node that will be used as root node of the tree.
Remarks
Assign true
to the node that should be considered as the root node of the tree, or false
otherwise.
If a custom root node selection is given by registering an IMapper<K,V> with this key, the rootSelectionPolicy is ignored.