This class provides the costs that are applied for violating restrictions during the path search phase of the EdgeRouter.
Remarks
The path search calculates the shortest path from the source to the target, where shortest path means the path with the lowest costs. Costs result from violations of restrictions that are defined by the different PathSearchExtensions. This class defines costs for the various violations. The algorithm can be adapted to specific needs by varying these costs. In order to avoid a certain violation, the appropriate cost must be increased.
There are some predefined cost settings which set a different focus for the path search: BALANCED_OPTIMIZATION, EDGE_BENDS_OPTIMIZATION, EDGE_LENGTHS_OPTIMIZATION, EDGE_CROSSINGS_OPTIMIZATION, and LOW_QUALITY.
Default Values of Properties
Type Details
- yFiles module
- algorithms
Constructors
Creates a new instance of EdgeRouterCosts.
Properties
Gets or sets the cost for a crossing of two edges that are adjacent, that is, share a common node.
Remarks
This cost only induces costs for crossings between edges that have a common end point, i.e., where one of the source/target nodes is equal. Crossings between non-adjacent edges are weighted using edgeCrossingCost. By default, avoiding crossing between adjacent edges is much more important and it is favored to introduce bends. Crossings between unrelated edges are less expensive and a crossing is preferred over an additional bend.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
7
.Property Value
See Also
Gets or sets the cost for an edge bend.
Remarks
This cost will make routes with many bends more expensive than routes with few or no bends. Hence, edges will have preferably few bends.
Increasing bend cost will raise the importance of avoiding bends in relation to other costs while decreasing this cost will raise the importance of all other restrictions. A high bend cost will result in routes that will preferably cross other edges instead of bending to avoid other edges. When increasing the edge bend cost, the resulting routes will have more edge crossings.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
3
.Property Value
1
) can lead to squiggles when the algorithm tries to avoid more expensive restrictions.Gets or sets the cost for an edge bend being closer to the border of the source node, the target node, or one of their ancestor group nodes than the minimum node to edge distance.
Remarks
This cost will make routes that bend too close to their source or target node more expensive than routes that maintain the specified minimum node to edge distance.
Increasing the bends in node to edge distance cost will raise the importance of avoiding bends that violate the minimum node to edge distance, while decreasing this cost will raise the importance of all other restrictions. This cost supports minimumNodeToEdgeDistance. In case the path search finally reaches the target node, the minimum node to edge distance for this node must be violated. Penalizing bends that are too close to the node forces the edge to directly cross this distance and connect to the node.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
10
.Property Value
See Also
Gets or sets the cost for a crossing of two edges.
Remarks
This cost will make routes that cross many other edges more expensive than routes that cross few other edges or no edges at all. Hence, edges preferably won't cross other edges. Crossings between adjacent edges (edges having a common end node) are not covered by this cost - their cost is defined by adjacentEdgeCrossingCost and, by default, they are more expensive.
Increasing the edge crossing cost will raise the importance of avoiding edge crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions. When increasing the edge crossing cost, the resulting route will be longer and have more bends because crossing other edges needs to be avoided.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
1
.Property Value
See Also
Gets or sets the cost for an edge crossing an edge label.
Remarks
This cost will make routes that cross edge labels of fixed edges more expensive than routes that avoid crossing edge labels, so edges won't preferably cross any edge labels that belong to fixed edges.
Increasing the edge label crossing cost will raise the importance of avoiding edge labels crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions. A high label crossing cost will cause edges to bend more often to avoid passing straight through labels.
The crossing cost can be weighted for each label individually using the edgeLabelCrossingCostFactors.
Use edgeLabelPlacement to set whether edge labels should be considered when routing the edges.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
13
.Property Value
See Also
Gets or sets the cost for the edge length.
Remarks
This cost will make long routes more expensive than short routes so edges will preferably be kept short.
Increasing the edge length cost will raise the importance of short edges in relation to all other costs while decreasing this cost will raise the importance of all other restrictions. A high edge length cost will result in routes that have fewer bends and more edge crossings to maintain the edge as short as possible.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
2
.Property Value
Gets or sets the cost for an edge crossing a group node.
Remarks
This cost will make routes that cross group nodes more expensive than routes that avoid crossing group nodes. Hence, edges won't preferably cross any group nodes.
Increasing the group node crossing cost will raise the importance of avoiding group node crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions.
Default Value
60
.Property Value
Gets or sets the cost for an edge with a group ID that is not grouped at the source or target side.
Remarks
This cost will make routes for grouped edges that don't use partly the same path as the other edges in this group more expensive than routes that stick to the group.
Increasing the invalid edge grouping cost will raise the importance of grouping edges with the same group ID, while decreasing this cost will raise the importance of all other restrictions. As edge groups require that the route of an edge belonging to an edge group stays partly identical to the other edges of the group, the route may not be optimal with respect to the other restrictions. To maintain the edges together as long as possible, this cost should be higher than most others.
Grouped edges have the same source or target group ID assigned with sourceGroupIds or targetGroupIds.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
25
.Property Value
See Also
Gets or sets the cost for an edge leaving and reentering in the same LayoutGrid cell.
Remarks
This cost will make routes that re-enter the same layout grid cell more expensive than routes taking a more direct way.
Increasing the layout grid reentrance cost will raise the importance of taking the most direct way through the layout grid, while decreasing this cost will raise the importance of all other restrictions.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
7
.Property Value
See Also
Gets or sets the cost for violations of the minimum distance between any two edges.
Remarks
This cost will make routes that pass other edges too close more expensive than routes that maintain the specified minimum edge-to-edge distance.
Increasing the minimum edge-to-edge distance cost will raise the importance of maintaining the minimum distance to other edges, while decreasing this cost will raise the importance of all other restrictions. When this cost has a high value, edges will maintain the specified distance. This may also reduce the number of edges that pass through a small channel between nodes. So, if such a channel is part of the shortest routes for many edges, some of them will take a longer way.
Use minimumEdgeDistance to set the minimum distance for a certain edge to any other edge.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
5
.Property Value
See Also
Gets or sets the cost for violations of the minimum length of the first and last segment of an edge.
Remarks
This cost will make routes whose first/last bend is too close to their source or target node more expensive than routes that maintain the specified minimum first/last segment length.
Increasing the minimum first last segment length cost will raise the importance of maintaining the first and last segment as long as they fit the minimum first/last segment length, while decreasing this cost will raise the importance of all other restrictions.
Use minimumFirstSegmentLength to set the minimum length of the first segment and minimumLastSegmentLength to set the minimum length of the last segment of a certain edge.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
12
.Property Value
See Also
Gets or sets the cost for violations of the minimum distance between any edge and any group node side.
Remarks
This cost will make routes that pass group nodes too close more expensive than routes that maintain the specified minimum node to edge distance.
Increasing the minimum group node to edge distance cost will raise the importance of maintaining the minimum distance to group nodes, while decreasing this cost will raise the importance of all other restrictions. A high cost for violating the minimum distance between edges and group nodes will produce edges that rather use a long route around group nodes to maintain the specified distance than pass through a small channel between two group nodes.
Use minimumNodeToEdgeDistance to set the minimum distance.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
10
.Property Value
See Also
Gets or sets the cost for violations of the minimum distance the edge shall maintain from node corners when entering or leaving the node.
Remarks
This cost will make routes that end too close to the corner of their source or target node more expensive than routes that maintain the specified minimum node corner distance.
Increasing the node corner distance cost will raise the importance of maintaining the minimum distance to the corner of the adjacent nodes, while decreasing this cost will raise the importance of all other restrictions.
Use minimumNodeCornerDistance to set the minimum node corner distance for a certain edge.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
6
.Property Value
See Also
Gets or sets the cost for violations of the minimum distance between any edge and any normal node side.
Remarks
This cost will make routes that pass too close to normal nodes more expensive than routes that maintain the specified minimum node to edge distance.
Increasing the minimum node to edge distance cost will raise the importance of maintaining the minimum distance to nodes, while decreasing this cost will raise the importance of all other restrictions. A high cost for violating the minimum distance between edges and nodes will produce edges that rather use a long route around nodes to maintain the specified distance than pass through a small channel between two nodes.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
10
.Property Value
See Also
Gets or sets the cost for violating the monotonic path restrictions of an edge.
Remarks
This cost will make routes with detours more expensive than routes that stay monotone.
Increasing the monotony violation cost will raise the importance of avoiding detours in the specified direction, while decreasing this cost will raise the importance of all other restrictions.
Use monotonicPathRestriction to set the monotonic path restrictions of a certain edge.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
14
.Property Value
See Also
Gets or sets the cost for an edge crossing a regular node.
Remarks
This cost will make routes that cross normal nodes more expensive than routes that avoid crossing nodes. Hence, edges won't preferably cross any nodes.
Increasing the node crossing cost will raise the importance of avoiding node crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
3000
.Property Value
Gets or sets the cost for an edge crossing a node label.
Remarks
This cost will make routes that cross node labels more expensive than routes that avoid crossing node labels. Hence, edges won't preferably cross any node labels.
Increasing the node label crossing cost will raise the importance of avoiding node labels crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions. A high label crossing cost will cause edges to bend more often to avoid passing straight through labels.
The crossing cost can be weighted for each label individually using the edgeLabelCrossingCostFactors.
Use nodeLabelPlacement to set whether node labels should be considered when routing the edges.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
13
.Property Value
See Also
Gets or sets the cost for an edge that crosses a fixed port location of another edge.
Remarks
This setting affects only ports that are not at the borders of the associated node. More specifically, affected ports are fixed external ports of other edges and fixed internal ports of edges at group nodes. Such ports are induced by a fixed LayoutPortCandidate.
This cost will make routes that cross the mentioned ports more expensive than routes that avoid them. Hence, edges won't preferably cross those ports.
Increasing this cost will raise the importance of avoiding port crossings in relation to other costs, while decreasing this cost will raise the importance of all other restrictions.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
13
.Property Value
Gets or sets the cost if an edge does not comply with its LayoutPortCandidates.
Remarks
This cost will make routes that start or end at a point that doesn't comply with its port constraints more expensive than routes that obey them.
Increasing the port violation cost will raise the importance of maintaining port constraints, while decreasing this cost will raise the importance of all other restrictions. It is recommended to have high costs for port violation since the constraints lose purpose if they are disregarded.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
10000
.Property Value
See Also
Gets or sets the cost for a crossing of two segments that belong to the same edge.
Remarks
This cost only induces costs for crossings between edge segments that are part of the same actual edge. Avoiding such self-crossings is, by default, very important and associated with high costs. Therefore, it is recommended to only reduce this for very specific cases. The costs of other crossings can be controlled with properties edgeCrossingCost and adjacentEdgeCrossingCost.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
50
.Property Value
See Also
Gets or sets the cost for bends of a self-loop edge.
Remarks
This cost will make self-loops leave and enter the node at different sides unless they are forced to one side by LayoutPortCandidates.
Increasing this cost will more strongly enforce routing the self-loops between two sides of the node but it will also require more time for determining the edge path. Decreasing the cost may result in self-loops that only connect to one side of the node.
By default this value is set to 9
. The value must be >= 0
, otherwise the default value will be assigned.
Property Value
Gets or sets the cost for deviating from the original edge path if the scope property of the edge is set to SEGMENTS_AS_NEEDED.
Remarks
For other policies this value is ignored.
This cost is mainly considered during a post-processing step that tries to correct the current route. For larger cost values, the algorithm may remove tiny non-orthogonal segments. In addition, larger values make it more likely that the algorithm considers a non-orthogonal segment to be either vertical/horizontal and tries to fix the route accordingly.
The value must be greater than or equal to 0
, otherwise the default value will be assigned.
Default Value
4.5
.Property Value
See Also
Methods
Creates a copy of this EdgeRouterCosts instance.
Remarks
Returns
- ↪EdgeRouterCosts
- a copy of this instance
Creates a new instance of EdgeRouterCosts.
Remarks
Returns
- ↪EdgeRouterCosts
- a specialized EdgeRouterCosts
Constants
Optimization strategy that balances bends and edge crossings in the edge routes.
Remarks
Optimization strategy that minimizes bends in the edge routes.
Remarks
Optimization strategy that minimizes edge crossings in the edge routes.
Remarks
Optimization strategy that minimizes the length of the edge routes.
Remarks
A cost configuration that prefers fast results over quality, so that several constraints can be ignored.
Remarks
To get the maximum effect, it is recommended to combine this cost configuration with setting property stopDuration to ZERO. This has the effect that edge routes get mostly simple shapes but can sometimes also cross through nodes, crossings are not optimized and various distance settings might be violated.
It is not recommended to use this cost configuration for the incremental use case where only a subset of edges should be routed since fixed edges are not properly considered.