This edge routing algorithm applies polyline routes to the edges of the graph.
Remarks
Layout Style
Edges are by default routed in an orthogonal fashion, i.e., they only consist of horizontal and vertical segments. There are two additional routing styles: the octilinear style where additional sloped segments are inserted between horizontal and vertical segments and the curved style that replaces the segments with smooth curves.
During the routing process, the positions of the nodes are considered to be fixed and the routing algorithm will not modify their locations or their sizes in any way.
The edge routing algorithm can be applied wherever it is needed to route the edges using orthogonal, octilinear or curved segments without crossing any nodes, while keeping the positions of the nodes in the diagram fixed. Some potential applications include electric circuit design, floor planning and navigation maps.
Concept
The edge routing algorithm basically performs three steps to achieve the main edge routing and an additional fourth step for edges with the octilinear or curved routing style.
- Creating a IPartition which divides the area of the graph area into several PartitionCells.
- Finding the shortest/cheapest paths for all edges through the IPartition using PathSearch.
- Assigning coordinates to the segments of the edges based on the paths that were calculated before with ChannelBasedPathRouting.
- Inserting non-orthogonal segments where horizontal and vertical segments meet for edges with routing style OCTILINEAR or inserting curved segments for edges with routing style CURVED.
The first two steps are customizable. IGraphPartitionExtensions are able to influence how the IPartition is created. They add PartitionCells and/or mark them for adding costs later in the process. The currently used partition extensions can be dropped or extended by custom implementations.
For example, the extension 'Node Partition' adds a PartitionCell to the IPartition for each node and marks it as belonging to a node. During PathSearch, the extension 'Node Crossing' recognizes these PartitionCells and adds costs that penalizes crossing a node. The edge will be routed around the nodes.
PathSearchExtensions influence the PathSearch by adding costs for traversing PartitionCells or narrowing their intervals to allow a less expensive traversal of a PartitionCell. The currently used partition extensions can be dropped or extended by custom implementations.
Using EdgeRouterEdgeLayoutDescriptors, it is possible to add individual layout settings like routing styles to edges. They are registered with the graph with key EDGE_LAYOUT_DESCRIPTOR_DP_KEY. If no descriptor is provided for an edge, a default edge layout descriptor is used as fallback value.
Features
The routing algorithm supports two approaches to connect edges on a specific side or even on an exact location to a node. PortConstraints define a single constraint for the ports of an edge. To realize more complex port restrictions, several PortCandidates or PortCandidateSets can be assigned to edges or nodes. If an edge with registered PortCandidates connects to nodes with PortCandidateSets, the edge router will try to match both collections in order to find an appropriate port. In case there is no matching port candidate, a PortCandidate specified for the edge is preferred. Note that the routing algorithm doesn't consider custom IPortCandidateMatcher implementations. Since their simultaneous existence at the same node may be ambiguous, it is not recommended to use a combination of PortConstraints and PortCandidates in the same diagram.
Strong PortConstraints or fixed PortCandidates defined for an edge end at a group node where the strong/fixed port location is inside the group node are supported with the following characteristics. First of all, if there are multiple PortCandidates and one is not inside the group but, e.g., on its border, then such a candidate is always preferred over an inner one. When an inner constraint is considered, then the algorithm actually generates a proper route from the group's border to the port location. Obstacles on the way are considered like for any other route. The group node is also entered at the side which is defined by the PortConstraint or PortCandidate.
A PartitionGrid is respected in the way that the algorithm avoids that cell boundaries are left and re-entered. This way, edge routes stay inside a cell if both source and target are in the same cell. For this feature to work properly it is required that the values of the properties originalPosition, originalPosition originalWidth and originalHeight are correctly specified. This is usually automatically the case when executing the EdgeRouter as a standalone algorithm via layout execution convenience methods (e.g. the values are taken from the table visualization of the grid). However, if the router is applied as part of a more complex layout pipeline it might be necessary to specify the values manually. For example, if another algorithm previously computed the grid position values and stored them in the respective 'computed' properties (e.g. computedPosition), and afterwards EdgeRouter should be applied, then the 'computed' values of the first algorithm should be written to the 'original' values prior to the run of the EdgeRouter.
Edges can be grouped so that they share common segments at the beginning or end of their routes. Edge groups are specified using IDataProviders that provide the same ID object for all edges in the same group. Those IDataProviders are registered with the graph with key SOURCE_GROUP_ID_DP_KEY for source groups or key TARGET_GROUP_ID_DP_KEY for target groups. Besides edge grouping, the EdgeRouter also supports port grouping where all edges with the same port id at a node will share the same port location but are still routed independently (i.e., do not share multiple segments as for edge groups). To specify port groups use a IDataProvider and register it to the graph with key SOURCE_PORT_GROUP_ID_DP_KEY for source port groups or key TARGET_PORT_GROUP_ID_DP_KEY for target port groups. Note that an edge can either be associated with a (source/target) group or a (source/target) port group id, but not both at the same time.
Edges can be routed in a bus-style. Edges that should share common bus segments must be mapped to the same EdgeRouterBusDescriptor (see also BUS_DESCRIPTOR_DP_KEY). The algorithm tries to route a large part of the edge using the common bus segments. These segments are automatically selected depending on the involved edges/nodes, but they might also be specified manually using busPoints. Edges that are fixed (i.e. are not marked for routing) may also belong to a bus. Then, the bus segments will be derived using the existing path of the fixed edges. This way, buses can be incrementally updated, e.g., when a new edge should be added to an existing bus structure. Bus routing can, e.g., be very useful in parts of a diagram where each node is connected to each other node.
Default Values of Properties
considerEdgeLabels | false | Edge labels of fixed edges are not considered. |
considerNodeLabels | false | Node labels are not considered. |
ignoreInnerNodeLabels | true | Node labels that are inside the bounds of their owner are ignored. |
integratedEdgeLabeling | false | Integrated edge labeling is disabled. |
maximumDuration | <code>0x7FFFFFFF</code> | The edge routing algorithm runs unrestricted. |
minimumNodeToEdgeDistance | 10 | |
rerouting | false | The rerouting step will not be performed. |
scope | ROUTE_ALL_EDGES
|
Type Details
- yfiles module
- router-polyline
- yfiles-umd modules
- layout-area, layout-multipage, layout-orthogonal-compact, layout, router-bus, router-polyline
- Legacy UMD name
- yfiles.router.EdgeRouter
See Also
Constructors
Creates a new EdgeRouter instance with an optional core layout algorithm.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- maximumDuration - number
The time limit (in milliseconds) set for the edge routing algorithm. This option sets the maximumDuration property on the created object.
- integratedEdgeLabeling - boolean
Whether or not the layout algorithm will place edge labels. This option sets the integratedEdgeLabeling property on the created object.
- polylineRouting - boolean
Whether or not the routing algorithm will route the edges with non-orthogonal, octilinear segments. This option sets the polylineRouting property on the created object.
- preferredPolylineSegmentLength - number
The preferred length of (non-orthogonal) octilinear segments. This option sets the preferredPolylineSegmentLength property on the created object.
- maximumPolylineSegmentRatio - number
The maximum ratio between the horizontal/vertical part of a segment and the (non-orthogonal) octilinear part. This option sets the maximumPolylineSegmentRatio property on the created object.
- rerouting - boolean
Whether or not the routing algorithm uses an additional step to reroute the edges that are considered to have the worst paths. This option sets the rerouting property on the created object.
- scope - EdgeRouterScope
A (sub-)set of edges that shall be routed. This option sets the scope property on the created object.
- affectedNodesDpKey - Object
The IDataProvider key to look up the selection state of the nodes. This option sets the affectedNodesDpKey property on the created object.
- affectedEdgesDpKey - Object
The IDataProvider key to look up the selection state of the edges. This option sets the affectedEdgesDpKey property on the created object.
- edgeComparer - IComparer<Object>
A custom IComparer<T> to define the processing order of the edges. This option sets the edgeComparer property on the created object.
- considerNodeLabels - boolean
Whether or not the routing algorithm considers the labels of the nodes as obstacles when calculating the edge routes to avoid overlaps. This option sets the considerNodeLabels property on the created object.
- ignoreInnerNodeLabels - boolean
Whether or not this routing algorithm ignores node labels that are inside the bounds of their owner as obstacles for edge routes. This option sets the ignoreInnerNodeLabels property on the created object.
- considerEdgeLabels - boolean
Whether or not the routing algorithm considers as obstacles the edge labels that do not belong to the (sub-)set of edges to be routed when calculating the edge routes. This option sets the considerEdgeLabels property on the created object.
- grid - Grid
- minimumNodeToEdgeDistance - number
The minimum distance between edges and node bounds. This option sets the minimumNodeToEdgeDistance property on the created object.
Properties
Gets or sets the IDataProvider key to look up the selection state of the edges.
Remarks
Default Value
AFFECTED_EDGES_DP_KEY.Throws
- Exception({ name: 'ArgumentError' })
- if the specified
key is null
See Also
Gets or sets the IDataProvider key to look up the selection state of the nodes.
Remarks
Default Value
AFFECTED_NODES_DP_KEY.Throws
- Exception({ name: 'ArgumentError' })
- if the specified
key is null
See Also
Gets or sets whether or not the routing algorithm considers as obstacles the edge labels that do not belong to the (sub-)set of edges to be routed when calculating the edge routes.
Default Value
false
.Edge labels of fixed edges are not considered.
See Also
Sample Graphs
Gets or sets whether or not the routing algorithm considers the labels of the nodes as obstacles when calculating the edge routes to avoid overlaps.
Default Value
false
.Node labels are not considered.
See Also
Sample Graphs
Gets or sets the core layout algorithm that is wrapped by this stage.
Gets the EdgeRouterEdgeLayoutDescriptor instance used for all those edges that do not have a specific edge layout descriptor assigned.
Gets or sets a custom IComparer<T> to define the processing order of the edges.
Default Value
null
.There is no custom instance set and the default implementation will be applied.
See Also
null
, the IComparer<T> instance created with createDefaultEdgeOrderComparer is applied.Gets or sets the Grid instance on which the routing algorithm places the orthogonal segments.
Gets or sets whether or not this routing algorithm ignores node labels that are inside the bounds of their owner as obstacles for edge routes.
Default Value
true
.Node labels that are inside the bounds of their owner are ignored.
See Also
Sample Graphs
Gets or sets whether or not the layout algorithm will place edge labels.
Remarks
Default Value
false
.Integrated edge labeling is disabled.
See Also
Gets or sets the time limit (in milliseconds) set for the edge routing algorithm.
Remarks
0
.Default Value
<code>0x7FFFFFFF</code>
.The edge routing algorithm runs unrestricted.
Throws
- Exception({ name: 'ArgumentError' })
- if the maximum duration is negative
Gets or sets the maximum ratio between the horizontal/vertical part of a segment and the (non-orthogonal) octilinear part.
Remarks
This property is deprecated and replaced by maximumOctilinearSegmentRatio. As the property is on the descriptor, it additionally allows to define the maximum segment ratio each edge individually.
This property only affects edges using the default layout descriptor and using routing style OCTILINEAR. Changing the value of this property changes property maximumOctilinearSegmentRatio of the default edge layout descriptor instance.
Default Value
0.3
.Throws
- Exception({ name: 'ArgumentError' })
- if the maximum segment length is negative or greater than
0.5
Sample Graphs
Deprecation warning
Use the respective maximum segment ratio property on the edge layout descriptor instead. See the documentation for details.Gets or sets the minimum distance between edges and node bounds.
Remarks
Default Value
10
.Throws
- Exception({ name: 'ArgumentError' })
- if the minimum node-to-edge distance is negative
See Also
Sample Graphs
Gets the GraphPartition instance used during the routing process.
null
will be returned.Gets or sets whether or not the routing algorithm will route the edges with non-orthogonal, octilinear segments.
Remarks
This property is deprecated! It is replaced by property routingStyle on the edge layout descriptor. Use the routing styles ORTHOGONAL and OCTILINEAR to switch between octilinear and orthogonal routing. With the descriptor, the style can be specified for each edge individually, if desired.
This property only affects edges using the default layout descriptor. Changing this property value changes property routingStyle of the default edge layout descriptor instance.
Default Value
false
.The octilinear edge routing is disabled and edges are routed orthogonal.
See Also
Sample Graphs
Deprecation warning
Use the routing style property on the edge layout descriptor instead. See the documentation for details.Gets or sets the preferred length of (non-orthogonal) octilinear segments.
Remarks
This property is deprecated and replaced by preferredOctilinearSegmentLength. As the property is on the descriptor, it additionally allows to define the preferred length for each edge individually.
This property only affects edges using the default layout descriptor and using routing style OCTILINEAR. Changing the value of this property changes property preferredOctilinearSegmentLength of the default edge layout descriptor instance.
Default Value
30
.Throws
- Exception({ name: 'ArgumentError' })
- if the preferred octilinear segment length is negative
See Also
Sample Graphs
Deprecation warning
Use the respective preferred length property on the edge layout descriptor instead. See the documentation for details.Gets a list of all registered IGraphPartitionExtensions.
Remarks
IGraphPartitionExtensions can be added to a GraphPartition in order to create new Obstacles or can be removed from a GraphPartition instance.
By default, the following IGraphPartitionExtensions are registered with a given GraphPartition instance:
- Minimum Node To Edge Distance Partition
- Node Partition
- Partition Grid Partition
- Node Label Partition
- Edge Label Partition
- Fixed Edges Partition
- External Strong Port Restriction Partition
See Also
Gets a list of all registered PathSearchExtensions.
Remarks
PathSearchExtensions can be added to a PathSearch instance in order to influence the path searching process or can be removed from a PathSearch instance.
By default, the following PathSearchExtensions are registered with a PathSearch instance:
- Fixed Grouped Edges
- Node Crossing
- Minimum Node To Edge Distance
- Group Node Crossing
- Minimum Group Node To Edge Distance
- Node Label Crossing
- Edge Label Crossing
- Bends In Node To Edge Distance
- Bend
- Monotonic Route
- Edge Length
- Partition Grid
- Port Restriction
- Edge Grouping
- Minimum Node Corner Distance
- Interval Based Crossing
- Minimum Edge To Edge Distance And Grid
- Minimum First Last Segment Length
- Intersecting Source And Target
See Also
Gets or sets whether or not the routing algorithm uses an additional step to reroute the edges that are considered to have the worst paths.
Default Value
false
.The rerouting step will not be performed.
Gets or sets a (sub-)set of edges that shall be routed.
Remarks
Default Value
ROUTE_ALL_EDGES.Throws
- Exception({ name: 'ArgumentError' })
- if the given scope is unknown
See Also
Methods
Performs the routing of the edges of the input graph.
Remarks
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
Checks the sizes of the nodes to be non-zero.
Removes all registered IGraphPartitionExtensions from a given GraphPartition instance.
Remarks
Parameters
A map of options to pass to the method.
- partition - GraphPartition
- the given GraphPartition instance
See Also
Adds all registered IGraphPartitionExtensions instances to a given GraphPartition instance.
Remarks
Parameters
A map of options to pass to the method.
- partition - GraphPartition
- the given GraphPartition instance
See Also
Adds all registered PathSearchExtensions to a given PathSearch instance.
Remarks
Parameters
A map of options to pass to the method.
- pathSearch - PathSearch
- a PathSearch instance
See Also
Creates a PathSearchConfiguration that is used during the path searching process.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- grouping - LayoutGroupingSupport
- the grouping structure of the graph
Returns
- ↪PathSearchConfiguration
- a PathSearchConfiguration instance
createDefaultEdgeOrderComparer
(graph: LayoutGraph, configuration: PathSearchConfiguration) : IComparer<any>Creates a default IComparer<T> instance to determine the order of the edges according to which they will be routed.
Remarks
This method is called by applyLayout before the edge routes are calculated. It may be overridden in order to create a new IComparer<T> object with a custom configuration.
By default, this method returns an instance of the default implementation.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
- configuration - PathSearchConfiguration
- the given configuration for the path searching process
Returns
- ↪IComparer<any>
- a IComparer<T> instance
Creates a GraphPartition instance that divides the area of the graph into several rectangles.
Remarks
This implementation creates a GraphPartition using the current IObstaclePartition instance.
This method is called by applyLayout before the edge routes are calculated. It may be overridden in order to create a new GraphPartition object with a custom configuration.
Parameters
A map of options to pass to the method.
- decomposition - IObstaclePartition
- the current IObstaclePartition
Returns
- ↪GraphPartition
- a GraphPartition instance
See Also
Creates a DynamicObstacleDecomposition that is used by the GraphPartition to divide the graph area in rectangles.
Remarks
Returns
See Also
Creates a ChannelBasedPathRouting instance that routes the edges using pre-calculated EdgeRouterPath objects.
Remarks
Returns
- ↪ChannelBasedPathRouting
- a ChannelBasedPathRouting instance
Creates a PathSearch instance that finds the paths of the edges through the GraphPartition.
Remarks
Returns
- ↪PathSearch
- a PathSearch instance
See Also
createPathSearchContext
(pathSearch: PathSearch, configuration: PathSearchConfiguration) : PathSearchContextCreates a PathSearchContext that provides context information for the path searching algorithm.
Remarks
Parameters
A map of options to pass to the method.
- pathSearch - PathSearch
- a given PathSearch instance
- configuration - PathSearchConfiguration
- a given configuration for the path searching process
Returns
- ↪PathSearchContext
- a PathSearchContext instance
Returns the EdgeRouterEdgeLayoutDescriptor instance for a given edge that is provided by a IDataProvider which is registered with the graph with key EDGE_LAYOUT_DESCRIPTOR_DP_KEY.
Remarks
For all those edges that do not have a specific layout descriptor assigned, the default layout descriptor returned by defaultEdgeLayoutDescriptor will be assigned.
This method may be overridden in order to create an EdgeRouterEdgeLayoutDescriptor with custom configuration.
Parameters
A map of options to pass to the method.
- edge - Edge
- the given edge
Returns
- ↪EdgeRouterEdgeLayoutDescriptor
- the current EdgeRouterEdgeLayoutDescriptor instance for a given edge
See Also
Returns whether or not a given edge is selected.
Remarks
If all the edges of the graph will be routed by EdgeRouter, i.e., the scope is set to ROUTE_ALL_EDGES, this utility method returns true
for all edges.
This method may be overridden in order to determine differently whether or not a given edge is considered to be selected.
Parameters
A map of options to pass to the method.
Returns
- ↪boolean
true
if the given edge is selected,false
otherwise
Constants
A data provider key for specifying a bus descriptor for each edge.
Remarks
Edges can be assigned to a EdgeRouterBusDescriptor instance; all edges associated to the same descriptor are routed in a bus-like style. A bus is a segment shared by multiple edges to which shorter segments that connect to the actual nodes are attached. Observe that using such a bus representation with multiple edges drawn on top of each other, information like the individual edge direction might be occluded.
The mapped EdgeRouterBusDescriptor allows to configure the bus formed by the associated edges.
Domain | Edge | |
Values | EdgeRouterBusDescriptor | a bus descriptor that represents the bus the edge belongs to |
See Also
A data provider key for specifying individual edge layout information.
Remarks
Domain | Edge | |
Values | EdgeRouterEdgeLayoutDescriptor | an edge layout descriptor that provides routing information for an edge or null if no descriptor is mapped for a given edge |
See Also
A data provider key for weighting the costs for crossing each label individually.
Remarks
If the factor for a label is 0
then it is allowed to cross it. Very important labels should get a high factor.
This factor is multiplied by the basic penalty arising when an edge must cross a node label or an edge label in order to determine the final costs arising when this label is crossed.
Domain | ILabelLayout | the labels of the input graph |
Values | number | the cost factor for a label if this particular label has to be crossed |