This edge routing algorithm applies orthogonal, octilinear or curved routes to the edges of the graph while not changing node positions.
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 performs three main steps to achieve the edge routing and an additional fourth step for edges with the octilinear or curved routing style.
- Creating an IRouterPartition which divides the area of the graph area into several PartitionCells.
- Finding the shortest/cheapest paths for all edges through the IRouterPartition using sophisticated path search algorithm.
- Assigning coordinates to the segments of the edges based on the paths that were calculated before.
- 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. PartitionExtensions are able to influence how the IRouterPartition is created. They add PartitionCells and/or mark them for adding costs later in the process. To add custom extension implementations, use method addPartitionExtension.
For example, the extension 'Node Partition' adds a PartitionCell to the IRouterPartition for each node and marks it as belonging to a node. During the path search phase, the extension 'Node Crossing' recognizes these PartitionCells and adds costs that penalize crossing a node. The edge will be routed around the nodes.
PathSearchExtensions influence the path search by adding costs for traversing PartitionCells or narrowing their intervals to allow a less expensive traversal of a PartitionCell. Custom extension implementations can be added via addPathSearchExtension.
Using edge descriptors, it is possible to add individual layout settings like routing styles to edges by using the layout data property edgeDescriptors. If no descriptor is provided for an edge, the defaultEdgeDescriptor is used as fallback value.
Features
The routing algorithm supports EdgePortCandidates and NodePortCandidates to connect edges on a specific side or even on an exact location to a node. If an edge with registered EdgePortCandidates connects to nodes with NodePortCandidates, 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 port candidate specified for the edge is preferred.
Fixed LayoutPortCandidates 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 LayoutPortCandidates 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 LayoutPortCandidate.
A LayoutGrid 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 position, position, width and height are correctly specified.
Edges can be grouped so that they share common segments at the beginning or end of their routes. Edge groups are specified with the same ID object via properties sourceGroupIds for source groups and targetGroupIds 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 sourcePortGroupIds for source port groups and targetPortGroupIds for target port groups of the sub-data ports. 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 buses). 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.
Performance
Specifying a stopDuration can reduce the time the EdgeRouter takes to produce a result. The acceleration is achieved by skipping optional optimization steps during the path search in general as well as e.g. during integrated edge labeling and when choosing a possible bus placement. It should be noted that the stopDuration is not a guarantee for the maximum time spent, as the algorithm still has to produce a valid result.
In general, the EdgeRouter tends to perform better when there is sufficient space for the edges to be routed. Consequently, it can take noticeably longer to calculate edge routes for large graphs with densely packed nodes.
Default Values of Properties
edgeLabelPlacement | GENERIC
| Edge labels placed by an an independent labeling algorithm. |
gridSpacing | 0 | No grid is considered. |
minimumNodeToEdgeDistance | 10 | |
nodeLabelPlacement | CONSIDER
| Node labels are considered. |
rerouting | false | The rerouting step will not be performed. |
stopDuration | MAX_VALUE
| The edge routing algorithm runs unrestricted. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new EdgeRouter instance with an optional coreLayout.
Parameters
A map of options to pass to the method.
- coreLayout - ILayoutAlgorithm
- The core layout algorithm.
- stopDuration - TimeSpan
- The time limit set for the edge routing algorithm. This option sets the stopDuration property on the created object.
- edgeLabelPlacement - EdgeRouterEdgeLabelPlacement
- How the layout handles the position of edge labels. This option sets the edgeLabelPlacement 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.
- nodeLabelPlacement - EdgeRouterNodeLabelPlacement
- How the layout handles the position of node labels. This option sets the nodeLabelPlacement property on the created object.
- gridSpacing - number
- The equidistant spacing between the horizontal and vertical grid lines, on which the routing algorithm places the orthogonal segments This option sets the gridSpacing property on the created object.
- minimumNodeToEdgeDistance - number
- The minimum distance between edges and node bounds. This option sets the minimumNodeToEdgeDistance property on the created object.
- genericLabeling - GenericLabeling
- A GenericLabeling helper class for this algorithm. This option either sets the value directly or recursively sets properties to the instance of the genericLabeling property on the created object.
- enabled - boolean
Properties
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Default Value
null
.Property Value
See Also
Implements
Gets the descriptor instance that defines settings for all those edges that do not have an assigned edge descriptor .
Property Value
See Also
Gets or sets how the layout handles the position of edge labels.
Remarks
INTEGRATED if the layout algorithm places the edge labels and accounts for their positions to avoid overlaps, IGNORE if the positions should be ignored, or CONSIDER_UNAFFECTED_EDGE_LABELS if only the positions of labels belonging to affected edges (see scope) should be considered. The edge label positions can also be adjusted by a configurable labeling algorithm in a generic post-processing step when this property is set to GENERIC.
With INTEGRATED edge labeling, the routes of edges with labels can change significantly. The algorithm finds a position for labels and routes the edge near the label trying to consider the EdgeLabelPreferredPlacement. To do so, the route itself maybe needs to take a detour that might otherwise not have been necessary. This especially holds true in case that there is very little space for the labels and/or the labels are rather large.
Default Value
See Also
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 a GenericLabeling helper class for this algorithm.
Remarks
Gets or sets the equidistant spacing between the horizontal and vertical grid lines, on which the routing algorithm places the orthogonal segments
Remarks
0
, no grid is considered.Default Value
0
.No grid is considered.
Property Value
See Also
Sample Graphs
Gets or sets the minimum distance between edges and node bounds.
Remarks
Default Value
10
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the minimum node-to-edge distance is negative
See Also
Sample Graphs
Gets or sets how the layout handles the position of node labels.
Default Value
Property Value
- CONSIDER if the layout algorithm takes the node labels into account
- IGNORE_GROUP_LABELS if the algorithm ignores labels that belong to group nodes and considers labels of other nodes the same way as for CONSIDER.
- IGNORE if the layout algorithm shouldn't take node labels into account
- GENERIC if the nodes should be placed in a post-processing step
See Also
Sample Graphs
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.
Property Value
true
if the rerouting step will be performed, false
otherwiseGets or sets the time limit set for the edge routing algorithm.
Remarks
The stop duration has to be greater than or equal to 0
.
Setting the duration to ZERO leads to the fastest possible routing mode while still observing important constraints. To put further emphasis on runtime while reducing quality, the edgeRouterCosts can be set to LOW_QUALITY.
Default Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given duration is negative
See Also
Methods
Adds a custom PartitionExtension instance to this router instance.
Remarks
Parameters
A map of options to pass to the method.
- extension - PartitionExtension
- A custom PartitionExtension instance that will be used during the partitioning phase.
See Also
Adds a custom PathSearchExtension instance to this router instance.
Remarks
Parameters
A map of options to pass to the method.
- extension - PathSearchExtension
- A custom PathSearchExtension instance that will be used by the path searching algorithm.
See Also
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
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
createLayoutData
(graph: LayoutGraph) : EdgeRouterData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the EdgeRouter.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪EdgeRouterData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given EdgeRouter.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to define the edges affected by the EdgeRouter.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪EdgeRouterData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given EdgeRouter.
LayoutExecutor
type is available at runtime.Returns the EdgeRouterEdgeDescriptor instance for a given edge that is defined via edgeDescriptors.
Remarks
Parameters
A map of options to pass to the method.
- edge - LayoutEdge
- the given edge
Returns
- ↪EdgeRouterEdgeDescriptor
- the current EdgeRouterEdgeDescriptor instance for a given edge
See Also
Constants
A data 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.
See Also
A data key for specifying individual edge layout information.
Remarks
Assign an EdgeRouterEdgeDescriptor to an edge to provide routing information for this edge, or null
if no descriptor should be mapped for a given edge.
If this IMapper<K,V> does not contain an EdgeRouterEdgeDescriptor for an edge, then the layout algorithm will use the default descriptor.
See Also
A data key for weighting the costs for crossing each edge label individually.
Remarks
Assign the cost factor to an edge label if this particular label has to be crossed.
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 cost arising when an edge must cross a edge label in order to determine the final costs arising when this label is crossed.
See Also
A data key for weighting the costs for crossing each node label individually.
Remarks
Assign the cost factor to a node label if this particular label has to be crossed.
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 cost arising when an edge must cross a node label in order to determine the final costs arising when this label is crossed.
See Also
A IMapper<K,V> key to look up the selection state of the edges.