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.
Concept
ParallelEdgeRouter performs four basic steps:
- 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).
- Invoke the coreLayout on the graph without multi-edges.
- Reinsert all previously removed multi-edges.
- 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
adaptiveEdgeDistances | true | The distances between multi-edges are adjusted to the nodes' bounds. |
adjustLeadingEdge | true | The leading edge is adjusted for more symmetric results. |
coreLayout | null | |
directedMode | false | All edges that connect the same pair of nodes are considered parallel, ignoring their directions. |
edgeDistance | 10 | |
joinEnds | false | Multi-edges have only parallel segments. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new ParallelEdgeRouter instance with an optional coreLayout.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- directedMode - boolean
- Whether or not the direction of edges should be considered. This option sets the directedMode property on the created object.
- adaptiveEdgeDistances - boolean
- Whether or not the distances between parallel multi-edges should be determined automatically according to the sizes of their source and target nodes. This option sets the adaptiveEdgeDistances property on the created object.
- edgeDistance - number
- The distance between two adjacent edge paths that run in parallel. This option sets the edgeDistance property on the created object.
- joinEnds - boolean
- Whether or not to join end points of multi-edges. This option sets the joinEnds property on the created object.
- absoluteJoinEndDistance - number
- The absolute distance from the end point of the joined lines to the first parallel segments. This option sets the absoluteJoinEndDistance property on the created object.
- relativeJoinEndDistanceFactor - number
- A relative factor which controls the distance from the end point of the joined lines to the first parallel segments. This option sets the relativeJoinEndDistanceFactor property on the created object.
- adjustLeadingEdge - boolean
- Whether or not to adjust the leading edge to obtain more symmetric results. This option sets the adjustLeadingEdge property on the created object.
- enabled - boolean
See Also
Properties
Gets or sets the absolute distance from the end point of the joined lines to the first parallel segments.
Remarks
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.
Default Value
20
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is negative
See Also
Sample Graphs
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.
Remarks
Default Value
true
.The distances between multi-edges are adjusted to the nodes' bounds.
Property Value
true
if the distances are determined according to the nodes' bounds, false
otherwiseSee Also
Sample Graphs
Gets or sets whether or not to adjust the leading edge to obtain more symmetric results.
Default Value
true
.The leading edge is adjusted for more symmetric results.
Property Value
true
if the leading edge is adjusted, false
otherwiseSample Graphs
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Default Value
null
.Property Value
See Also
Implements
Gets or sets whether or not the direction of edges should be considered.
Remarks
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.
Default Value
false
.All edges that connect the same pair of nodes are considered parallel, ignoring their directions.
Property Value
true
if the direction of multi-edges must be the same, false
otherwiseSample Graphs
Gets or sets the distance between two adjacent edge paths that run in parallel.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is less than
0
See Also
Sample Graphs
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.
See Also
Implements
Gets or sets whether or not to join end points of multi-edges.
Remarks
Default Value
false
.Multi-edges have only parallel segments.
Property Value
true
if edges are joined at the ends, false
otherwiseSee Also
Sample Graphs
Gets or sets a relative factor which controls the distance from the end point of the joined lines to the first parallel segments.
Remarks
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.
Default Value
0.0
.No additional relative distance is added to
Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified relative distance is less than
0
or greater than1
See Also
Sample Graphs
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.
See Also
Implements
Delegates the arrangement of nodes and edges to the coreLayout and routes the multi-edges.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Hides all multi-edges only leaving one leading edge per group of multi-edges.
Remarks
ParallelEdgeRouter detects multi-edges of the given graph. From each set of multi-edges it hides all but one edge from the given graph. The remaining edge is called the leading edge.
This method is called before invoking the coreLayout. It may be overridden to change the selection of the multi-edges. If so, use method hideMultiEdges to hide these edges.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
Returns
- ↪IMapper<LayoutEdge,YList<LayoutEdge>>
- A mapping from each leading edge to the list of multi-edges that it represents.
See Also
Hides and stores the given list of multi-edges.
Remarks
Parameters
A map of options to pass to the method.
- multiEdges - YList<LayoutEdge>
- the list of multi-edges to be hidden
- graph - LayoutGraph
- the input graph
Routes all the multi-edges.
Remarks
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.
Parameters
A map of options to pass to the method.
- 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
Constants
A data key for marking edges that will be routed.
Remarks
Assign true
to an edge if the edge should be routed, or false
otherwise.
If no IMapper<K,V> is registered with the given key, all edges will be routed.
See Also
A data key for specifying the leading edges.
Remarks
Assign true
to edges that are leading edges, or false
or null
that are multi-edges.
Marked edges won't be removed for the coreLayout. All multi-edges of the leading edges will get parallel paths.
If no leading edge is specified for a bundle of multi-edges, it will be determined automatically. If there is more than one leading edge, the first one is chosen.
See Also
A data key for publishing the multi-edges that were routed and not treated as leading edges.
Remarks
In the settable IMapper<K,V> registered with the graph with this key all multi-edges which are no leading edges are marked. This way, it is easily possible to determine the set of edges that were hidden during the coreLayout.
Knowing which multi-edges were identified and hidden during the core layout can be a valuable information for use cases where it is required to handle such edges specifically. A frequent scenario is, for example, the requirement to place edge labels of these edges. The core layout is not able to do so, because multi-edges are hidden. A generic labeling algorithm where only the labels of the multi-edges are affected and placed can now easily be applied (see PLACE_EDGE_LABELS_DATA_KEY.
See Also
Static Methods
routeEdgesParallel
(leadingEdge: LayoutEdge, edge: LayoutEdge, edgeDistance: number, joinEnds?: boolean, absJoinDistance?: number, relJoinDistance?: number)Routes two edges which are incident to the same nodes in parallel, optionally joining the end points.
Remarks
Parameters
A map of options to pass to the method.
- leadingEdge - LayoutEdge
- the leading edge
- edge - LayoutEdge
- the edge to be adjusted
- edgeDistance - number
- the distance between the two edges
- joinEnds - boolean
true
if the edges should share their end points (the ones of the leading edge),false
otherwise- absJoinDistance - number
- the absolute distance between the end points and the beginning of the parallel segment routing if the ends are joined
- relJoinDistance - number
- the relative distance, measured relative to the length of the first/last segments if the ends are joined