LayeredDigraphLayout class

This arranges nodes of directed graphs into layers (rows or columns). There are many samples that use LayeredDigraphLayout.

If you want to experiment interactively with most of the properties, try the Layered Digraph Layout sample. See samples that make use of LayeredDigraphLayout in the samples index.

The #layerSpacing property controls the distance between layers. The #columnSpacing property controls the breadth of each "column" -- this affects the distance between nodes within a layer, although the exact distance also depends on the breadth of each node. The #layeringOption property determines whether nodes without links coming in or without links going out are lined up at the edge of the graph, or whether they are positioned close to their connected nodes.

By default the layout will route the links in a manner that is consistent with the #direction. So, for example, if the #direction is 90 degrees (i.e. downward), the links are expected to go from the top towards the bottom. That means the links should come out from the bottom of the ports and should go into the top of the ports. Basically the layout will set Link#fromSpot to Spot.Bottom and Link#toSpot to Spot.Top.

If you want to the links to use the spots that are given by the ports or by the links themselves, you will need to set #setsPortSpots to false to prevent this layout from setting the spots on the links. For example, if each node only has one port that is the whole node, and if you want the links to be spread out along the sides of the nodes, then you should set #setsPortSpots to false and set the node's GraphObject#fromSpot to Spot.BottomSide and GraphObject#toSpot to Spot.TopSide.

This layout handles links that form cycles better than TreeLayout does. The normal routing behavior for "backwards" links is to route them "around" the source node and "around" the destination node, so that all links come in one side and go out the other side. However if you want "backwards" links to go more directly between nodes, set #setsPortSpots to false and the node's GraphObject#fromSpot and GraphObject#toSpot both to Spot.TopBottomSides. (Of course if the #direction is zero or 180, you'll want to use Spot.LeftRightSides.)

If the diagram is structured in a tree-like fashion, it may be better to use TreeLayout, which has more options specific to trees. TreeLayout is much faster than LayeredDigraphLayout, and can handle a limited number of links that would prevent the graph structure from being a true tree (i.e. some nodes having multiple parents).

This layout makes use of a LayoutNetwork of LayeredDigraphVertexes and LayeredDigraphEdges that normally correspond to the Nodes and Links of the Diagram.

The layout algorithm consists of four-major steps: Cycle Removal, Layer Assignment, Crossing Reduction, and Straightening and Packing. The layout cannot guarantee that it provides optimal positioning of nodes or routing of links.

The Layer Assignment step can be slow if #layeringOption is LayeredDigraphLayout.LayerOptimalLinkLength, which is the default value.

The CrossingReduction step is usually slow, but it can be avoided if you want to maintain a certain order within each layer by setting LayeredDigraphLayout#aggressiveOption to LayeredDigraphLayout.AggressiveNone.

The Straightening and Packing step is usually slow, but you can set #packOption at the expense of less nicely placed nodes. Moreover, if you do not set this property, the layout will automatically remove the LayeredDigraphLayout.PackExpand flag if the graph is large enough, in order to improve performance. It is also worth experimenting whether using #alignOption to straighten and pack provides good results for your graphs, as it is faster than #packOption.

If performance remains a problem, contact us.

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

LayeredDigraphLayout([dynamic init])
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

aggressiveLess EnumValue
The faster, less aggressive, crossing reduction algorithm; a valid value for LayeredDigraphLayout#aggressiveOption.
getter/setter pair
aggressiveMore EnumValue
The slower, more aggressive, crossing reduction algorithm, a valid value for LayeredDigraphLayout#aggressiveOption.
getter/setter pair
aggressiveNone EnumValue
The fastest, but poorest, crossing reduction algorithm; a valid value for LayeredDigraphLayout#aggressiveOption.
getter/setter pair
alignAll num
Enable all options for the LayeredDigraphLayout#alignOption property; See also LayeredDigraphLayout.AlignUpperLeft, LayeredDigraphLayout.AlignUpperRight, LayeredDigraphLayout.AlignLowerLeft, and LayeredDigraphLayout.AlignLowerRight.
getter/setter pair
alignLowerLeft num
This option aligns and compacts nodes based on lower neighbors, favoring leftmost neighbors, a valid value for LayeredDigraphLayout#alignOption.
getter/setter pair
alignLowerRight num
This option aligns and compacts nodes based on lower neighbors, favoring rightmost neighbors, a valid value for LayeredDigraphLayout#alignOption.
getter/setter pair
alignNone num
This option means the the layout will pack nodes using the LayeredDigraphLayout#packOption instead of LayeredDigraphLayout#alignOption, a valid value for LayeredDigraphLayout#alignOption.
getter/setter pair
alignUpperLeft num
This option aligns and compacts nodes based on upper neighbors, favoring leftmost neighbors, a valid value for LayeredDigraphLayout#alignOption.
getter/setter pair
alignUpperRight num
This option aligns and compacts nodes based on upper neighbors, favoring rightmost neighbors, a valid value for LayeredDigraphLayout#alignOption.
getter/setter pair
cycleDepthFirst EnumValue
Remove cycles using depth first cycle removal; a valid value of LayeredDigraphLayout#cycleRemoveOption.
getter/setter pair
cycleFromLayers EnumValue
Remove cycles depending on #assignLayers determining entirely which links are backwards links; a valid value of LayeredDigraphLayout#cycleRemoveOption.
getter/setter pair
cycleGreedy EnumValue
Remove cycles using greedy cycle removal; a valid value of LayeredDigraphLayout#cycleRemoveOption.
getter/setter pair
initDepthFirstIn EnumValue
Initialize using depth first in initialization; a valid value for LayeredDigraphLayout#initializeOption.
getter/setter pair
initDepthFirstOut EnumValue
Initialize using depth first out initialization; a valid value for LayeredDigraphLayout#initializeOption.
getter/setter pair
initNaive EnumValue
Initialize using naive initialization; a valid value for LayeredDigraphLayout#initializeOption.
getter/setter pair
layerLongestPathSink EnumValue
Assign layers using longest path sink layering, so that nodes are placed in the latest layer possible possibly resulting in longer links to nodes at the last/deepest layers; a valid value for LayeredDigraphLayout#layeringOption.
getter/setter pair
layerLongestPathSource EnumValue
Assign layers using longest path source layering, so that nodes without any predecessors are placed in the first layer possibly resulting in longer links from nodes at the first/shallowest layers; a valid value for LayeredDigraphLayout#layeringOption.
getter/setter pair
layerOptimalLinkLength EnumValue
Assign layers using optimal link length layering, so that links tend to cross the fewest number of layers; A valid value for LayeredDigraphLayout#layeringOption.
getter/setter pair
packAll num
Enable all options for the LayeredDigraphLayout#packOption property; but we recommend using #alignOption instead for better alignment and speed; See also LayeredDigraphLayout.PackExpand, LayeredDigraphLayout.PackStraighten, and LayeredDigraphLayout.PackMedian.
getter/setter pair
packExpand num
This option gives more chances for the packing algorithm to improve the network, but is very expensive in time for large networks; but we recommend using #alignOption instead for better alignment and speed; a valid value for LayeredDigraphLayout#packOption.
getter/setter pair
packMedian num
This option tries to have the packing algorithm center groups of nodes based on their relationships with nodes in other layers, a valid value for LayeredDigraphLayout#packOption; but we recommend using #alignOption instead for better alignment and speed.
getter/setter pair
packNone num
Does minimal work in packing the nodes; a valid value for LayeredDigraphLayout#packOption; but we recommend using #alignOption instead for better alignment and speed.
getter/setter pair
packStraighten num
This option tries to have the packing algorithm straighten many of the links that cross layers, a valid value for LayeredDigraphLayout#packOption; but we recommend using #alignOption instead for better alignment and speed.
getter/setter pair