Edge Router
This chapter describes the major API changes to the EdgeRouter introduced with yFiles for HTML 3.0 and how to migrate from the older version.
Renamed, Moved, and Removed Classes and Members
The following table contains the renamed, moved, and removed classes and members of the major classes of the EdgeRouter. In addition to the changes listed here, the expert API to customize path search behavior was streamlined as well; see Major Changes to Expert API.
yFiles for HTML 2.6 | yFiles for HTML 3.0 | Remarks |
---|---|---|
Changed Default Values and Behavior Changes
With buses and a limited duration, the available time is now split among buses. This means that the algorithm will not get "stuck" on a single bus, which could otherwise negatively affect the quality of the remaining buses and non-bus edge routes.
Node labels are now considered by default. To change this behavior, set the nodeLabelPlacement property to the desired value. It is now also easier to place the node labels with GenericLabeling by setting the value to GENERIC.
Edge labels are now placed by a generic labeling algorithm by default. To change this behavior, set the edgeLabelPlacement property to the desired value.
ChannelEdgeRouter Replacement
The EdgeRouter is the replacement for the removed classes ChannelEdgeRouter
,
OrthogonalPatternEdgeRouter
, and OrthogonalSegmentDistributionStage
.
To configure it to have similar performance and generate similar results as the removed ChannelEdgeRouter
,
set the stopDuration property to zero and use the predefined cost configuration
LOW_QUALITY. However, it is not compatible with advanced features like integrated edge label placement.
const fastEdgeRouter = new EdgeRouter({
stopDuration: TimeSpan.ZERO,
defaultEdgeDescriptor: { edgeRouterCosts: EdgeRouterCosts.LOW_QUALITY }
})
graph.applyLayout(fastEdgeRouter)
Scope
yFiles for HTML 3.0 introduces more powerful options to configure the scope of the edge routing algorithm. The new EdgeRouterScopeData<TNode,TEdge,TNodeLabel,TEdgeLabel> still offers functionality to specify the affected edges directly or based on their incident nodes. In addition, it is now possible to assign one of the more differentiated EdgeRouterScope policies to each individual edge, using the scope's new edgeMapping and incidentNodeMapping properties.
For more information on changes to the Scope API, see Scope and Affected Items.
const edgeRouter = new EdgeRouter()
const routerData = edgeRouter.createLayoutData(graph)
routerData.scope.edgeMapping.mapperFunction = (edge) => {
if (edge === edge1) {
// edge1 is always routed
return EdgeRouterScope.PATH
}
if (edge === edge2) {
// edge2 is only routed if necessary
return EdgeRouterScope.PATH_AS_NEEDED
}
if (edge === edge3) {
// only segments of edge3 are routed if necessary
return EdgeRouterScope.SEGMENTS_AS_NEEDED
}
// other edges are not affected
return EdgeRouterScope.IGNORE
}
const edgeRouter = new EdgeRouter()
const routerData = edgeRouter.createLayoutData(graph)
routerData.scope.edgeMapping.mapperFunction = (edge: LayoutEdge) => {
if (edge === edge1) {
// edge1 is always routed
return EdgeRouterScope.PATH
}
if (edge === edge2) {
// edge2 is only routed if necessary
return EdgeRouterScope.PATH_AS_NEEDED
}
if (edge === edge3) {
// only segments of edge3 are routed if necessary
return EdgeRouterScope.SEGMENTS_AS_NEEDED
}
// other edges are not affected
return EdgeRouterScope.IGNORE
}
BusRouter Replacement
The EdgeRouter is the replacement for the removed class BusRouter
.
While it was already able to create bus-style orthogonal edge routes in yFiles for HTML 2.6, the quality
has been improved. Buses are defined very similarly to the old BusRouter
by using a descriptor class
and property buses on class EdgeRouterData.
Major Changes to Expert API
The changes described in this section only affect users who directly worked with the LayoutGraph API, such as when writing custom layout algorithms.
This section provides a broad overview of the changes to the classes that allow advanced customization of the routing and path search algorithm of EdgeRouter. It is not a complete list of all changes.
The protected and expert API to customize the routing behavior of EdgeRouter has been simplified considerably. This makes it less powerful in some ways, but also easier to use when required.
- Class PathSearchExtension still exists and allows you to influence the search process via various callback methods. You can add extensions to the router with the method addPathSearchExtension.
- Class
IGraphPartitionExtension
has been removed and replaced by PartitionExtension. You can add custom partition extensions with the method addPartitionExtension. - Classes/interfaces that have been removed without direct replacement include
PathSearch
,PathSearchResult
,ChannelBasedPathRouting
,IObstaclePartition
,IPartition
,GraphPartition
, andIGraphPartitionExtension
. - Multiple callback methods on EdgeRouter have been removed because they are now obsolete.