C

HierarchicalLayout

This layout algorithm arranges graphs in a hierarchical fashion.
ImplementsInheritance Hierarchy

Remarks

Layout Style

The nodes are distributed into layers so that most of the edges point to the main layout direction. The order of the nodes within the layers ensures that the number of edge crossings is as small as possible. There are different edge routing styles available. Edges can be orthogonal, polyline, octilinear, or curved (see RoutingStyleDescriptor for details).

Hierarchical diagrams are commonly used for the visualization of hierarchical data, since they facilitate the identification of dependencies and relationships among the nodes of the graph. Possible application domains are the following: workflow visualization, call graph visualization, entity-relationship diagrams, biochemical pathways, and network management.

Hierarchical Layout obtained with default settings

Concept

The layout algorithm runs in three main phases:

  • Layering – The nodes are distributed into layers by means of fromScratchLayerAssigner or fixedElementsLayerAssigner, respectively. If the layout orientation is top-to-bottom, the nodes in each layer are arranged horizontally while the layers are ordered vertically top-to-bottom.
  • Sequencing – The order of the nodes in each layer is determined such that the number of edge crossings is as small as possible. To specify the sequencing algorithm, use fromScratchSequencer or fixedElementsSequencer.
  • Drawing – The layout algorithm assigns the final coordinates to all nodes and routes the edges.

Features

This layout algorithm is able to create hierarchical layouts from scratch or add new elements to the existing sketch drawing incrementally. In order to add elements incrementally to the current sketch or let the algorithm optimize certain elements in the current sketch, set fromSketchMode to true. Then associate the IncrementalNodeHints with the elements to be added incrementally via the layout data property incrementalNodes and/or define a collection of edges that should be sequenced incrementally via property incrementalEdges.

HierarchicalLayoutNodeDescriptor and HierarchicalLayoutEdgeDescriptor instances can be used for specifying individual information (e.g. distances or routing styles) for each node and edge in the graph. The descriptors are bound to the graph using properties nodeDescriptors or edgeDescriptors. If there is no descriptor assigned to some nodes/edges, a default descriptor will be used. To set default descriptors use defaultNodeDescriptor and defaultEdgeDescriptor.

HierarchicalLayout supports connecting edges to a node on a specific side or even an exact location by assigning LayoutPortCandidates to the edges or NodePortCandidatess to the nodes. If an edge with registered LayoutPortCandidates connects to nodes with NodePortCandidatess, the algorithm will try to match both collections to find an appropriate port. In case there is no matching port candidate, a LayoutPortCandidate specified for the edge is preferred. For the matching to work properly, the candidates in both collections need to be the same instances. Furthermore, LayoutPortCandidates with multiple sides (e.g. LEFT or] RIGHT) are not supported. To model that an edge should connect at one of several sides, define multiple candidates instead, where each candidate has a single side.

The edge grouping feature of this layout algorithm is restricted to normal, hierarchical edges. Edges with recursiveEdgePolicy DIRECTED or UNDIRECTED will not be grouped. They are also not grouped when enabling automaticEdgeGrouping.

The port grouping feature (see sourcePortGroupIds and targetPortGroupIds in ports) allows to specify edges that share the same port location at their source/target. However, unlike as for edge grouping, edges with port groups will be routed independently without sharing segments. Port grouping has similar restrictions as the edge grouping feature. In addition, port grouping is not considered for self-loops.

The port alignment feature (see sourcePortAlignmentIds and targetPortAlignmentIds) allow to specify edges that either share the same port location or be placed exactly opposite provided. The alignment is not considered when deciding on which node sides to place the ports. To ensure that the edges are aligned in the presence of EdgePortCandidates or NodePortCandidates, it is recommended to assign consistent candidates to all aligned edges. Alignment works both for edges in the layoutOrientation (for example edges with ports on the TOP or BOTTOM sides if the layout orientation is top-to-bottom) and edges that are orthogonal to it. However, the quality of the resulting layouts is typically higher when aligning edges in the layout orientation. Port alignment is not supported at group nodes, for self-loops, and for edges that are part of a grid component at the root of the grid component.

The HierarchicalLayout also supports nodeTypes as a subordinate criterion during the sequencing of nodes within their layer. More precisely, the sequencing algorithm prefers to place nodes of the same type next to each other if this does not induce additional crossings or conflicts with other constraints (like node groups, swimlanes, or sequenceConstraints ). The algorithm uses an additional local optimization heuristic to improve the placement with respect to node types and, thus, does not guarantee optimal results. Furthermore, this additional step may increase the required runtime. Note that node types do not affect the layer assignment.

HierarchicalLayout allows restricting the duration which may be a suitable option to reduce the runtime required for large graphs. Note that restricting the maximum duration can result in a lower layout quality. Furthermore, the actual runtime may exceed the maximum duration since the layout algorithm still has to find a valid solution.

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:

  • SubgraphLayoutStage: Filters the graph to include only specific nodes and edges from a subgraph while preserving the positions of excluded elements. Note: This stage is disabled by default.
  • ComponentLayout: Arranges graph components with customizable styles. Note: This stage is disabled by default.
  • 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. The property edgeLabelPlacement is set to IGNORE to allow for proper handling of edge labels in the hierarchical layout.

With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.

Performance

Specifying a stopDuration can reduce the time the HierarchicalLayout takes to produce a result. The acceleration is achieved by switching to faster heuristics for some features and skipping some optional optimization steps. This can impact the quality of the layout result and is usually most noticeable in the calculated edge routes. It should be noted that the stopDuration is not a guarantee for the maximum time spent, as the algorithm still has to produce a valid result.

The coordinateAssigner uses a comparably expensive SymmetryOptimizationStrategy by default, which improves the symmetry of the calculated layout result. This optimization can be disabled to speed up the layout calculation, or the faster WEAK strategy can be applied as a compromise between speed and quality.

Default Values of Properties

NameDefaultDescription
componentArrangementPolicyComponentArrangementPolicy.TOPMOST
Connected components are aligned with their first layer.
edgeLabelPlacementEdgeLabelPlacement.INTEGRATED
Edge labels are placed by the layout algorithm.
gridSpacing0
There is no grid specified.
groupAlignmentPolicyGroupAlignmentPolicy.CENTER
Groups and normal nodes are center aligned.
groupLayeringPolicyGroupLayeringPolicy.RECURSIVE
The content of groups is considered separately during the layering stage.
nodeLabelPlacementNodeLabelPlacement.CONSIDER
Node labels are considered.
stopDurationTimeSpan.MAX_VALUE
The layout algorithm runs unrestricted.

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new HierarchicalLayout instance with the default settings.

Parameters

Properties

Gets or sets whether or not edges are grouped automatically.
The automatic edge grouping tries to group a high number of edges without changing the semantics of the graph, i.e., it groups edges either at a common source node or a common target node. Edge groupings often allow more compact layouts since grouped edges are routed in a bus-style manner.
Edges are only grouped at their source (target) node if they do not have port candidates or port group ids (see sourcePortGroupIds and targetPortGroupIds in ports) at this node. Furthermore, edges cannot be grouped at a node with specified port candidate set.
User specified edge groups are not considered.
This setting is ignored for edges with recursive edge policies DIRECTED and UNDIRECTED, including edges where source or target are not inside a group node.
final

Property Value

true if the edge grouping should be applied, false otherwise

Default Value

The default value is: false
Edges are not grouped automatically.

Sample Graphs

ShownSetting: false

See Also

Developer's Guide
Gets or sets the policy that specifies how to arrange connected components.
conversionfinal

Property Value

one of the default component arrangement policies

Throws

Exception ({ name: 'ArgumentError' })
if the specified policy does not match a default component arrangement policy

Default Value

The default value is: ComponentArrangementPolicy.TOPMOST
Connected components are aligned with their first layer.
Gets the ComponentLayout from the layoutStages of this instance.
If you need to replace the instance, modify the layoutStages stack using replace. If you want to remove a stage, consider disabling it instead.
readonlyfinal

Throws

Exception ({ name: 'InvalidOperationError' })
If there is no instance of the respective type in the layoutStages
Gets the coordinateAssigner instance that will calculate the final node placement (coordinates) of the layout.
Don't use this property if a custom ICoordinateAssigner implementation was set with coordinateAssigner.
readonlyfinal

Property Value

the coordinateAssigner instance if there is one set, otherwise throws an exception

Throws

Exception ({ name: 'InvalidOperationError' })
if the ICoordinateAssigner specified as property coordinateAssigner is not of type coordinateAssigner. To access the instance directly access the core property.

Default Value

Gets or sets the HierarchicalLayoutEdgeDescriptor instance used for all those edges that do not have a specific descriptor assigned.
To define individual settings per item (edge), use the layout data property edgeDescriptors.
final

Property Value

Throws

Exception ({ name: 'ArgumentError' })

Default Value

The default value is: HierarchicalLayoutEdgeDescriptor
A descriptor instance with default settings.

See Also

Developer's Guide
API
edgeDescriptors
Gets or sets the HierarchicalLayoutNodeDescriptor instance used for all those nodes that do not have a specific descriptor assigned.
To define individual settings per item (node), use the layout data property nodeDescriptors.
final

Property Value

Throws

Exception ({ name: 'ArgumentError' })

Default Value

The default value is: HierarchicalLayoutNodeDescriptor
A descriptor instance with default settings.

See Also

Developer's Guide
API
nodeDescriptors
Gets or sets the minimum distance between two directly consecutive edges that pass through the same layer.

More precisely, the specified value is the minimum distance between the two vertical segments of these edges that traverse the layer. The algorithm does not consider this value if the layer contains other elements lying between the two edges (e.g., nodes or group node borders).

All values have to be greater than or equal to 0.

If edges should use different distances, you can map them to different HierarchicalLayoutEdgeDescriptor instances (see edgeDescriptors) with custom minimumDistance values.
This property delegates to the according property of DrawingDistanceCalculator. It must not be used if a different IDrawingDistanceCalculator instance is set as value of property drawingDistanceCalculator.
final

Property Value

the non-negative minimum distance

Throws

Exception ({ name: 'ArgumentError' })
if the distance is negative
Exception ({ name: 'InvalidOperationError' })
if the current drawingDistanceCalculator is not an instance of DrawingDistanceCalculator

Default Value

The default value is: 20

Sample Graphs

ShownSetting: Edge distance 10

See Also

Developer's Guide
Gets or sets how the layout handles the position of edge labels.
conversionfinal

Property Value

INTEGRATED if the layout algorithm places the edge labels avoiding overlaps, IGNORE if the edge labels are ignored by the layout algorithm, and GENERIC if the edge labels are placed by an independent labeling algorithm. The used generic labeling algorithm can be accessed for further configuration on the layoutStages, using get.

Default Value

The default value is: EdgeLabelPlacement.INTEGRATED
Edge labels are placed by the layout algorithm.

Sample Graphs

ShownSetting: IGNORE

See Also

Developer's Guide
Gets or sets a predefined layering strategy for the HierarchicalLayout.

The layout algorithm assigns the nodes to separate layers. For layout orientation top-to-bottom, nodes within the same layer will be placed on the same horizontal line (y-coordinate). The layers will be arranged vertically (below each other), with the first layer at the topmost.

Besides the various prebuilt layering strategies, the layering can also be customized by specifying so-called layering constraints or by implementing a custom ILayerAssigner.

This method wraps the internal implementations into a MultiComponentLayerAssigner instance so that it is possible to specify the behavior of the algorithm if the componentLayout is disabled (via property enabled).

The from sketch mode uses a specific layering strategy and, thus, ignores this setting.
conversionfinal

Property Value

one of the predefined layering strategies

Throws

Exception ({ name: 'ArgumentError' })
if an unknown strategy is given

Default Value

See Also

Developer's Guide
API
fromScratchLayerAssigner
Gets or sets a value indicating whether the layout should be calculated based on the current sketch, allowing incremental insertion of elements.

If set to true, the layout will keep some nodes fixed and insert the remaining nodes incrementally. Nodes can be marked as incremental using incrementalNodes. Fixed elements will be handled by the fixedElementsSequencer and fixedElementsLayerAssigner. Incremental elements will be added during the layering or the sequencing phase. They are handled by fromScratchLayerAssigner and fromScratchSequencer, respectively.

If set to false, the layout will be recalculated entirely from scratch. All elements will be handled by the same layerer and sequencer.

final

Default Value

The default value is: false
The layout will start from scratch by default.

See Also

Developer's Guide
API
fixedElementsLayerAssigner, fixedElementsSequencer, fromScratchLayerAssigner, fromScratchSequencer, incrementalNodes
Gets or sets the equidistant spacing between the horizontal and vertical grid lines.
The grid spacing needs to be a non-negative value. If it is set to 0, no grid is considered, otherwise nodes and edges are placed on multiples of the grid spacing.
The grid feature doesn't work together with exact (layer/sequence) coordinate hints.
final

Property Value

the grid spacing

Throws

Exception ({ name: 'ArgumentError' })
Thrown when an attempt is made to set a negative grid spacing value.

Default Value

The default value is: 0
There is no grid specified.

Sample Graphs

ShownSetting: No grid

See Also

Developer's Guide
API
IncrementalNodeHint
Gets or sets the group layer alignment strategy used for recursive group layering.
conversionfinal

Property Value

one of the default group alignment policies

Default Value

The default value is: GroupAlignmentPolicy.CENTER
Groups and normal nodes are center aligned.

See Also

Developer's Guide
API
groupLayeringPolicy
Gets or sets the policy that specifies how to compute the layering in grouped graphs.
conversionfinal

Property Value

one of the default group layering policies

Default Value

The default value is: GroupLayeringPolicy.RECURSIVE
The content of groups is considered separately during the layering stage.

See Also

Developer's Guide
Gets or sets the layoutOrientation of the OrientationStage.
conversionfinal

See Also

Developer's Guide
Gets or sets the minimum distance between two adjacent layers.
The specified distance should have a non-negative value.
final

Property Value

the non-negative minimum distance

Throws

Exception ({ name: 'ArgumentError' })
if the distance is negative

Default Value

The default value is: 20

Sample Graphs

ShownSetting: Layer distance 10

See Also

Developer's Guide
Gets or sets the minimum distance between two adjacent nodes in one layer.
All values have to be greater than or equal to 0.
If nodes should use different distances, you can map them to different HierarchicalLayoutNodeDescriptor instances (see nodeDescriptors) with custom minimumDistance values.
This property delegates to the according property of DrawingDistanceCalculator. It must not be used if a different IDrawingDistanceCalculator instance is set as value of property drawingDistanceCalculator.
final

Property Value

the non-negative minimum distance

Throws

Exception ({ name: 'ArgumentError' })
if the distance is negative
Exception ({ name: 'InvalidOperationError' })
if the current drawingDistanceCalculator is not an instance of DrawingDistanceCalculator

Default Value

The default value is: 30

Sample Graphs

ShownSetting: Node distance 10

See Also

Developer's Guide
Gets or sets how the layout handles the position of node labels.
conversionfinal

Property Value

CONSIDER if the layout algorithm takes the position and sizes of the node labels into account, IGNORE if the node labels are ignored by the layout algorithm, and GENERIC if the node labels are placed by an independent labeling algorithm. The used generic labeling algorithm can be accessed for further configuration on the layoutStages, using get.

Default Value

The default value is: NodeLabelPlacement.CONSIDER
Node labels are considered.

Sample Graphs

ShownSetting: IGNORE

See Also

Developer's Guide
Gets or sets the minimum distance between an edge and an adjacent node in one layer.
All values have to be greater than or equal to 0.
If nodes/edges should use different distances, you can map them to different HierarchicalLayoutNodeDescriptor /HierarchicalLayoutEdgeDescriptor instances (see nodeDescriptors and edgeDescriptors) with custom minimum distance values.
This property delegates to the according property of DrawingDistanceCalculator. It must not be used if a different IDrawingDistanceCalculator instance is set as value of property drawingDistanceCalculator.
final

Property Value

the non-negative minimum distance

Throws

Exception ({ name: 'ArgumentError' })
if the distance is negative
Exception ({ name: 'InvalidOperationError' })
if the current drawingDistanceCalculator is not an instance of DrawingDistanceCalculator

Default Value

The default value is: 15

Sample Graphs

ShownSetting: Node-edge distance 10

See Also

Developer's Guide
Gets or sets the preferred time limit for the layout algorithm.
Values have to be greater or equal to 0.
Restricting the duration may result in a lower layout quality. Furthermore, the real runtime may exceed the duration since the layout algorithm still has to find a valid solution.
The layout algorithm takes also into consideration the time limits of the default ILayerAssigner, ISequencer and ICoordinateAssigner instances (if any) and will try to not exceed the given values.
conversionfinal

Property Value

a non-negative value that specifies the time limit

Throws

Exception ({ name: 'ArgumentError' })
if the duration is negative

Default Value

The default value is: TimeSpan.MAX_VALUE
The layout algorithm runs unrestricted.

See Also

Developer's Guide

Methods

Calculates a hierarchical layout of the given graph.
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.

Parameters

graph: LayoutGraph
the input graph
Delegates the calculation of the hierarchical layout to a configured HierarchicalLayoutCore instance.
HierarchicalLayout applies its own configuration to HierarchicalLayoutCore and also prepares the graph for layout.
The given graph will not be copied during the layout process and the layout will be immediately applied to the given graph.
protectedfinal

Parameters

graph: LayoutGraph
the input graph
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the HierarchicalLayout.
The generic type arguments of the created layout data are compatible with instances of LayoutGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.

Parameters

graph: LayoutGraph
the graph that determines the generic type arguments of the created layout data

Return Value

HierarchicalLayoutData<LayoutNode, LayoutEdge, LayoutGraphItem, LayoutNodeLabel, LayoutEdgeLabel>
an instance of layout data that can be used to perform item-specific configurations for the given HierarchicalLayout.
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the HierarchicalLayout.
The generic type arguments of the created layout data are compatible with instances of IGraph, but the layout data is not bound to a specific graph instance. Therefore, the created layout data still has to be passed as an argument of applyLayout in order to be applied.
This method is not available unless the module view-layout-bridge is loaded. Either load the module 'view-layout-bridge' explicitly or ensure that the LayoutExecutor type is available at runtime.

Parameters

graph?: IGraph
the graph that determines the generic type arguments of the created layout data

Return Value

HierarchicalLayoutData<INode, IEdge, IModelItem, ILabel, ILabel>
an instance of layout data that can be used to perform item-specific configurations for the given HierarchicalLayout.

See Also

Developer's Guide

Constants

All constants are filtered. Go to Filters.

Static Methods

All static methods are filtered. Go to Filters.