documentationfor yFiles for HTML 3.0.0.1

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.

Renamed, moved, and removed members of classes related to the EdgeRouter (classes are bold)
yFiles for HTML 2.6 yFiles for HTML 3.0 Remarks
EdgeRouterclass name unchanged
Properties in class EdgeRouter
considerEdgeLabelsedgeLabelPlacementCombined the two properties. The enum now allows you to choose between integrated labeling and the GenericLabeling algorithm.
integratedEdgeLabeling
considerNodeLabelsnodeLabelPlacementThe enum now allows you to choose between considering the node labels and the GenericLabeling algorithm.
defaultEdgeLayoutDescriptordefaultEdgeDescriptorSettings for individual edges can be specified via the edgeDescriptors property of EdgeRouterData.
edgeComparerEdgeRouterData.edgeProcessingComparatorMoved to layout data.
gridgridSpacingIs now a simple numeric value. Set to zero to disable grid.
ignoreInnerNodeLabelsremovedControlled via nodeLabelPlacement. Inner labels of non-group nodes are only ignored when choosing settings IGNORE; labels of group nodes alone can be ignored when choosing IGNORE_GROUP_LABELS.
maximumDurationstopDurationThe router tries to stop within the given time, but it is not guaranteed to do so. The property was renamed to signal this intent better.
polylineRoutingremovedUse routingStyle on the descriptor instead.
preferredPolylineSegmentLengthremovedUse preferredOctilinearSegmentLength on the descriptor instead.
maximumPolylineSegmentRatioremovedUse maximumOctilinearSegmentRatio on the descriptor instead.
scoperemovedThe routed edges can instead be selected using scope
EdgeRouterDataEdgeRouterData<TNode,TEdge,TNodeLabel,TEdgeLabel>
Properties in class EdgeRouterData
affectedEdgesscope.edgesMoved to sub-data scope. See migration chapter about Scope and Affected Items.
affectedNodesscope.incidentNodesMoved to sub-data scope. See migration chapter about Scope and Affected Items.
edgeLabelPreferredPlacementedgeLabelPreferredPlacements
edgeLayoutDescriptorsedgeDescriptors
nodeHalosnodeMarginsThe type of the values was changed to Insets.
nodePortCandidatesSetports.nodePortCandidatesMoved to sub-data ports. See also Ports.
partitionGridDatalayoutGridData
sourcePortCandidatesports.sourcePortCandidatesMoved to sub-data ports. PortCandidates and PortConstraints are now combined in one concept; see migration chapter about Ports.
sourcePortConstraints
sourcePortGroupIdsports.sourcePortGroupIdsMoved to sub-data ports.
targetPortCandidatesports.targetPortCandidatesMoved to sub-data ports. PortCandidates and PortConstraints are now combined in one concept; see migration chapter about Ports.
targetPortConstraints
targetPortGroupIdsports.targetPortGroupIdsMoved to sub-data ports.
EdgeRouterEdgeLayoutDescriptorEdgeRouterEdgeDescriptor
Properties in class EdgeRouterEdgeDescriptor
penaltySettingsedgeRouterCosts
minimumEdgeToEdgeDistanceminimumEdgeDistance
PenaltySettingsEdgeRouterCosts
Properties in class EdgeRouterCosts
minimumEdgeToEdgeDistancePenaltyminimumEdgeDistanceCost

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.

Creating an EdgeRouter instance that behaves similarly to the removed ChannelEdgeRouter
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, and IGraphPartitionExtension.
  • Multiple callback methods on EdgeRouter have been removed because they are now obsolete.