C

SeriesParallelLayout

This layout algorithm arranges series-parallel graphs.
ImplementsInheritance Hierarchy

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:

  1. Series composition: The source of a subgraph is merged with the sink of a second subgraph.
  2. 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:

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

Default Values of Properties

NameDefaultDescription
defaultPortAssignerSeriesParallelLayoutPortAssigner
All ports are DISTRIBUTED on the borders of the nodes.
edgeLabelPlacementEdgeLabelPlacement.INTEGRATED
Edge labels are placed by the layout algorithm.
edgeRoutingStyleSeriesParallelLayoutRoutingStyle.ORTHOGONAL
fromSketchModefalse
The initial coordinates of the nodes are not considered.
minimumEdgeDistance5
minimumNodeDistance10
minimumNodeToEdgeDistance10
nodeLabelPlacementNodeLabelPlacement.CONSIDER
Node labels are considered.
parallelSubgraphAlignment0.5
Subgraphs are center aligned.

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new SeriesParallelLayout instance with default settings.

Parameters

Properties

Gets the ComponentLayout from the layoutStages of this instance.
If you need to replace the instance, modify the layoutStages stack using replace.
readonlyfinal

Throws

Exception ({ name: 'InvalidOperationError' })
If there is no instance of the respective type in the layoutStages
Gets or sets the SeriesParallelLayoutEdgeDescriptor instance used for all those edges that do not have a specific descriptor assigned.
To define individual settings per edge, use the layout data property edgeDescriptors.
final

Property Value

Throws

Exception ({ name: 'ArgumentError' })
if the specified SeriesParallelLayoutEdgeDescriptor is null

Default Value

The default value is: SeriesParallelLayoutEdgeDescriptor

See Also

Developer's Guide
API
edgeDescriptors
Gets or sets the default ISeriesParallelLayoutPortAssigner used for those nodes that do not have an individual port assigner specified.
An ISeriesParallelLayoutPortAssigner can be assigned individually for the nodes using the layout data property portAssigners.
final

Property Value

the port assigner

Throws

Exception ({ name: 'ArgumentError' })
if null is specified

Default Value

The default value is: SeriesParallelLayoutPortAssigner
All ports are DISTRIBUTED on the borders of the nodes.

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 the GenericLabeling algorithm subsequently.

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 the routing style for edges.
The routing style has no effect on non-series-parallel edges. Their routing style can be determined by configuring the nonSeriesParallelEdgeRouter.
conversionfinal

Property Value

The routing style for the edges

Default Value

See Also

Developer's Guide
Gets or sets whether or not to take the coordinates of the input diagram into account when arranging the nodes.
The order of edges incident to the same source node will remain the same as in the original layout.
A previously specified childOrder will be ignored if From Sketch mode is enabled.
final

Property Value

true if input coordinates are considered, false otherwise

Default Value

The default value is: false
The initial coordinates of the nodes are not considered.

See Also

Developer's Guide
Gets or sets the layoutOrientation of this layout algorithm.
conversionfinal

See Also

Developer's Guide
Gets or sets the minimum distance between edges.
This distance needs to be non-negative.
final

Property Value

the minimum distance between edges

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is smaller than 0

Default Value

The default value is: 5

Sample Graphs

ShownSetting: 5

See Also

Developer's Guide
Gets or sets the minimum distance between nodes.
This distance needs to be non-negative.
final

Property Value

the minimum distance between nodes

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is smaller than 0

Default Value

The default value is: 10

Sample Graphs

ShownSetting: 10

See Also

Developer's Guide
Gets or sets the minimum distance between nodes and edges.
This distance needs to be non-negative.
final

Property Value

the minimum distance between nodes and edges

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is smaller than 0

Default Value

The default value is: 10

Sample Graphs

ShownSetting: 10

See Also

Developer's Guide
Gets or sets the minimum vertical distance of the edge segments that are not orthogonal.
The distance needs to be non-negative.
This distance will only be considered when the routing style is POLYLINE.
final

Property Value

the minimum vertical distance

Throws

Exception ({ name: 'ArgumentError' })
if the specified length is smaller than 0

Default Value

The default value is: 30

Sample Graphs

ShownSetting: 30

See Also

Developer's Guide
API
minimumSlope, edgeRoutingStyle, POLYLINE
Gets or sets the minimum slope which a non-orthogonal edge segment should have.
A higher minimum slope prevents those segments in very wide graphs from becoming nearly horizontal. The slope needs to have a non-negative value.
This distance will only be considered when the routing style is POLYLINE.
final

Property Value

the minimum slope for a non-orthogonal segment

Throws

Exception ({ name: 'ArgumentError' })
if the specified slope is smaller than 0

Default Value

The default value is: 0.25

Sample Graphs

ShownSetting: 0.25

See Also

Developer's Guide
API
minimumPolylineSegmentLength, edgeRoutingStyle, POLYLINE
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 the GenericLabeling algorithm subsequently.

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 labeling algorithm that is applied to all edge labels that belong to non-series-parallel edges.
The communication between the SeriesParallelLayout and the specified labeling algorithm is automatically established via the key PLACE_EDGE_LABELS_DATA_KEY.
final

Property Value

the labeling algorithm used for edge labels of non-series-parallel edges

Default Value

The default value is: GenericLabeling
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.
final

Property Value

the edge routing algorithm applied to the non-series-parallel edges

Throws

Exception ({ name: 'ArgumentError' })
if null is specified

Default Value

The default value is: EdgeRouter

See Also

Developer's Guide
Gets the ParallelEdgeRouter 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 or sets the alignment of parallel subgraphs.
The alignment is defined by a ratio:
  • 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
In grouped graphs, the alignment only applies to parallel subgraphs that belong to the same group.
Values outside interval [0,1] will be matched with the nearest interval end.
final

Property Value

the alignment ratio from interval [0,1]

Default Value

The default value is: 0.5
Subgraphs are center aligned.

Sample Graphs

ShownSetting: Top alignment (0)

See Also

Developer's Guide
Gets or sets the preferred length for non-orthogonal segments in octilinear edge routes.
If there is not enough space, those segments may be shorter than the specified length. The length needs to be non-negative.
This segment length will only be considered when the routing style is OCTILINEAR.
final

Property Value

the preferred length for non-orthogonal segments in octilinear edge routes

Throws

Exception ({ name: 'ArgumentError' })
if the specified length is smaller than 0

Default Value

The default value is: 10

Sample Graphs

ShownSetting: 10

See Also

Developer's Guide
API
edgeRoutingStyle, OCTILINEAR
Gets the SelfLoopRouter 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

Methods

Calculates a series-parallel layout of the graph.
In contrast to applyLayoutCore, graph and layout algorithm are prepared for an independent layout run.
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
Calculates a series-parallel layout for the given graph.
protectedfinal

Parameters

graph: LayoutGraph
the input graph

Throws

Exception ({ name: 'ArgumentError' })
if the graph is not series-parallel
Returns an instance of LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> that can be used to perform item-specific configurations for the SeriesParallelLayout.
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

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.
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

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

Developer's Guide

Constants

All constants are filtered. Go to Filters.

Static Methods

Determines whether or not the given graph has a series-parallel structure.
The current implementation detects the series-parallel graph structure in linear time.
static

Parameters

graph: LayoutGraph
the input graph

Return Value

boolean
true if the given graph is series-parallel, false otherwise

See Also

Developer's Guide