An edge routing algorithm which routes edges of a graph in an orthogonal bus-style.
Remarks
Carefully observe that the resulting bus representation, with many edge segments drawn on top of each other, leaves little room for a sensible interpretation of edge direction.
Note that class EdgeRouter offers a newer, improved bus-style support (also see EdgeRouterBusDescriptor) and it is recommended to use this instead.
Layout Style
Edge segments are bundled to buses. A bus is a segment shared by multiple edges to which shorter segments that connect to actual nodes are attached. Buses and all other segments are routed orthogonally.
A bus can, for example, be created in parts of a diagram where each node is connected to each other node. There are no cycles induced by any two edge paths of the same bus, that is, the combination of all edge routes looks like an orthogonal tree.
The algorithm tries to produce routes where the edges share as much of their paths as possible. It yields long line segments (so-called backbone segments) where ideally all but the first and last segments of all edge paths are drawn on top of each other (forming a bus), with short connections branching off to the nodes (bus connections). These short connections bundle the respective first or last segments of a node's incident edges.
This algorithm will not modify positions or sizes of nodes in any way, but will route the edges of the graph.
Concept
The algorithm uses a two-phase process:
- Backbone Selection: a set of suitable initial backbone segments is determined.
- Routing and Recombination: each initial backbone segment is connected to all other backbone segments and to each node by using orthogonal edge paths. Then, the resulting structure is reduced to the most optimal structure where backbone segments are long and connections to the nodes are short.
Features
To determine which edges belong to a common bus, a mapping that assigns a bus ID to each edge must be specified using BusRouterBusDescriptors. A IDataProvider holding BusRouterBusDescriptor instances is expected to be registered with the graph using the descriptor key. In the absence of an individual bus ID for an edge, a bus consisting only of the single edge is created.
This algorithm supports PortConstraints as well as PortCandidates to control where edges should connect to nodes.
Note that if edges of the same bus connect to a common node but have inconsistent or contradicting port constraints/candidates, then any of these constraints/candidates can determine the actual location of the common port. The same applies for edges that, in addition, belong to the same edge group.
Also, the cardinality defined with a PortCandidateSet object is interpreted in terms of different bus IDs (group IDs) instead of number of edges.
This algorithm supports incremental edge routing, that is, extending or updating an already existing bus-style representation. This is useful to rearrange existing edges or to include additional edges in an existing bus.
Incremental routing is supported by denoting so-called fixed edges using the corresponding BusDescriptor property. The paths of edges which are not marked as fixed are calculated by the algorithm. The structure induced by the fixed edges must be orthogonal and cycle-free.
Default Values of Properties
crossingCost | 1.0 | One direction change is preferred over the crossing of an edge. |
gridRouting | false | Edges are freely routed. |
gridSpacing | 10 | |
minimumBusConnectionsCount | 3 | |
minimumDistanceToEdge | 5 | |
minimumDistanceToNode | 10 | |
preferredBackboneSegmentCount | 2 | |
scope | ROUTE_ALL_EDGES
|
Type Details
- yfiles module
- router-bus
- yfiles-umd modules
- router-bus, layout
- Legacy UMD name
- yfiles.router.BusRouter
See Also
Constructors
Creates a new instance of BusRouter with default settings.
Parameters
A map of options to pass to the method.
- gridSpacing - number
The equidistant spacing between the horizontal and vertical grid lines. This option sets the gridSpacing property on the created object.
- gridRouting - boolean
Whether or not to route edge segments on grid lines only. This option sets the gridRouting property on the created object.
- minimumDistanceToNode - number
The minimum distance between edge segments and nodes. This option sets the minimumDistanceToNode property on the created object.
- minimumDistanceToEdge - number
The minimum distance between any two edge segments. This option sets the minimumDistanceToEdge property on the created object.
- crossingCost - number
The cost for each edge crossing. This option sets the crossingCost property on the created object.
- rerouting - boolean
Whether or not to perform an additional step to reroute the edges such that the number of edge crossings is reduced. This option sets the rerouting property on the created object.
- preferredBackboneSegmentCount - number
The maximum number of selected backbone segments with the same orientation. This option sets the preferredBackboneSegmentCount property on the created object.
- minimumBackboneSegmentLength - number
The preferred minimum length of a backbone segment. This option sets the minimumBackboneSegmentLength property on the created object.
- minimumBusConnectionsCount - number
The minimum number of bus connections a backbone segment must have. This option sets the minimumBusConnectionsCount property on the created object.
- removeCollinearBends - boolean
Whether or not collinear bends are removed from the layout. This option sets the removeCollinearBends property on the created object.
- affectedEdgesDpKey - Object
The key to register a IDataProvider for marking edges as selected. This option sets the affectedEdgesDpKey property on the created object.
- scope - EdgeRouterScope
The scope for this routing algorithm that determines which edges are routed. This option sets the scope property on the created object.
- coreLayout - ILayoutAlgorithm
The core layout algorithm that is wrapped by this stage. This option sets the coreLayout property on the created object.
Properties
Gets or sets the key to register a IDataProvider for marking edges as selected.
Remarks
true
will be routed. All other edges will be considered to have fixed routes.Default Value
DEFAULT_AFFECTED_EDGES_DP_KEY.Throws
- Exception({ name: 'ArgumentError' })
- if the specified key is
null
Gets or sets the core layout algorithm that is wrapped by this stage.
Gets or sets the cost for each edge crossing.
Remarks
A cost value of n
means that it is more profitable for a path to change its direction n
times rather than crossing the path of an edge. If the cost value is set to 0.0
, no global crossing optimization is performed.
The cost is defined to be a non-negative value.
Default Value
1.0
.One direction change is preferred over the crossing of an edge.
Throws
- Exception({ name: 'ArgumentError' })
- if the given cost value is negative
See Also
Sample Graphs
1.0
and 3.0
.Gets or sets whether or not to route edge segments on grid lines only.
Default Value
false
.Edges are freely routed.
See Also
Sample Graphs
Gets or sets the equidistant spacing between the horizontal and vertical grid lines.
Remarks
2
are allowed. Positive values less than 2
are ignored, while negative values are mapped to their absolute value.Default Value
10
.See Also
Sample Graphs
Gets or sets the preferred minimum length of a backbone segment.
Remarks
This number defines the minimum length of backbone segments which are computed by the backbone selection phase. Some of the final backbone segments may be shorter due to changes in the routing and recombination phase.
The minimum length is defined to be a value greater than or equal to 1.0
.
Default Value
100.0
.Throws
- Exception({ name: 'ArgumentError' })
- if the given minimum length is smaller than
1.0
See Also
Sample Graphs
Gets or sets the minimum number of bus connections a backbone segment must have.
Remarks
If a backbone segment has less connections, it is removed and the affected nodes connect to another backbone segment.
The minimum connection count must be a value greater than or equal to 1
.
Default Value
3
.Throws
- Exception({ name: 'ArgumentError' })
- if the given minimum count is smaller than
1
See Also
Sample Graphs
3
or 4
is a good choice for small graphs. For larger graphs a much larger count can be reasonable.Gets or sets the minimum distance between any two edge segments.
Remarks
The edge routing algorithm adheres to this value if possible, but reduces the distance value selectively, i.e., only for a currently processed edge, when there is not enough space to find a path with the proper value.
Positive values greater than 4
are allowed. Positive values less than 4
are ignored, while negative values are mapped to their absolute values.
Default Value
5
.See Also
Sample Graphs
Gets or sets the minimum distance between edge segments and nodes.
Remarks
2
are allowed. Positive values less than 2
are ignored, while negative values are mapped to their absolutes.Default Value
10
.See Also
Sample Graphs
Gets or sets the maximum number of selected backbone segments with the same orientation.
Remarks
This setting defines the number of backbone segments of the same orientation which are computed by the backbone selection phase. The final number of backbone segments may be different due to changes in the routing and recombination phase.
The number must be a value greater than or equal to 1
.
Default Value
2
.Throws
- Exception({ name: 'ArgumentError' })
- if the given preferred number is smaller than
1
See Also
Sample Graphs
Gets or sets whether or not collinear bends are removed from the layout.
Remarks
A collinear bend is a bend that lies on a common line with its predecessor bend and successor bend.
If an edge has a collinear bend, there is another edge which has a real bend at this point, i.e., the bend location is an intersection of the bus. Therefore, it may be advantageous for some applications to keep such bends.
Default Value
true
.Gets or sets whether or not to perform an additional step to reroute the edges such that the number of edge crossings is reduced.
Remarks
Default Value
false
.See Also
0.0
is assigned to the crossing cost.Gets or sets the scope for this routing algorithm that determines which edges are routed.
Remarks
Default Value
ROUTE_ALL_EDGES.Throws
- Exception({ name: 'ArgumentError' })
- if an unknown scope is given
See Also
Methods
Calculates bus-like routes for the edges in the given input graph.
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
Constants
A data provider key for specifying the edge subset to be routed.
Remarks
Domain | Edge | |
Values | boolean | true if the edge is part of the subset, false or null otherwise |
See Also
A data provider key for specifying a bus descriptor object for each edge.
Remarks
Domain | Edge | |
Values | BusRouterBusDescriptor |