Packagecom.yworks.yfiles.layout.router
Classpublic class BusRouter
InheritanceBusRouter Inheritance AbstractLayoutStage Inheritance YObject Inheritance Object

An orthogonal bus-style edge routing algorithm which combines the large number of edges of complete subgraphs in a concise, tree-like structure that consists of vertical and horizontal line segments. A complete (sub)graph is a set of nodes, in which each node is connected to every other node. The positions of the nodes in a graph are not altered by this algorithm.

In a drawing of this algorithm, each edge path is orthogonal and 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. Besides these strict requirements, the algorithm aims to find routes where shared paths of edges with different end-nodes are drawn on top of each other and form long straight lines, so-called backbone segments. From these backbone segments, short connections of grouped edges branch off to each node (bus connections).

This routing algorithm uses a two-phase process. First, in backbone selection, a set of good initial backbone segments is determined. In routing and recombination, each initial backbone segment is connected to all others and also to each node by using orthogonal edge paths. Then, the set of resulting structures is reduced to the most optimal structure where backbone segments are long and connections to the nodes are short. Note that the calculated paths can join before reaching an initial backbone segment and, thus, establish additional backbone segments. Contrariwise, initial backbone segments of low overall profit are discarded and connections to them are rerouted to other backbone segments.

To determine which edges belong to a common bus, a mapping that assigns a bus ID to each edge must be specified using com.yworks.yfiles.layout.router.BusDescriptor s. A data provider holding bus descriptor objects is expected to be registered with the graph using the EDGE_DESCRIPTOR_DPKEY look-up key. In the absence of an individual bus ID for an edge, a bus consisting only of the single edge is created. Additionally, a bus descriptors allows to mark its associated edge as fixed or movable, which is required for incremental routing, and to specify an optional group ID for an edge's source end and target end, respectively.

Incremental routing means extending or updating an already existing bus-style representation. This can be used to rearrange existing edges or to include additional edges in an existing bus. The paths of edges not marked as fixed by their associated BusDescriptor (com.yworks.yfiles.layout.router.BusDescriptor.fixed) are calculated anew. The structure induced by the fixed edges must be orthogonal and cycle-free.

See also

com.yworks.yfiles.layout.router.BusDescriptor
EDGE_DESCRIPTOR_DPKEY
BusDescriptor


Public Properties
 PropertyDefined By
 InheritedcoreLayouter : Layouter
Specifies the core layouter.
AbstractLayoutStage
  crossingCost : Number
Specifies the cost for each edge crossing of a routed path.
BusRouter
  gridRouting : Boolean
Getter: Returns whether or not to route edge segments on grid lines.
BusRouter
  gridSpacing : int
Specifies the grid spacing that is used when grid routing is enabled.
BusRouter
  minimumBackboneSegmentLength : Number
Specifies the preferred minimum length of a backbone segment.
BusRouter
  minimumBusConnectionsCount : int
Getter: Returns the minimum number of bus connections each backbone segment must have.
BusRouter
  minimumDistanceToEdge : int
Specifies the minimum distance between edge segments.
BusRouter
  minimumDistanceToNode : int
Specifies the minimum distance between edge segments and nodes.
BusRouter
  preferredBackboneSegmentCount : int
Getter: Returns the preferred number of backbone segments with the same orientation.
BusRouter
  removeCollinearBends : Boolean
Specifies whether or not collinear bends are removed from the layout.
BusRouter
  rerouting : Boolean
Getter: Returns whether rerouting of edges with many crossings is enabled.
BusRouter
  scope : int
Getter: Returns the scope set for this router.
BusRouter
  selectedEdgesDpKey : Object
Specifies the DataProvider key to mark edges as selected.
BusRouter
Public Methods
 MethodDefined By
  
BusRouter(init:Boolean = true)
Creates a new instance of BusRouter.
BusRouter
  
canLayout(graph:LayoutGraph):Boolean
[override] Returns true if the specified graph can be routed by this algorithm.
BusRouter
  
doLayout(graph:LayoutGraph):void
[override] Calculates a new bus layout for the specified graph.
BusRouter
 Inherited
equals(o:Object):Boolean
YObject
  
getClass():Class
[override]
BusRouter
 Inherited
hashCode():int
YObject
  
[static] Creates a new instance of BusRouter.
BusRouter
  
setProperty(key:String, value:Object):Boolean
Provides access to implementation specific properties of the algorithms used internally.
BusRouter
Protected Methods
 MethodDefined By
 Inherited
canLayoutCore(graph:LayoutGraph):Boolean
Queries the core layouter whether or not the given graph can be laid out.
AbstractLayoutStage
  
Factory method that creates an appropriate OrthogonalEdgeRouter implementation.
BusRouter
 Inherited
Invokes the layout routine of the core layouter.
AbstractLayoutStage
 Inherited
AbstractLayoutStage
 Inherited
AbstractLayoutStage
  
Initializes this object.
BusRouter
Public Constants
 ConstantDefined By
  EDGE_DESCRIPTOR_DPKEY : Object = y.layout.router.BusRouter.EDGE_DESCRIPTOR_DPKEY
[static] com.yworks.yfiles.base.DataProvider key used to store the com.yworks.yfiles.layout.router.BusDescriptor of every edge.
BusRouter
  EDGE_SUBSET_DPKEY : Object = y.layout.router.BusRouter.EDGE_SUBSET_DPKEY
[static] com.yworks.yfiles.base.DataProvider key used for specifying the edge subset to be laid out.
BusRouter
  SCOPE_ALL : int
[static] Scope constant - used for routing all edges in the graph.
BusRouter
  SCOPE_SUBSET : int
[static] Scope constant - used for routing only a subset of edges.
BusRouter
Property Detail
crossingCostproperty
crossingCost:Number

Specifies the cost for each edge crossing of a routed path. A cost of n means that a path rather changes direction n times than crossing the path of an edge. If the cost is set to 0.0, no global crossing optimization is performed. Setting a higher value will activate global crossing minimization. A good trade-off between the number of direction changes and few crossings of a path is achieved by values between 1.0 and 3.0. By default, a cost of 1.0 is set.

This setting is taken into account only in the routing and recombination phase and does not affect the selection of the initial backbone segments.


Implementation
    public function get crossingCost():Number
    public function set crossingCost(value:Number):void
gridRoutingproperty 
gridRouting:Boolean

Getter: Returns whether or not to route edge segments on grid lines.

Setter: Specifies whether or not to route edge segments on grid lines only. By default, this feature is disabled.


Implementation
    public function get gridRouting():Boolean
    public function set gridRouting(value:Boolean):void

See also

gridSpacingproperty 
gridSpacing:int

Specifies the grid spacing that is used when grid routing is enabled. By default, a spacing of 10 is set.


Implementation
    public function get gridSpacing():int
    public function set gridSpacing(value:int):void

See also

minimumBackboneSegmentLengthproperty 
minimumBackboneSegmentLength:Number

Specifies the preferred minimum length of a backbone segment. This should be at least as large as the typical distance between nodes to avoid small backbone segments. It is reasonable to set this according to the dimension of the graph's bounding box. By default, a minimum length of 100.0 is set.

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.


Implementation
    public function get minimumBackboneSegmentLength():Number
    public function set minimumBackboneSegmentLength(value:Number):void
minimumBusConnectionsCountproperty 
minimumBusConnectionsCount:int

Getter: Returns the minimum number of bus connections each backbone segment must have.

Setter: Sets the minimum number of bus connections a backbone segment must have. If a backbone segment has less connections, it is removed and the affected nodes connect to another backbone segment. Three or four is a good choice for small graphs, for larger graphs a much larger count can be reasonable. By default, a minimum count of 3 is set.

This setting is taken into account only in the routing and recombination phase and does not affect the selection of the initial backbone segments.


Implementation
    public function get minimumBusConnectionsCount():int
    public function set minimumBusConnectionsCount(value:int):void
minimumDistanceToEdgeproperty 
minimumDistanceToEdge:int

Specifies the minimum distance between edge segments. By default, a distance of 5 is set.


Implementation
    public function get minimumDistanceToEdge():int
    public function set minimumDistanceToEdge(value:int):void

See also

minimumDistanceToNodeproperty 
minimumDistanceToNode:int

Specifies the minimum distance between edge segments and nodes. By default, a distance of 10 is set.


Implementation
    public function get minimumDistanceToNode():int
    public function set minimumDistanceToNode(value:int):void

See also

preferredBackboneSegmentCountproperty 
preferredBackboneSegmentCount:int

Getter: Returns the preferred number of backbone segments with the same orientation.

Setter: Sets the maximal number of selected backbone segments with the same orientation. The more initial backbone segments, the longer the running time. By default, a count of 2 is set.

This count 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.


Implementation
    public function get preferredBackboneSegmentCount():int
    public function set preferredBackboneSegmentCount(value:int):void
removeCollinearBendsproperty 
removeCollinearBends:Boolean

Specifies whether or not collinear bends are removed from the layout. 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 is advantageous for some applications to keep such bends. By default, this feature is enabled.


Implementation
    public function get removeCollinearBends():Boolean
    public function set removeCollinearBends(value:Boolean):void
reroutingproperty 
rerouting:Boolean

Getter: Returns whether rerouting of edges with many crossings is enabled.

Setter: Specifies whether or not to enable a further crossing minimization optimization based on rerouting edges that cross many edges. By default, this feature is disabled. Activating this feature only makes sense if the global crossing cost is set to a value greater than 0.0.

This setting is taken into account only in the routing and recombination phase and does not affect the selection of the initial backbone segments.


Implementation
    public function get rerouting():Boolean
    public function set rerouting(value:Boolean):void

See also

scopeproperty 
scope:int

Getter: Returns the scope set for this router.

Setter: Sets the scope for this router. The scope determines which edges are routed. Defaults to SCOPE_ALL.


Implementation
    public function get scope():int
    public function set scope(value:int):void

See also

selectedEdgesDpKeyproperty 
selectedEdgesDpKey:Object

Specifies the DataProvider key to mark edges as selected.

By default, EDGE_SUBSET_DPKEY is used.


Implementation
    public function get selectedEdgesDpKey():Object
    public function set selectedEdgesDpKey(value:Object):void

Throws
IllegalArgumentException — if the specified key is null.

See also

Constructor Detail
BusRouter()Constructor
public function BusRouter(init:Boolean = true)

Creates a new instance of BusRouter.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
canLayout()method
override public function canLayout(graph:LayoutGraph):Boolean

Returns true if the specified graph can be routed by this algorithm. Calling doLayout() with the specified graph as its argument will only succeed if this method returns true.

If there is no fixed edge in the graph, routing is always possible. Otherwise, the route of each fixed edge must be orthogonal.

Parameters

graph:LayoutGraph

Returns
Boolean

See also

createOrthogonalEdgeRouter()method 
protected function createOrthogonalEdgeRouter():OrthogonalEdgeRouter

Factory method that creates an appropriate OrthogonalEdgeRouter implementation.

Returns
OrthogonalEdgeRouter — an appropriate OrthogonalEdgeRouter
doLayout()method 
override public function doLayout(graph:LayoutGraph):void

Calculates a new bus layout for the specified graph.

Parameters

graph:LayoutGraph — the graph to lay out

getClass()method 
override public function getClass():Class

Returns
Class
initBusRouter()method 
protected final function initBusRouter():void

Initializes this object. See the documentation of the corresponding factory method newBusRouter() for details.

See also

newBusRouter()method 
public static function newBusRouter():BusRouter

Creates a new instance of BusRouter.

Returns
BusRouter
setProperty()method 
public function setProperty(key:String, value:Object):Boolean

Provides access to implementation specific properties of the algorithms used internally. Used for internal purposes.

Parameters

key:String — the key to a property
 
value:Object — the value to associate with the key

Returns
Boolean
Constant Detail
EDGE_DESCRIPTOR_DPKEYConstant
public static const EDGE_DESCRIPTOR_DPKEY:Object = y.layout.router.BusRouter.EDGE_DESCRIPTOR_DPKEY

com.yworks.yfiles.base.DataProvider key used to store the com.yworks.yfiles.layout.router.BusDescriptor of every edge. A bus descriptor provides the edge's bus ID, its optional group IDs and whether or not the edge is fixed.

See also

EDGE_SUBSET_DPKEYConstant 
public static const EDGE_SUBSET_DPKEY:Object = y.layout.router.BusRouter.EDGE_SUBSET_DPKEY

com.yworks.yfiles.base.DataProvider key used for specifying the edge subset to be laid out. This key is used if no custom key is set. The algorithm expects for each edge in the graph to find a boolean (com.yworks.yfiles.base.DataProvider.getBool()) that indicates whether the node belongs to the scope.

See also

SCOPE_ALLConstant 
public static const SCOPE_ALL:int

Scope constant - used for routing all edges in the graph.

See also

SCOPE_SUBSETConstant 
public static const SCOPE_SUBSET:int

Scope constant - used for routing only a subset of edges. This subset has to be specified by registering an appropriate com.yworks.yfiles.base.DataProvider.

See also