ParallelEdgeRouter is a ILayoutStage that routes parallel edges which connect the same pair of nodes in a graph.
Remarks
Layout Style
The edge paths of parallel 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 parallel edges between the same endpoints, the algorithm removes all edges but one from the input graph (the remaining edge is called the leading or master edge)
- Invoke the core layout algorithm on the graph without parallel edges
- Reinsert all previously removed parallel edges
- Route the parallel edges such that their path is parallel to that of the associated master edge.
Features
ParallelEdgeRouter can either be used as a ILayoutStage wrapping a layout algorithm which cannot handle parallel edges. Then it will hide the parallel edges from this core layout algorithm and take over the routing of them.
If no core layout algorithm is specified, ParallelEdgeRouter can work alone. It will route only the parallel edges and keep the remaining graph unchanged. Note that, since the parallel edges' paths are parallel to the path of the associated master edge, the master edge should always have a suitable route before calling the ParallelEdgeRouter.
To find out which edges this stage routed, a IDataAcceptor can be registered with the graph with key ROUTED_PARALLEL_EDGES_DP_KEY. Parallel 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 parallel edges require further consideration, e.g., to place labels their labels (the core layout could not do that because they were hidden).
Parallel edges can either be all edges between the same two nodes, ignoring the direction, or edges are only considered parallel if they share the same source node and target node. Hence, they share the same direction.
To make sure that the ports of all parallel 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 master edges. All edges that are parallel to the selected edges will be temporarily removed.
Default Values of Properties
adaptiveLineDistances | true | The distances between parallel 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. |
joinEnds | false | Parallel edges have only parallel segments. |
lineDistance | 10 |
Type Details
- yfiles module
- layout-core
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.router.ParallelEdgeRouter
See Also
Constructors
Creates a new ParallelEdgeRouter instance with an optional core layout algorithm.
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.
- adaptiveLineDistances - boolean
Whether or not the distances between parallel edges should be determined automatically according to the sizes of their source and target nodes. This option sets the adaptiveLineDistances property on the created object.
- lineDistance - number
The distance between two adjacent edge paths that run in parallel. This option sets the lineDistance property on the created object.
- joinEnds - boolean
Whether or not to join end points of parallel edges. This option sets the joinEnds property on the created object.
- absJoinEndDistance - number
The absolute distance from the end point of the joined lines to the first parallel segments. This option sets the absJoinEndDistance property on the created object.
- relJoinEndDistance - number
The relative distance from the end point of the joined lines to the first parallel segments. This option sets the relJoinEndDistance 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.
See Also
Properties
Gets or sets the absolute distance from the end point of the joined lines to the first parallel segments.
Gets or sets whether or not the distances between parallel edges should be determined automatically according to the sizes of their source and target nodes.
Remarks
Default Value
true
.The distances between parallel edges are adjusted to the nodes' bounds.
See Also
Sample Graphs
Gets or sets the core layout algorithm that is wrapped by this stage.
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.
Sample Graphs
Gets or sets whether or not to join end points of parallel edges.
Remarks
Default Value
false
.Parallel edges have only parallel segments.
See Also
Sample Graphs
Gets or sets the distance between two adjacent edge paths that run in parallel.
Remarks
Default Value
10
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified distance is less than
0
See Also
Sample Graphs
Gets or sets the relative distance from the end point of the joined lines to the first parallel segments.
Remarks
[0,1]
.Default Value
0.1
.Throws
- Exception({ name: 'ArgumentError' })
- if the specified relative distance is less than
0
or greater than1
See Also
Sample Graphs
Methods
Delegates the arrangement of nodes and edges to the core layout algorithm and routes the parallel edges.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Invokes the layout process of the core layout algorithm.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Defined in
Hides all parallel edges leaving a master edge in the graph.
Remarks
ParallelEdgeRouter detects parallel edges of the given graph. From each set of parallel edges it hides all but one edge from the given graph.
This method is called before invoking the core layout algorithm. It may be overridden to change the selection of leading edges. Hidden edges should be stored in hiddenEdges to enable un-hiding later on.
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
See Also
Assigns a layout to all parallel edges.
Remarks
The layout for each parallel edge follows the layout of the master edge which was not removed from the core layout algorithm.
This method is called when the core layout algorithm is finished. It may be overridden to introduce a custom routing for parallel edges.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph after the core layout
- parallelEdges - IEdgeMap
- the map that provides all parallel edges for each master edge
Domain Edge Values EdgeList a list of edges being parallel to the edge or null
if there are none
See Also
Fields
IEdgeMap that associates a hidden edge with the unique parallel edge not hidden from the core layout algorithm.
Constants
A data provider key for marking edges that will be routed.
Domain | Edge | |
Values | boolean | true if the edge should be routed, false otherwise |
A data provider key for specifying the master edges.
Remarks
Marked edges won't be removed for the core layout algorithm. All edges parallel to the master edges will get parallel paths.
If no leading edge is specified for a bundle of parallel edges, it will be determined automatically. If there is more than one leading edge, the first one is chosen.
Domain | Edge | |
Values | boolean | true for the leading edges, false or null for the parallel edges |
A data acceptor key for publishing the parallel edges that were routed and not treated as leading edges.
Remarks
In the IDataAcceptor registered with the graph with this key all parallel edges which are no leading (master) edges are marked. This way, it is easily possible to determine the set of edges that were hidden during the core layout.
Knowing which parallel 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 parallel edges are hidden. A generic labeling algorithm where only the labels of the parallel edges are affected and placed can now easily be applied (see affectedLabelsDpKey.
Domain | Edge | |
Values | boolean | true if the edge is a parallel edge that was hidden during the core layout, false if the edge is no parallel edge or a leading parallel edge that was visible for the core layout |