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 strong PortConstraints into account. It will connect the edges to the specified locations, the directions, however, 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 IDataProvider key MINIMUM_NODE_SIZE_DP_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 a PreferredPlacementDescriptor 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 ISeriesParallelLayoutPortAssignment. The default assignment is able to consider PortConstraints and edge groups.
The From Sketch mode 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 outgoing edges of a node. A IComparer<T> can be assigned individually for the nodes using a IDataProvider registered with key OUT_EDGE_COMPARER_DP_KEY. For all nodes for which the IDataProvider returns null
, the layout algorithm falls back to the default comparator.
By default, this layout algorithm can only handle graphs with a series-parallel structure. To apply it to a general graph, general graph handling needs to be activated. Then, 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 separately afterwards.
Default Values of Properties
componentLayoutEnabled | true | The stage that arranges connected graph components is activated. |
considerNodeLabels | false | Node labels are not considered. |
defaultOutEdgeComparer | DefaultOutEdgeComparer
| The order of the edges is used along with a special |
defaultPortAssignment | DefaultSeriesParallelLayoutPortAssignment
| All ports are |
fromSketchMode | false | The initial coordinates of the nodes are not considered. |
generalGraphHandling | false | Only series-parallel graphs are handled. |
hideGroupsStageEnabled | false | The stage responsible for hiding group nodes is activated. |
integratedEdgeLabeling | false | Integrated edge labeling is disabled. |
minimumEdgeToEdgeDistance | 5 | |
minimumNodeToEdgeDistance | 10 | |
minimumNodeToNodeDistance | 10 | |
nonSeriesParallelEdgeLabelingAlgorithm | GenericLabeling
| |
routingStyle | ORTHOGONAL
| |
selfLoopRouterEnabled | true | The stage that routes self-loops is activated. |
verticalAlignment | 0.5 | Subgraphs are center aligned. |
Type Details
- yfiles module
- layout-seriesparallel
- yfiles-umd modules
- layout-seriesparallel, layout
- Legacy UMD name
- yfiles.seriesparallel.SeriesParallelLayout
See Also
Constructors
Creates a new SeriesParallelLayout instance with default settings.
Parameters
A map of options to pass to the method.
- considerNodeLabels - boolean
Whether or not the layout algorithm reserves space for node labels to avoid overlaps. This option sets the considerNodeLabels property on the created object.
- integratedEdgeLabeling - boolean
Whether or not the layout algorithm will place edge labels and reserve space for them. This option sets the integratedEdgeLabeling property on the created object.
- verticalAlignment - number
The vertical alignment of parallel subgraphs. This option sets the verticalAlignment property on the created object.
- generalGraphHandling - boolean
Whether or not the layout algorithm can handle general graphs. This option sets the generalGraphHandling 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.
- nonSeriesParallelEdgesDpKey - Object
The key to register a IDataProvider that is used for marking non-series-parallel edges. This option sets the nonSeriesParallelEdgesDpKey property on the created object.
- nonSeriesParallelEdgeLabelingAlgorithm - ILayoutAlgorithm
The labeling algorithm that is applied to all edge labels that belong to non-series-parallel edges. This option sets the nonSeriesParallelEdgeLabelingAlgorithm property on the created object.
- nonSeriesParallelEdgeLabelSelectionKey - Object
The key to register a IDataProvider that is used by the non-series-parallel edge labeling algorithm to determine which edge labels it should place. This option sets the nonSeriesParallelEdgeLabelSelectionKey property on the created object.
- defaultPortAssignment - ISeriesParallelLayoutPortAssignment
The default ISeriesParallelLayoutPortAssignment used for those nodes that do not have their own specific instance. This option sets the defaultPortAssignment property on the created object.
- defaultOutEdgeComparer - IComparer<Object>
The default IComparer<T> used for sorting the outgoing edges incident to nodes that do not have a specific IComparer<T>. This option sets the defaultOutEdgeComparer property on the created object.
- routingStyle - SeriesParallelLayoutRoutingStyle
The currently used routing style for edges. This option sets the routingStyle 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.
- defaultEdgeLayoutDescriptor - SeriesParallelLayoutEdgeLayoutDescriptor
The SeriesParallelLayoutEdgeLayoutDescriptor instance used for all those edges that do not have a specific layout descriptor assigned. This option sets the defaultEdgeLayoutDescriptor property on the created object.
- minimumNodeToNodeDistance - number
The minimum distance between nodes. This option sets the minimumNodeToNodeDistance property on the created object.
- minimumNodeToEdgeDistance - number
The minimum distance between nodes and edges. This option sets the minimumNodeToEdgeDistance property on the created object.
- minimumEdgeToEdgeDistance - number
The minimum distance between edges. This option sets the minimumEdgeToEdgeDistance 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.
- componentLayoutEnabled - boolean
Whether or not the ILayoutStage used for arranging the components of the graph is activated. This option sets the componentLayoutEnabled property on the created object.
- selfLoopRouterEnabled - boolean
Whether or not the ILayoutStage used for routing self-loops is activated. This option sets the selfLoopRouterEnabled property on the created object.
- labeling - ILayoutStage
The ILayoutStage that places the labels of the input graph. This option sets the labeling property on the created object.
- selfLoopRouter - ILayoutStage
The ILayoutStage that routes self-loops. This option sets the selfLoopRouter property on the created object.
- parallelEdgeRouter - ILayoutStage
The ILayoutStage that routes parallel edges. This option sets the parallelEdgeRouter property on the created object.
- componentLayout - ILayoutStage
The ILayoutStage that arranges the connected components of an input graph. This option sets the componentLayout property on the created object.
- subgraphLayout - ILayoutStage
The ILayoutStage that constrains the layout process to a subgraph of the input graph. This option sets the subgraphLayout property on the created object.
- hideGroupsStage - ILayoutStage
The ILayoutStage that hides the group nodes of the input graph. This option sets the hideGroupsStage property on the created object.
- orientationLayout - ILayoutStage
The ILayoutStage that modifies the orientation of a computed layout. This option sets the orientationLayout property on the created object.
- orientationLayoutEnabled - boolean
Whether or not the ILayoutStage that modifies the orientation of the layout is activated. This option sets the orientationLayoutEnabled property on the created object.
- layoutOrientation - LayoutOrientation
The main orientation of the layout. This option sets the layoutOrientation property on the created object.
- labelingEnabled - boolean
Whether or not the ILayoutStage used for placing the labels of the input graph is activated. This option sets the labelingEnabled property on the created object.
- hideGroupsStageEnabled - boolean
Whether or not the ILayoutStage used for hiding group nodes is activated. This option sets the hideGroupsStageEnabled property on the created object.
- parallelEdgeRouterEnabled - boolean
Whether or not the ILayoutStage used for routing parallel edges is activated. This option sets the parallelEdgeRouterEnabled property on the created object.
- subgraphLayoutEnabled - boolean
Whether or not the ILayoutStage used for constraining the layout process to a subgraph of the input graph is activated. This option sets the subgraphLayoutEnabled property on the created object.
Properties
Gets or sets the ILayoutStage that arranges the connected components of an input graph.
Default Value
ComponentLayout.See Also
Defined in
Sets whether or not the ILayoutStage used for arranging the components of the graph is activated.
Default Value
true
.The stage that arranges connected graph components is activated.
See Also
Overrides
Gets or sets whether or not the layout algorithm reserves space for node labels to avoid overlaps.
Default Value
false
.Node labels are not considered.
See Also
Sample Graphs
Gets or sets the SeriesParallelLayoutEdgeLayoutDescriptor instance used for all those edges that do not have a specific layout descriptor assigned.
Default Value
SeriesParallelLayoutEdgeLayoutDescriptor.Throws
- Exception({ name: 'ArgumentError' })
- if the specified
is null
See Also
Gets or sets the default IComparer<T> used for sorting the outgoing edges incident to nodes that do not have a specific IComparer<T>.
Remarks
Default Value
DefaultOutEdgeComparer.The order of the edges is used along with a special
See Also
null
.Gets or sets the default ISeriesParallelLayoutPortAssignment used for those nodes that do not have their own specific instance.
Remarks
Default Value
DefaultSeriesParallelLayoutPortAssignment.All ports are
Throws
- Exception({ name: 'ArgumentError' })
- if
null
is specified
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.
See Also
Gets or sets whether or not the layout algorithm can handle general graphs.
Remarks
Default Value
false
.Only series-parallel graphs are handled.
See Also
Gets or sets the ILayoutStage that hides the group nodes of the input graph.
Default Value
HideGroupsStage.See Also
Defined in
Gets or sets whether or not the ILayoutStage used for hiding group nodes is activated.
Remarks
Default Value(Overrides the default value defined in MultiStageLayout)
false
.The stage responsible for hiding group nodes is activated.
See Also
Defined in
Gets or sets whether or not the layout algorithm will place edge labels and reserve space for them.
Default Value
false
.Integrated edge labeling is disabled.
See Also
Sample Graphs
Gets or sets the ILayoutStage that places the labels of the input graph.
Default Value
See Also
Defined in
Gets or sets whether or not the ILayoutStage used for placing the labels of the input graph is activated.
Remarks
Default Value
false
.The stage responsible for label placement is deactivated.
See Also
Defined in
Gets or sets the main orientation of the layout.
Remarks
Default Value
TOP_TO_BOTTOM.Throws
- Exception({ name: 'ArgumentError' })
- if the specified orientation does not match a default layout orientation
See Also
Defined in
Gets or sets the minimum distance between edges.
Remarks
Default Value
5
.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
.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
.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
.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
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified slope is smaller than
0
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.See Also
Gets or sets the key to register a IDataProvider that is used by the non-series-parallel edge labeling algorithm to determine which edge labels it should place.
Remarks
During the layout, a IDataProvider with this key will be registered with the graph. It will mark all IEdgeLabelLayouts that belong to non-series-parallel edges. A specified custom non-series-parallel edge labeling algorithm needs to obey this selection. If using GenericLabeling as labeling algorithm, set this key as value of property affectedLabelsDpKey.
The labeling algorithm set as default is already configured such that it uses the correct selection key.
Default Value
NON_SERIES_PARALLEL_EDGE_LABELS_DP_KEY.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.Throws
- Exception({ name: 'ArgumentError' })
- if
null
is specified
See Also
Gets or sets the key to register a IDataProvider that is used for marking non-series-parallel edges.
Remarks
Default Value
AFFECTED_EDGES_DP_KEY.Throws
- Exception({ name: 'ArgumentError' })
- if the given key is set to
null
See Also
Gets or sets the ILayoutStage that modifies the orientation of a computed layout.
Default Value
OrientationLayout.See Also
Defined in
Gets or sets whether or not the ILayoutStage that modifies the orientation of the layout is activated.
Remarks
Default Value
true
.The orientation
See Also
Defined in
Gets or sets the ILayoutStage that routes parallel edges.
Default Value
ParallelEdgeRouter.See Also
Defined in
Gets or sets whether or not the ILayoutStage used for routing parallel edges is activated.
Remarks
Default Value
true
.The stage that routes parallel edges is activated.
See Also
Defined in
Gets or sets the preferred length for non-orthogonal segments in octilinear edge routes.
Remarks
Default Value
10
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified length is smaller than
0
See Also
Sample Graphs
Gets or sets the currently used routing style for edges.
Default Value
ORTHOGONAL.See Also
Gets or sets the ILayoutStage that routes self-loops.
Default Value
SelfLoopRouter.See Also
Defined in
Sets whether or not the ILayoutStage used for routing self-loops is activated.
Default Value
true
.The stage that routes self-loops is activated.
See Also
Overrides
Gets or sets the ILayoutStage that constrains the layout process to a subgraph of the input graph.
Default Value
SubgraphLayout.See Also
Defined in
Gets or sets whether or not the ILayoutStage used for constraining the layout process to a subgraph of the input graph is activated.
Remarks
Default Value
false
.The stage that constrains the input graph to a subgraph is deactivated.
See Also
Defined in
Gets or sets the vertical 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.
See Also
Sample Graphs
[0,1]
will be matched with the nearest interval end.Methods
Appends the given ILayoutStage to the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- the ILayoutStage instance to be added
See Also
Defined in
Calculates a layout for the given graph and applies it directly to 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: 'InvalidGraphStructureError' })
- if the graph is not series-parallel
Implements
Checks the sizes of the nodes to be non-zero.
Parameters
A map of options to pass to the method.
- g - LayoutGraph
- The graph to check.
Defined in
Deactivates all predefined ILayoutStages so that upon applyLayout only the layout algorithm will be executed.
See Also
Defined in
Prepends the given ILayoutStage to the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- the ILayoutStage instance to be added
See Also
Defined in
Removes the given ILayoutStage from the layout pipeline.
Remarks
Parameters
A map of options to pass to the method.
- stage - ILayoutStage
- a ILayoutStage to be removed from the layout pipeline
See Also
Defined in
Constants
A data provider key for storing individual settings for edges.
Remarks
Domain | Edge | |
Values | SeriesParallelLayoutEdgeLayoutDescriptor | an edge layout descriptor that provides layout information for each edge or null if the default |
See Also
A data provider key for marking edge labels of non-series-parallel edges.
Domain | IEdgeLabelLayout | an edge label |
Values | boolean | true if the edge label belongs to a non-series-parallel edge, false otherwise |
See Also
A data provider key for assigning different orderings for outgoing edges of the nodes.
Remarks
null
, the outgoing edges maintain their initial order.Domain | YNode | |
Values | IComparer<T> | the ordering for the outgoing edges of a node or null if no |
See Also
A data provider key for providing an individual port distribution at nodes.
Remarks
Domain | YNode | |
Values | ISeriesParallelLayoutPortAssignment | the placement of port locations for a node or null if no |
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 - Graph
- the input graph
Returns
- ↪boolean
true
if the given graph is series-parallel,false
otherwise