( a feature of FlowChartX Pro edition)
Implements a layered graph layout algorithm.
VB6
![]() |
---|
Public Class LayeredLayout |
C++
![]() |
---|
class LayeredLayout |
This algorithm assigns diagram nodes to distinct horizontal or vertical layers. While arranging the layers, the layout routine seeks to meet the following criteria:
To apply this layout to a diagram, create a LayeredLayout instance, set its members and invoke the ArrangeDiagram method. If there are several unconnected graphs in the diagram, it is possible to specify which of them to arrange by means of the Root property.
By default, layers are generated along the longest path in the graph, where each node from the path is placed on a consecutive layer. Arranging nodes along the longest path guarantees that all links from the path flow in the same direction, but could lead to many other links point backwards in the graph. To ensure that the maximum possible number of links flow in the same direction, set the EnforceLinkFlow property. If you need specific nodes to be used as a start and end node in the layout and the layering of other nodes be determined by their distance from the start, set the StartNode and EndNode properties.
The final appearance of arranged graphs depends mostly on the Orientation property which defines the overall orientation of the layout. The LayerDistance and NodeDistance properties specify how much space to leave between adjacent layers and adjacent nodes in a layer. Note that the size of nodes is ignored by default; to specify that the node size should be considered, set IgnoreNodeSize to false.
The performance of LayeredLayout is dependent on the number of links in the diagram. At its first stage, the algorithm looks for the longest sequence of links in the graph and builds the node layers along it. That stage can be the most time consuming if there are a lot of links in a graph, so there is the TimeLimit property provided to control how much time the layout routine is allowed to spend on path-finding. Next, if there are layers much longer than the other ones and SplitLayers is enabled, nodes from these layers are moved to new ones so the graph width is uniformly distributed.
The layout routine continues by shuffling nodes and link points across their layers, so the criteria mentioned above are approximated. Finally, link ends are aligned to anchor points if ArrowAnchoring is enabled and the distance between outermost links is decreased as set in CompactFactor.