documentationfor yFiles for HTML 2.6

RecursiveGroupLayout

This layout algorithm recursively traverses a hierarchically organized graph in a bottom-up fashion and applies a specified layout algorithm to the contents (direct children) of each group node.

Inheritance Hierarchy
LayoutStageBase
RecursiveGroupLayout
Implemented Interfaces

Remarks

Layout Style

The way a graph is arranged depends on the layout algorithms which are applied to the different group nodes. RecursiveGroupLayout is able to produce different layout styles for the content of each group node.

This layout algorithm can be either applied if a layout algorithm cannot handle grouped graphs by itself or if the content of (some) group nodes should be arranged differently.

Concept

RecursiveGroupLayout uses a hierarchy tree representation of the grouped graph in which the content nodes are the children of their containing group node. That way, it can traverse the tree recursively while arranging only the direct children of each group node. The layout algorithm starts by arranging the leaves in the hierarchy tree, then works its way up to the root computing the layout for each group node in the tree.

A) Group Handling

All nodes other than the direct children are temporarily hidden. The layout algorithm performs two steps for each group node.

  1. It arranges the direct children using either the core layout algorithm or a special layout algorithm retrieved from a IDataProvider registered with GROUP_NODE_LAYOUT_DP_KEY. The content of group nodes among the children is already arranged at this time and will be ignored. These group nodes are handled like normal nodes with a size that encloses the content.

    The following two special cases should be considered. If null is specified as layout algorithm for a group, the recursion will be disabled and the group is handled non-recursively: the group itself and its content is arranged by the algorithm specified for the nearest ancestor which has a non-null algorithm mapped to it. Importantly, this must be distinguished from the second case where the layout of the group content should remain unchanged. This is achieved when the group is associated with NULL_LAYOUT as responsible layout algorithm (or any another algorithm that does not change the layout).

  2. Then RecursiveGroupLayout computes the final size of the group node using an implementation of ILayoutGroupBoundsCalculator. Customized ILayoutGroupBoundsCalculators can be specified using groupBoundsCalculator. Aside from the resulting layout, this size is used in the following iteration.

B) Top-Level Hierarchy

After a layout is applied to all group nodes, the layout algorithm uses the core layout algorithm to arrange the top level hierarchy. Note that RecursiveGroupLayout can run without a core layout. In this case no layout is calculated for the top level hierarchy. Still, for group nodes with a non-null algorithm, the bounds are adjusted to fit their respective contents.

C) Inter-Edge Routing

Finally, routes for the edges whose source node is located at a different hierarchy level than its target node are computed. The edge routing algorithm for these so-called inter-edges can be customized.

Features

There are two alternatives for applying different layout styles to the contents of group nodes:

  1. Mapping each group node to a corresponding layout algorithm by registering a IDataProvider with key GROUP_NODE_LAYOUT_DP_KEY. The content of the hierarchy root is arranged with the core layout algorithm.
  2. Using LayoutMultiplexer as core layout algorithm.

Since RecursiveGroupLayout delegates the actual arrangement of the graph to other layout algorithms, it will support the same features as the currently used layout algorithm.

The improvement of the routing of inter-edges is based on the insertion of PortCandidates or the conversion of PortConstraints into PortCandidates. Hence, they only work well if the applied layout algorithm supports PortCandidates.

This algorithm also provides a From Sketch mode that should be activated if the applied layout algorithm runs in From Sketch mode, too. Otherwise, the initial coordinates may not be considered correctly.

It is also possible to apply individual layout styles to different sub-graphs using this algorithm without actually defining group nodes: Use TemporaryGroupNodeInsertionStage and specify RecursiveGroupLayout as its core layout algorithm. The stage allows to define sub-graphs which are internally enclosed by a temporary group node. To assign a specific ILayoutAlgorithm instance for a temporary group, specify the desired ILayoutAlgorithm in the TemporaryGroupDescriptor's property recursiveGroupLayoutAlgorithm. It is then not necessary to use key GROUP_NODE_LAYOUT_DP_KEY.

Default Values of Properties

considerEmptyGroupstrueEmpty group nodes are resized.
fromSketchModefalseThe initial coordinates of the nodes are not taken into account.
groupBoundsCalculatorMinimumSizeGroupBoundsCalculator
interEdgeRouternullEdges are routed as straight lines from source to target.
interEdgesDpKeyAFFECTED_EDGES_DP_KEY

Type Details

yfiles module
layout-core
yfiles-umd modules
All layout modules, view-layout-bridge
Legacy UMD name
yfiles.layout.RecursiveGroupLayout

See Also

To only recalculate the group node bounds and not change any content while also keeping the top-level layout as it is, apply RecursiveGroupLayout with core layout set to NULL_LAYOUT and no further configuration.

Constructors

Properties

Methods

Constants