C

EdgeRouterCosts

This class provides the costs that are applied for violating restrictions during the path search phase of the EdgeRouter.
Inheritance Hierarchy

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

NameDefault
adjacentEdgeCrossingCost7
bendCost3
bendsInNodeToEdgeDistanceCost10
edgeCrossingCost1
edgeLabelCrossingCost13
edgeLengthCost2
groupNodeCrossingCost60
invalidEdgeGroupingCost25
layoutGridCellReentranceCost7
minimumEdgeDistanceCost5
minimumFirstLastSegmentLengthCost12
minimumGroupNodeToEdgeDistanceCost10
minimumNodeCornerDistanceCost6
minimumNodeToEdgeDistanceCost10
monotonyViolationCost14
nodeCrossingCost3000
nodeLabelCrossingCost13
portCrossingCost13
portViolationCost10000
sketchViolationCost4.5

See Also

Developer's Guide

Members

Show:

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.

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.

EDGE_CROSSINGS_OPTIMIZATION is a predefined configuration of EdgeRouterCosts where edge crossings are expensive and the routes get favorably longer with more bends to avoid crossing other edges.

Property Value

the cost

Default Value

The default value is: 7

See Also

API
edgeCrossingCost
Gets or sets the cost for an edge bend.

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.

EDGE_BENDS_OPTIMIZATION is a predefined configuration of EdgeRouterCosts where bends are expensive and more edges will be crossed to avoid bending.
A very small bend cost (less than 1) can lead to squiggles when the algorithm tries to avoid more expensive restrictions.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 3
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.

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.

In principle, this cost can always be set to the same value as minimumNodeToEdgeDistanceCost since they are used for the same feature.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 10

See Also

API
minimumNodeToEdgeDistance
Gets or sets the cost for a crossing of two edges.

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.

EDGE_CROSSINGS_OPTIMIZATION is a predefined configuration of EdgeRouterCosts where edge crossings are expensive and the routes get favorably longer with more bends to avoid crossing other edges.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 1

See Also

API
adjacentEdgeCrossingCost
Gets or sets the cost for an edge crossing an edge label.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 13

See Also

API
edgeLabelPlacement
Gets or sets the cost for the edge length.

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.

EDGE_LENGTHS_OPTIMIZATION is a predefined configuration of EdgeRouterCosts where short edges are preferred over a small amount of bends and edge crossings.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 2
Gets or sets the cost for an edge crossing a group node.

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.

Like node crossing cost , this cost should be one of the highest costs to make sure that these nodes are avoided. However, as group nodes may be very large it might be useful to allow group node crossings to achieve more direct edge routes.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 60
Gets or sets the cost for an edge with a group ID that is not grouped at the source or target side.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 25

See Also

API
sourceGroupIds, targetGroupIds
Gets or sets the cost for an edge leaving and reentering in the same LayoutGrid cell.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 7

See Also

API
LayoutGrid
Gets or sets the cost for violations of the minimum distance between any two edges.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 5

See Also

API
minimumEdgeDistance
Gets or sets the cost for violations of the minimum length of the first and last segment of an edge.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 12

See Also

API
minimumFirstSegmentLength, minimumLastSegmentLength
Gets or sets the cost for violations of the minimum distance between any edge and any group node side.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 10

See Also

API
minimumNodeToEdgeDistance
Gets or sets the cost for violations of the minimum distance the edge shall maintain from node corners when entering or leaving the node.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 6

See Also

API
minimumNodeCornerDistance
Gets or sets the cost for violations of the minimum distance between any edge and any normal node side.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 10

See Also

API
minimumNodeToEdgeDistance
Gets or sets the cost for violating the monotonic path restrictions of an edge.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 14

See Also

API
monotonicPathRestriction
Gets or sets the cost for an edge crossing a regular node.

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.

The node crossing cost should always be one of the highest costs to make sure that edges are routed around nodes.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 3000
Gets or sets the cost for an edge crossing a node label.

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.

This only applies to labels that are placed outside the bounds of their owner nodes as long as the node crossing cost is higher than the node label crossing cost. Unless the route connects from outside a group to one of its inner nodes, the node label will also be considered.
High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 13

See Also

API
nodeLabelPlacement
Gets or sets the cost for an edge that crosses a fixed port location of another edge.

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.

final

Property Value

the cost

Default Value

The default value is: 13
Gets or sets the cost if an edge does not comply with its LayoutPortCandidates.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost

Default Value

The default value is: 10000

See Also

API
LayoutPortCandidate
Gets or sets the cost for a crossing of two segments that belong to the same edge.

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.

Property Value

the cost

Default Value

The default value is: 50

See Also

API
edgeCrossingCost, adjacentEdgeCrossingCost
Gets or sets the cost for bends of a self-loop edge.

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.

High values for the costs may seem like a great idea to avoid certain conditions, but can cause all kinds of side effects and significantly increase the runtime when it is hard or even impossible to satisfy the condition. Thus, we recommend keeping the values in the range between 0 and 10000. It is especially discouraged to use maximum values like Number.MAX_VALUE as they easily lead to overflows and routing artifacts.

Property Value

the cost
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.

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.

Property Value

the cost

Default Value

The default value is: 4.5

See Also

Developer's Guide
API
SEGMENTS_AS_NEEDED

Methods

Creates a copy of this EdgeRouterCosts instance.
This implementation uses method newInstance to obtain a new instance which adopts all settings.

Return Value

EdgeRouterCosts
a copy of this instance
Creates a new instance of EdgeRouterCosts.
This factory method is used by createCopy. Subclasses can override this method in order to return a more specialized version.
protected

Return Value

EdgeRouterCosts
a specialized EdgeRouterCosts

Constants

Optimization strategy that balances bends and edge crossings in the edge routes.
By default, this strategy is used for the path search.
static
Optimization strategy that minimizes bends in the edge routes.
Edges may cross other edges to prevent bends occurring around them.
static
Optimization strategy that minimizes edge crossings in the edge routes.
This may cause more bends.
static
Optimization strategy that minimizes the length of the edge routes.
In consequence, there may be more edge crossings.
static
A cost configuration that prefers fast results over quality, so that several constraints can be ignored.

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.

static