This layout algorithm arranges series-parallel graphs.
Remarks
Layout Style
Series-parallel graphs are directed graphs with a single source (node without incoming edges) and a single sink (node without outgoing edges). The layout algorithm highlights the main layout direction (from source to sink). It also emphasizes the paths through the graph because edges are routed with few bends.
SeriesParallelLayout is suitable for the visualization of circuits, call trees or flowcharts.
Concept
Series-parallel graphs are directed graphs with a single source (node without incoming edges) and a single sink (node without outgoing edges) that are built using only the following two rules:
- Series composition: The source of a subgraph is merged with the sink of a second subgraph.
- Parallel composition: The sources and sinks of two subgraphs are merged.
From the recursive structure of series-parallel graphs, the layout algorithm retrieves a decomposition tree where each node represents one of the decomposition types. Then, this tree is traversed recursively from bottom to top, aligning subgraphs above (series) or next to (parallel) each other until the whole graph is arranged. The edges are routed when both end nodes are placed. Different routing styles can be used.
To avoid moving all nodes several times and to be aware of the area that the subtrees occupy, the layout algorithm keeps track of the shape of the subtrees. These shapes are moved and merged during the layout calculation. The layout algorithm also stores the connections between nodes and nodes that haven't already been placed in these shapes.
Features
SeriesParallelLayout can take fixed LayoutPortCandidates into account. It will connect the edges to the specified locations. However, the directions will be ignored.
Grouping of nodes can also be handled by this layout algorithm. It is important that a group node contains a whole series-parallel subgraph. Otherwise, the group nodes may overlap with each other or with other nodes. Edges which are connected to non-empty group nodes are not allowed. Furthermore, the user may specify minimum size constraints for each group node using IMapper<K,V> key MINIMUM_GROUP_NODE_SIZE_DATA_KEY.
The layout algorithm can be configured to reserve space for node labels and to place the edge labels along the edge such that the labels won't overlap with other graph elements. Edge labels are placed according to the information stored in an EdgeLabelPreferredPlacement instance. However, labels that should be centered between source and target are placed close to the target node, unless this edge connects to the local source and sink of a subgraph.
Parallel subgraphs can be aligned in different ways. Depending on the node sizes, a different alignment can increase the compactness of the layout.
The way in which edges are distributed around their incident nodes is computed by an instance of ISeriesParallelLayoutPortAssigner. The default port assigner is able to consider LayoutPortCandidates and edge groups.
The fromSketchMode allows to take the initial locations of the nodes into account. However, the layout algorithm won't insert crossings because it maintains the order of children of each node.
SeriesParallelLayout supports custom sorting of the successors of a node, see childOrder.
This layout algorithm is designed to handle graphs with a series-parallel structure. When it is applied to a general graph, the layout algorithm will temporarily add and/or remove some edges from the input graph until a series-parallel graph is obtained. The edges that were removed will be routed afterward by the nonSeriesParallelEdgeRouter and their labels will be placed by nonSeriesParallelEdgeLabeling.
How port placement constraints are handled depends on the selected portAssigners. In addition, the PortPlacementStage is applied 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. The property routeCorrectionPolicy is set to LOCAL_ORTHOGONAL.
- GroupHidingStage: Removes group nodes and their adjacent edges before layout processing, and reinserts them afterward. Note: This stage is disabled by default.
- 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.
- 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.
- 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.
With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.
Default Values of Properties
defaultPortAssigner | SeriesParallelLayoutPortAssigner
| All ports are |
edgeLabelPlacement | INTEGRATED
| Edge labels are placed by the layout algorithm. |
edgeRoutingStyle | ORTHOGONAL
| |
fromSketchMode | false | The initial coordinates of the nodes are not considered. |
minimumEdgeDistance | 5 | |
minimumNodeDistance | 10 | |
minimumNodeToEdgeDistance | 10 | |
nodeLabelPlacement | CONSIDER
| Node labels are considered. |
parallelSubgraphAlignment | 0.5 | Subgraphs are center aligned. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new SeriesParallelLayout instance with default settings.
Parameters
A map of options to pass to the method.
- layoutOrientation - LayoutOrientation
- The layoutOrientation of this layout algorithm. This option sets the layoutOrientation property on the created object.
- nodeLabelPlacement - NodeLabelPlacement
- How the layout handles the position of 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.
- parallelSubgraphAlignment - number
- The alignment of parallel subgraphs. This option sets the parallelSubgraphAlignment property on the created object.
- nonSeriesParallelEdgeRouter - ILayoutAlgorithm
- The edge routing algorithm used for the edges of a general graph that are not part of the series-parallel subgraph whose layout is calculated. This option sets the nonSeriesParallelEdgeRouter property on the created object.
- nonSeriesParallelEdgeLabeling - GenericLabeling
- The labeling algorithm that is applied to all edge labels that belong to non-series-parallel edges. This option either sets the value directly or recursively sets properties to the instance of the nonSeriesParallelEdgeLabeling property on the created object.
- defaultPortAssigner - ISeriesParallelLayoutPortAssigner
- The default ISeriesParallelLayoutPortAssigner used for those nodes that do not have an individual port assigner specified. This option sets the defaultPortAssigner property on the created object.
- edgeRoutingStyle - SeriesParallelLayoutRoutingStyle
- The routing style for edges. This option sets the edgeRoutingStyle property on the created object.
- minimumPolylineSegmentLength - number
- The minimum vertical distance of the edge segments that are not orthogonal. This option sets the minimumPolylineSegmentLength property on the created object.
- minimumSlope - number
- The minimum slope which a non-orthogonal edge segment should have. This option sets the minimumSlope property on the created object.
- preferredOctilinearSegmentLength - number
- The preferred length for non-orthogonal segments in octilinear edge routes. This option sets the preferredOctilinearSegmentLength property on the created object.
- defaultEdgeDescriptor - SeriesParallelLayoutEdgeDescriptor
- The SeriesParallelLayoutEdgeDescriptor instance used for all those edges that do not have a specific descriptor assigned. This option either sets the value directly or recursively sets properties to the instance of the defaultEdgeDescriptor property on the created object.
- minimumNodeDistance - number
- The minimum distance between nodes. This option sets the minimumNodeDistance property on the created object.
- minimumNodeToEdgeDistance - number
- The minimum distance between nodes and edges. This option sets the minimumNodeToEdgeDistance property on the created object.
- minimumEdgeDistance - number
- The minimum distance between edges. This option sets the minimumEdgeDistance property on the created object.
- fromSketchMode - boolean
- Whether or not to take the coordinates of the input diagram into account when arranging the nodes. This option sets the fromSketchMode property on the created object.
Properties
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
Gets or sets the SeriesParallelLayoutEdgeDescriptor instance used for all those edges that do not have a specific descriptor assigned.
Default Value
SeriesParallelLayoutEdgeDescriptor.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified
is null
See Also
Gets or sets the default ISeriesParallelLayoutPortAssigner used for those nodes that do not have an individual port assigner specified.
Remarks
Default Value
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if
null
is specified
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 routing style for edges.
Default Value
ORTHOGONAL.Property Value
See Also
Gets or sets whether or not to take the coordinates of the input diagram into account when arranging the nodes.
Remarks
Default Value
false
.The initial coordinates of the nodes are not considered.
Property Value
true
if input coordinates are considered, false
otherwiseSee Also
Gets or sets the layoutOrientation of this layout algorithm.
Gets the mutable stack of ILayoutStage that will be applied to this layout.
Gets or sets the minimum distance between edges.
Remarks
Default Value
5
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is smaller than
0
See Also
Sample Graphs
Gets or sets the minimum distance between nodes.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is smaller than
0
See Also
Sample Graphs
Gets or sets the minimum distance between nodes and edges.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is smaller than
0
See Also
Sample Graphs
Gets or sets the minimum vertical distance of the edge segments that are not orthogonal.
Remarks
Default Value
30
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified length is smaller than
0
See Also
Sample Graphs
Gets or sets the minimum slope which a non-orthogonal edge segment should have.
Remarks
Default Value
0.25
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified slope is smaller than
0
See Also
Sample Graphs
Gets or sets how the layout handles the position of node labels.
Default Value
Property Value
See Also
Sample Graphs
Gets or sets the labeling algorithm that is applied to all edge labels that belong to non-series-parallel edges.
Default Value
GenericLabeling.Property Value
See Also
Gets or sets the edge routing algorithm used for the edges of a general graph that are not part of the series-parallel subgraph whose layout is calculated.
Default Value
EdgeRouter.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if
null
is specified
See Also
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
Gets or sets the alignment of parallel subgraphs.
Remarks
- Ratio
0
means that nodes are top-aligned - Ratio
0.5
means that nodes are center-aligned - Ratio
1
means that nodes are bottom-aligned
Default Value
0.5
.Subgraphs are center aligned.
Property Value
[0,1]
See Also
Sample Graphs
[0,1]
will be matched with the nearest interval end.Gets or sets the preferred length for non-orthogonal segments in octilinear edge routes.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified length is smaller than
0
See Also
Sample Graphs
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
Methods
Calculates a series-parallel layout of the graph.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Calculates a series-parallel layout for the given graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Throws
- Exception({ name: 'ArgumentError' })
- if the graph is not series-parallel
createLayoutData
(graph: LayoutGraph) : SeriesParallelLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the SeriesParallelLayout.
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
- ↪SeriesParallelLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given SeriesParallelLayout.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the SeriesParallelLayout.
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
- ↪SeriesParallelLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given SeriesParallelLayout.
See Also
LayoutExecutor
type is available at runtime.Constants
A data key for storing individual settings for edges.
Remarks
null
if the defaultEdgeDescriptor should be used.See Also
A data key for assigning different orderings for outgoing edges of the nodes.
Remarks
null
, the outgoing edges maintain their initial order.See Also
A data key for providing an individual port distribution at nodes.
Remarks
See Also
Static Methods
Determines whether or not the given graph has a series-parallel structure.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Returns
- ↪boolean
true
if the given graph is series-parallel,false
otherwise