C

ParallelEdgeRouter

ParallelEdgeRouter is an ILayoutStage that routes multi-edges, which connect the same pair of nodes, in a parallel fashion.

Remarks

Layout Style

The edge paths of multi-edges consist of parallel segments. At the end points, the edges can either still be parallel or joined in one point.

The leading edge determining the routing is highlighted.

Concept

ParallelEdgeRouter performs four basic steps:

  1. For each set of multi-edges between the same endpoints, the algorithm removes all edges but one from the input graph (the remaining edge is called the leading edge).
  2. Invoke the coreLayout on the graph without multi-edges.
  3. Reinsert all previously removed multi-edges.
  4. Route the multi-edges such that their path is parallel to that of the associated leading edge.

Features

ParallelEdgeRouter can either be used as a ILayoutStage wrapping an ILayoutAlgorithm which cannot handle multi-edges. Then it will hide the multi-edges from this coreLayout and take over the routing of them.

If no coreLayout is specified, ParallelEdgeRouter can work alone. It will route only the multi-edges and keep the remaining graph unchanged. Note that, since the multi-edges' paths are parallel to the path of the associated leading edge, the leading edge should always have a suitable route before calling the ParallelEdgeRouter.

The edges this stage routed can be obtained from routedMultiEdgesResult. Multi-edges that were hidden during the core layout and then routed by this stage are marked. Leading edges are not marked. This may be convenient if multi-edges require further consideration, e.g., to place labels their labels (the core layout could not do that because they were hidden).

Multi-edges can either be all edges between the same two nodes, ignoring the direction, or edges are only considered to be multi-edges if they share the same source node and target node. Hence, they share the same direction.

To make sure that the ports of all multi-edges are on the end nodes, the first and last segments can be joined. However, these segments won't be parallel.

There are two ways to define the distance between two parallel edges. First, an absolute distance can be defined. Parallel segments will keep this distance. Second, the distance can be determined relative to the node bounds. Depending on the size of the nodes and the number of parallel edges between them, the distance between parallel edges is adjusted. This will keep the edges straight in most cases.

It is possible to select custom leading edges. All edges that are multi-edges of the selected edges will be temporarily removed.

Default Values of Properties

NameDefaultDescription
adaptiveEdgeDistancestrue
The distances between multi-edges are adjusted to the nodes' bounds.
adjustLeadingEdgetrue
The leading edge is adjusted for more symmetric results.
coreLayoutnull
directedModefalse
All edges that connect the same pair of nodes are considered parallel, ignoring their directions.
edgeDistance10
joinEndsfalse
Multi-edges have only parallel segments.

See Also

Developer's Guide

Members

Show:

Constructors

Creates a new ParallelEdgeRouter instance with an optional coreLayout.

Parameters

coreLayout?: ILayoutAlgorithm
The core layout algorithm.

See Also

API
coreLayout

Properties

Gets or sets the absolute distance from the end point of the joined lines to the first parallel segments.

The absolute distance needs to be non-negative.

The distance from the end point to the first parallel segment in the resulting layout is the sum of this absolute distance and the length of the first segment multiplied by the relativeJoinEndDistanceFactor.

This distance is only considered if parallel edge paths are joined, that is, property joinEnds is enabled.
final

Property Value

the absolute distance from the end point to the first/last bend of multi-edges

Throws

Exception ({ name: 'ArgumentError' })
if the specified distance is negative

Default Value

The default value is: 20

Sample Graphs

ShownSetting: 20

See Also

API
joinEnds, relativeJoinEndDistanceFactor
Gets or sets whether or not the distances between parallel multi-edges should be determined automatically according to the sizes of their source and target nodes.
If enabled, the distances between edges are chosen such that all multi-edges can be drawn as straight lines and still connect to the nodes' bounds.
final

Property Value

true if the distances are determined according to the nodes' bounds, false otherwise

Default Value

The default value is: true
The distances between multi-edges are adjusted to the nodes' bounds.

Sample Graphs

ShownSetting: false

See Also

API
edgeDistance
Gets or sets whether or not to adjust the leading edge to obtain more symmetric results.
Enabling this property may change the original ports of the leading edge.
final

Property Value

true if the leading edge is adjusted, false otherwise

Default Value

The default value is: true
The leading edge is adjusted for more symmetric results.

Sample Graphs

ShownSetting: false
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
final

Property Value

the core layout routine

Default Value

The default value is: null
Gets or sets whether or not the direction of edges should be considered.

In directed mode, only edges that share the same source and target node will be routed in parallel. Edges that connect to the same nodes but in different directions won't be considered parallel.

In undirected mode, all edges connecting the same pair of nodes will be routed in parallel.

final

Property Value

true if the direction of multi-edges must be the same, false otherwise

Default Value

The default value is: false
All edges that connect the same pair of nodes are considered parallel, ignoring their directions.

Sample Graphs

ShownSetting: false
Gets or sets the distance between two adjacent edge paths that run in parallel.
The distance needs to be non-negative.
If adaptiveEdgeDistances are used, the resulting distance may be less than the specified distance.
final

Property Value

the distance between two parallel multi-edges

Throws

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

Default Value

The default value is: 10

Sample Graphs

ShownSetting: 10

See Also

API
adaptiveEdgeDistances
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.

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.

final
Gets or sets whether or not to join end points of multi-edges.
If enabled, all edges end with non-parallel segments that connect at the same point to the node. Otherwise, all segments of the edges are parallel. In this case, some edges may not connect to the nodes' bounds.
final

Property Value

true if edges are joined at the ends, false otherwise

Default Value

The default value is: false
Multi-edges have only parallel segments.

Sample Graphs

ShownSetting: false

See Also

API
absoluteJoinEndDistance, relativeJoinEndDistanceFactor
Gets or sets a relative factor which controls the distance from the end point of the joined lines to the first parallel segments.

The length is relative to the corresponding original segment's length. It needs to have a value in the interval [0,1].

The distance from the end point to the first parallel segment in the resulting layout is the sum of the absoluteJoinEndDistance and the length of the first segment multiplied by this relative distance factor.

This distance is only considered if parallel edge paths are joined, that is, property joinEnds is enabled.
final

Property Value

the relative distance from the end point to the first/last bend of multi-edges

Throws

Exception ({ name: 'ArgumentError' })
if the specified relative distance is less than 0 or greater than 1

Default Value

The default value is: 0.0
No additional relative distance is added to absoluteJoinEndDistance

Sample Graphs

ShownSetting: 0.1

See Also

API
joinEnds, absoluteJoinEndDistance

Methods

Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
This implementation checks the enabled state and when it's not enabled, will delegate to the coreLayout, directly. When the stage is enabled, all the work will be delegated to applyLayoutImpl, instead.
final

Parameters

graph: LayoutGraph
The graph to apply the layout to.
Delegates the arrangement of nodes and edges to the coreLayout and routes the multi-edges.
protected

Parameters

graph: LayoutGraph
the input graph
Routes all the multi-edges.

The layout for each multi-edge follows the layout of the leading edge which was not removed from the coreLayout.

This method is called when the coreLayout is finished. It may be overridden to introduce a custom routing for multi-edges.

protected

Parameters

graph: LayoutGraph
the graph after the core layout
parallelEdges: IMapper<LayoutEdge, YList<LayoutEdge>>
the IMapper<K, V> that provides all multi-edges for each leading edge, or null if there are none

See Also

API
joinEnds, adaptiveEdgeDistances, adjustLeadingEdge

Constants

All constants are filtered. Go to Filters.

Static Methods

All static methods are filtered. Go to Filters.