- I
- I
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
| Name | Default | Description |
|---|---|---|
| coreLayout | null | |
| edgeLabelPlacement | EdgeRouterEdgeLabelPlacement.GENERIC | Edge labels placed by an an independent labeling algorithm. |
| gridSpacing | 0 | No grid is considered. |
| minimumNodeToEdgeDistance | 10 | |
| nodeLabelPlacement | EdgeRouterNodeLabelPlacement.CONSIDER | Node labels are considered. |
| rerouting | false | The rerouting step will not be performed. |
| stopDuration | TimeSpan.MAX_VALUE | The edge routing algorithm runs unrestricted. |
See Also
Developer's Guide
Members
Constructors
Creates a new EdgeRouter instance with an optional coreLayout.
Parameters
- coreLayout?: ILayoutAlgorithm
- The core layout algorithm.
Properties
Gets or sets the core ILayoutAlgorithm that is wrapped by this stage.
Property Value
Default Value
Defined in
LayoutStageBase.coreLayoutGets the descriptor instance that defines settings for all those edges that do not have an assigned edge descriptor .
Property Value
See Also
Developer's Guide
API
- edgeDescriptors
Gets or sets how the layout handles the position of edge labels.
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
Developer's Guide
Gets or sets a value that determines whether this stage should do anything but execute the coreLayout.
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.
Defined in
LayoutStageBase.enabledGets or sets a GenericLabeling helper class for this algorithm.
0, no grid is considered.Property Value
Default Value
Sample Graphs
See Also
Developer's Guide
Property Value
Throws
- Exception ({ name: 'ArgumentError' })
- if the minimum node-to-edge distance is negative
Default Value
Sample Graphs
10See Also
Developer's Guide
API
- minimumNodeToEdgeDistanceCost
Gets or sets how the layout handles the position of node labels.
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
Default Value
Sample Graphs
See Also
Developer's Guide
Property Value
true if the rerouting step will be performed, false otherwiseDefault Value
Gets or sets the time limit set for the edge routing algorithm.
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.
Throws
- Exception ({ name: 'ArgumentError' })
- if the given duration is negative
Default Value
Methods
Implementation of the ILayoutAlgorithm interface and main entry point for the layout calculation.
Parameters
- graph: LayoutGraph
- The graph to apply the layout to.
Defined in
LayoutStageBase.applyLayoutPerforms the routing of the edges of the input graph.
Parameters
- graph: LayoutGraph
- the input graph
Overrides
LayoutStageBase.applyLayoutImplcreateLayoutData
(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.
createLayoutData
(graph: LayoutGraph): EdgeRouterData<LayoutNode, LayoutEdge, LayoutNodeLabel, LayoutEdgeLabel>Parameters
- graph: LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Return Value
- 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.
LayoutExecutor type is available at runtime.Parameters
- graph?: IGraph
- the graph that determines the generic type arguments of the created layout data
Return Value
- EdgeRouterData<INode, IEdge, ILabel, ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given EdgeRouter.
Returns the EdgeRouterEdgeDescriptor instance for a given edge that is defined via edgeDescriptors.
Parameters
- edge: LayoutEdge
- the given edge
Return Value
- EdgeRouterEdgeDescriptor
- the current EdgeRouterEdgeDescriptor instance for a given edge