The TreeReductionStage temporarily reduces general graphs to trees.
Remarks
Layout Style
This stage prepares a non-tree graph such that it can be processed by a tree layout algorithm.
Concept
This ILayoutStage works in three steps:
- Remove some edges to get a tree or forest from the graph
- Invoke the coreLayout which supports tree graph handling
- Reinsert all previously removed edges
- Optionally route these edges using the non-tree edge router and place their labels using the non-tree edge labeling algorithm.
Features
The routing of the temporarily hidden non-tree edges can be customized by specifying an edge routing algorithm for those edges. Similarly, the placement of edge labels of non-tree edges can be delegated to a custom edge labeling algorithm. As default, both custom algorithms are not specified and, thus, non-tree edges are not routed and edge labels not placed.
This stage is also able to handle multi-parent structures, i.e., structures of multiple nodes that share the same predecessors as well as the same successors. More precisely, if the specified coreLayout supports multi-parent structures (see allowMultiParent) and option allowMultiParent is enabled, this stage does not hide such structures, i.e., the multi-parent structures are passed to the coreLayout.
Non-tree edges can also be bundled together such that their common parts are to some degree merged into a bundled part. The edge bundling can be specified by means of property edgeBundling.
Default Values of Properties
allowMultiParent | false | The reduced graph is a normal tree. |
nonTreeEdgeLabeling | null | Edge labels of non-tree edges are not placed. |
nonTreeEdgeRouter | null | Non-tree edges are not routed. |
Type Details
- yFiles module
- algorithms
Constructors
Creates a new TreeReductionStage instance with the given core layout algorithm and default settings.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- the core layout algorithm
- allowMultiParent - boolean
- Whether or not multi-parent structures (structures of multiple nodes that share the same predecessors as well as the same successors) are allowed. This option sets the allowMultiParent property on the created object.
- nonTreeEdgeRouter - ILayoutAlgorithm
- The edge routing algorithm that is applied to all non-tree edges. This option sets the nonTreeEdgeRouter property on the created object.
- nonTreeEdgeLabeling - GenericLabeling
- The labeling algorithm that is applied to all edge labels that belong to non-tree edges. This option either sets the value directly or recursively sets properties to the instance of the nonTreeEdgeLabeling property on the created object.
- enabled - boolean
Properties
Gets or sets whether or not multi-parent structures (structures of multiple nodes that share the same predecessors as well as the same successors) are allowed.
Remarks
Default Value
false
.The reduced graph is a normal tree.
Property Value
true
if multi-parent structures are allowed, false
otherwiseSample Graphs
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Gets the EdgeBundling instance that defines the settings of the edge bundling feature.
Remarks
The specified EdgeBundling defines global bundling properties. Settings for individual edges can be defined by assigning an EdgeBundleDescriptor to an edge with edgeBundleDescriptors. To enable bundling for all non-tree edges, set a defaultBundleDescriptor which has bundling enabled.
If the graph contains self-loops that belong to the set of non-tree edges, the stage will invoke the router defined for the non-tree edges in order to route them. In the case where this is not desired, the user has to hide them from the stage and route them afterwards as desired.
Property Value
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.
Remarks
By default, when constructed, stages should be enabled. Users may disable a stage's functionality by setting this property to false
.
Stages that can guarantee that the graph will not change can choose to not even execute the coreLayout when disabled.
Implements
Gets or sets the labeling algorithm that is applied to all edge labels that belong to non-tree edges.
Default Value
null
.Edge labels of non-tree edges are not placed.
Property Value
Gets or sets the edge routing algorithm that is applied to all non-tree edges.
Default Value
null
.Non-tree edges are not routed.
Property Value
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- The graph to apply the layout to.
Implements
Determines a spanning tree of the graph and passes it to the coreLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Implements
createLayoutData
(graph: LayoutGraph) : TreeReductionStageData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the TreeReductionStage.
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
- ↪TreeReductionStageData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given TreeReductionStage.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the TreeReductionStage.
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
- ↪TreeReductionStageData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given TreeReductionStage.
LayoutExecutor
type is available at runtime.Routes all edges that do not belong to the chosen spanning tree.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph containing tree and non-tree edges
- nonTreeEdgeMap - IMapper<LayoutEdge,boolean>
null
).Constants
A data key for explicitly marking (some) edges that should not be considered for the tree.
Remarks
true
to an edge if the edge should be excluded from the tree, or false
otherwise.See Also
A data key for publishing the non-tree edges that this stage actually selected.