GoJS® Diagramming Components
version 1.6.19 for JavaScript/HTML
by Northwoods Software®

## Class TreeLayout

Extends Layout. This layout positions nodes of a tree-structured graph in layers (rows or columns). For a discussion and examples of the most commonly used properties, see Trees page in the Introduction. There are many samples that use TreeLayout. If you want to experiment interactively with most of the properties, try the Tree Layout sample.

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

The most commonly set properties for controlling the results of a TreeLayout are:

- angle: the direction in which the tree grows, from parent to child; the default value of zero means that the tree grows towards the right, with the children of a node arranged in a layer that is a column. An angle of 0 or 180 means that children form vertical layers -- breadth is height and depth is width; an angle of 90 or 270 means that children form horizontal layers -- breadth is width and depth is height.
- layerSpacing: the distance between layers -- between a parent node and its child nodes.
- nodeSpacing: the distance between nodes within a layer -- between siblings.
- alignment: the relative position of a parent node with its children.
- sorting and comparer: specify the order of the immediate children of a parent node.
- compaction: whether subtrees should be packed closer together if there is room.
- layerStyle: whether the children of one node are aligned with the children of a sibling node.
- setsPortSpot, portSpot, setsChildPortSpot, and childPortSpot: this controls whether to set the Link.fromSpot and Link.toSpot to be sensible for the angle.
- nodeIndent and nodeIndentPastParent: if the alignment is TreeLayout.AlignmentStart or TreeLayout.AlignmentEnd, control how much extra space the first child is given when positioned.
- breadthLimit, rowSpacing: try to limit the total breadth of a subtree to a certain distance; when there are too many children or when they are too broad, this puts children into additional rows (or columns, depending on the angle) thereby limiting the breadth while increasing the depth of the tree.

When you set one of the TreeLayout properties listed above, that property normally applies to all of the nodes in the tree. What if you want alignment to be TreeLayout.AlignmentCenterChildren for the root node but TreeLayout.AlignmentBus for the other nodes in the tree? Or what if you want want layerSpacing to be 50 for all layers except for the layer separating "leaf" nodes from their parent?

One common solution is to set treeStyle. For the former scenario, you could set treeStyle to TreeLayout.StyleRootOnly; the value of alignment would only apply to the root node. For the latter scenario, you could set it to TreeLayout.StyleLastParents; the value of layerSpacing would apply to all nodes except those that have children but that do not have grandchildren. How do you then set the alignment or layerSpacing for the other nodes? By setting the TreeLayout properties whose names start with "alternate...". In these cases that would mean setting alternateAlignment or alternateLayerSpacing.

These TreeLayout properties actually apply to the TreeVertex that the TreeLayout uses to represent a Node within the TreeNetwork. All of those TreeLayout properties are actually stored in rootDefaults; all of the "alternate..." properties are stored in alternateDefaults. Depending on the value of treeStyle, the actual TreeVertex properties for each Node are copied appropriately from either rootDefaults or alternateDefaults. In the default case where treeStyle is TreeLayout.StyleLayered, the alternateDefaults are ignored. (Note that treeStyle, and a few other properties such as path and arrangement, apply to the whole layout, not to an individual node/vertex.)

The use of treeStyle and "alternate..." TreeLayout properties will cover a lot of common needs for tree layout customization. However, there may be times when that is not enough. Imagine a situation where you want a special TreeVertex property value for a particular Node. The solution is to override assignTreeVertexValues, where you can examine the given TreeVertex, including its corresponding LayoutVertex.node, to decide what TreeVertex property values should apply.

## Constructor Summary Details

Name | Description
--- | ---
TreeLayout() | Constructs a TreeLayout with no Layout.network and with no owning Layout.diagram.

## Properties Summary Details

Name, Value Type | Description
--- | ---
alignment {EnumValue} | Gets or sets the default alignment of parents relative to their children.More... Must be a static constant of TreeLayout whose name starts with "Alignment". The default value is TreeLayout.AlignmentCenterChildren. This sets the rootDefaults' property of the same name.
alternateAlignment {EnumValue} | Gets or sets the alternate alignment of parents relative to their children.More... Must be a static constant of TreeLayout whose name starts with "Alignment". The default value is TreeLayout.AlignmentCenterChildren. This sets the alternateDefaults' property of the same name.
alternateAngle {number} | Gets or sets the alternate direction for tree growth.More... The default value is 0; the value must be one of: 0, 90, 180, 270. These values are in degrees, where 0 is along the positive X axis, and where 90 is along the positive Y axis. This sets the alternateDefaults' property of the same name.

alternateBreadthLimit
{number}

Gets or sets an alternate limit on how broad a tree should be.More...

A value of zero (the default) means there is no limit; a positive value specifies a limit. The default value is zero.

This property is just a suggested constraint on how broadly the tree will be laid out. When there isn't enough breadth for all of the children of a node, the children are placed in as many rows as needed to try to stay within the given breadth limit. If the value is too small, since this layout algorithm does not modify the size or shape of any node, the nodes will just be laid out in a line, one per row, and the breadth is determined by the broadest node. The distance between rows is specified by rowSpacing. To make room for the links that go around earlier rows to get to later rows, when the alignment is not a "center" alignment, the rowIndent property specifies that space at the start of each row. This sets the alternateDefaults' property of the same name.

alternateChildPortSpot
{Spot}

Gets or sets the alternate spot that children nodes' ports get as their ToSpot The default value is Spot.Default.More...

A value of Spot.Default will cause the TreeLayout to assign a ToSpot based on the parent node's TreeVertex.angle.

If the value is other than NoSpot, it is just assigned. When path is PathSource, the port's FromSpot is set instead of the ToSpot. This sets the alternateDefaults' property of the same name.

alternateCommentMargin {number} | Gets or sets the alternate distance between a node and its comments.More... The default value is 20. This is used by addComments and layoutComments. This sets the alternateDefaults' property of the same name.
alternateCommentSpacing {number} | Gets or sets the alternate distance between comments.More... The default value is 10. This is used by addComments and layoutComments. This sets the alternateDefaults' property of the same name.
alternateCompaction {EnumValue} | Gets or sets how closely to pack the child nodes of a subtree.More... Must be either TreeLayout.CompactionBlock or TreeLayout.CompactionNone. The default value is TreeLayout.CompactionBlock. This sets the alternateDefaults' property of the same name.
alternateComparer {function(TreeVertex, TreeVertex):number} | Gets or sets the alternate comparison function used for sorting the immediate children of a vertex.More... The default comparer compares the LayoutVertex.node Text values. This sets the alternateDefaults' property of the same name. Whether this comparison function is used is determined by the value of alternateSorting.
alternateDefaults {TreeVertex} | Gets or sets the object holding the default values for alternate layer TreeVertexes, used when the treeStyle is StyleAlternating or StyleLastParents.More... See the list of inheritable properties in the documentation for rootDefaults. The other properties of this TreeVertex are ignored.

alternateLayerSpacing
{number}

Gets or sets the alternate distance between a parent node and its children.More...

The default value is 50.

This is the distance between a parent node and its first row of children, in case there are multiple rows of its children. The rowSpacing property determines the distance between rows of children. Negative values may cause children to overlap with the parent. This sets the alternateDefaults' property of the same name.

alternateLayerSpacingParentOverlap
{number}

Gets or sets the alternate fraction of the node's depth for which the children's layer starts overlapped with the parent's layer.More...

The default value is 0.0 -- there is overlap between layers only if layerSpacing is negative. A value of 1.0 and a zero layerSpacing will cause child nodes to completely overlap the parent.

A value greater than zero may still cause overlap between layers, unless the value of layerSpacing is large enough. A value of zero might still allow overlap between layers, if layerSpacing is negative. This sets the alternateDefaults' property of the same name.

alternateNodeIndent
{number}

Gets or sets the alternate indentation of the first child.More...

The default value is zero. The value should be non-negative.

This property is only sensible when the alignment is AlignmentStart or AlignmentEnd. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node. This sets the alternateDefaults' property of the same name.

alternateNodeIndentPastParent
{number}

Gets or sets the fraction of this node's breadth is added to nodeIndent to determine any spacing at the start of the children.More...

The default value is 0.0 -- the only indentation is specified by nodeIndent. When the value is 1.0, the children will be indented past the breadth of the parent node.

This property is only sensible when the alignment is AlignmentStart or AlignmentEnd. This sets the alternateDefaults' property of the same name.

alternateNodeSpacing {number} | Gets or sets the alternate distance between child nodes.More... The default value is 20. A negative value causes sibling nodes to overlap. This sets the alternateDefaults' property of the same name.

alternatePortSpot
{Spot}

Gets or sets the alternate spot that this node's port gets as its FromSpot.More...

The default value is Spot.Default.

A value of Spot.Default will cause the TreeLayout to assign a FromSpot based on the parent node's TreeVertex.angle. If the value is other than NoSpot, it is just assigned. When path is PathSource, the port's ToSpot is set instead of the FromSpot. This sets the alternateDefaults' property of the same name.

alternateRowIndent {number} | Gets or sets the alternate indentation of the first child of each row, if the alignment is not a "Center" alignment.More... The default value is 10. The value should be non-negative. This is used to leave room for the links that connect a parent node with the child nodes that are in additional rows. This sets the alternateDefaults' property of the same name.
alternateRowSpacing {number} | Gets or sets the alternate distance between rows of children.More... The default value is 25. This property is only used when there is more than one row of children for a given parent node. layerSpacing determines the distance between the parent node and its first row of child nodes. This sets the alternateDefaults' property of the same name.
alternateSetsChildPortSpot {boolean} | Gets or sets whether the TreeLayout should set the ToSpot for each child node port.More... The default value is true -- this may modify the spot of the ports of the children nodes, if the node has only a single port. The spot used depends on the value of childPortSpot. This sets the alternateDefaults' property of the same name.
alternateSetsPortSpot {boolean} | Gets or sets whether the TreeLayout should set the FromSpot for this parent node port.More... The default value is true -- this may modify the spot of the port of this node, the parent, if the node has only a single port. The spot used depends on the value of portSpot. This sets the alternateDefaults' property of the same name.

alternateSorting
{EnumValue}

Gets or sets the alternate sorting policy for ordering the immediate children of a vertex.More... Must be TreeLayout.SortingForwards, TreeLayout.SortingReverse, TreeLayout.SortingAscending, or TreeLayout.SortingDescending.

The default value is SortingForwards.

This sets the alternateDefaults' property of the same name. The sort order is determined by alternateComparer.

angle {number} | Gets or sets the default direction for tree growth.More... The default value is 0; the value must be one of: 0, 90, 180, 270. These values are in degrees, where 0 is along the positive X axis, and where 90 is along the positive Y axis. This sets the rootDefaults' property of the same name.
arrangement {EnumValue} | Gets or sets how arrangeTrees should lay out the separate trees.More... Must be TreeLayout.ArrangementVertical, TreeLayout.ArrangementHorizontal, or TreeLayout.ArrangementFixedRoots. The default value is TreeLayout.ArrangementVertical
arrangementSpacing {Size} | Gets or sets the space between which arrangeTrees will position the trees.More... This defaults to the Size(10, 10). This property is ignored if arrangement is TreeLayout.ArrangementFixedRoots.

breadthLimit
{number}

Gets or sets a limit on how broad a tree should be.More...

A value of zero (the default) means there is no limit; a positive value specifies a limit. The default value is zero.

This property is just a suggested constraint on how broadly the tree will be laid out. When there isn't enough breadth for all of the children of a node, the children are placed in as many rows as needed to try to stay within the given breadth limit. If the value is too small, since this layout algorithm does not modify the size or shape of any node, the nodes will just be laid out in a line, one per row, and the breadth is determined by the broadest node. The distance between rows is specified by rowSpacing. To make room for the links that go around earlier rows to get to later rows, when the alignment is not a "center" alignment, the rowIndent property specifies that space at the start of each row. This sets the rootDefaults' property of the same name.

childPortSpot
{Spot}

Gets or sets the spot that children nodes' ports get as their ToSpot.More...

The default value is Spot.Default.

A value of Spot.Default will cause the TreeLayout to assign a ToSpot based on the parent node's TreeVertex.angle. If the value is other than NoSpot, it is just assigned. When path is PathSource, the port's FromSpot is set instead of the ToSpot. This sets the rootDefaults' property of the same name.

commentMargin {number} | Gets or sets the distance between a node and its comments.More... The default value is 20. This is used by addComments and layoutComments. This sets the rootDefaults' property of the same name.
comments {boolean} 1.3 | Gets or sets whether this layout should find all Nodes whose category is "Comment" and whose anchors are nodes represented in the network, and increase the size of the corresponding TreeVertex to make room for the comment nodes.More... The default value is true.
commentSpacing {number} | Gets or sets the distance between comments.More... The default value is 10. This is used by addComments and layoutComments. This sets the rootDefaults' property of the same name.
compaction {EnumValue} | Gets or sets how closely to pack the child nodes of a subtree.More... Must be either TreeLayout.CompactionBlock or TreeLayout.CompactionNone. The default value is CompactionBlock. This sets the rootDefaults' property of the same name.
comparer {function(TreeVertex, TreeVertex):number} | Gets or sets the default comparison function used for sorting the immediate children of a vertex.More... The default comparer compares the LayoutVertex.node Text values. This sets the rootDefaults' property of the same name. Whether this comparison function is used is determined by the value of sorting.

layerSpacing
{number}

Gets or sets the distance between a parent node and its children.More...

The default value is 50.

This is the distance between a parent node and its first row of children, in case there are multiple rows of its children. The rowSpacing property determines the distance between rows of children. Negative values may cause children to overlap with the parent. This sets the rootDefaults' property of the same name.

layerSpacingParentOverlap
{number}

Gets or sets the fraction of the node's depth for which the children's layer starts overlapped with the parent's layer.More...

The default value is 0.0 -- there is overlap between layers only if layerSpacing is negative. A value of 1.0 and a zero layerSpacing will cause child nodes to completely overlap the parent.

A value greater than zero may still cause overlap between layers, unless the value of layerSpacing is large enough. A value of zero might still allow overlap between layers, if layerSpacing is negative. This sets the rootDefaults' property of the same name.

layerStyle {EnumValue} 1.4 | Gets or sets the manner in which the nodes are aligned in layers.More... Must be TreeLayout.LayerIndividual, TreeLayout.LayerSiblings, or TreeLayout.LayerUniform. The default value is TreeLayout.LayerIndividual.

nodeIndent
{number}

Gets or sets the default indentation of the first child.More...

The default value is zero. The value should be non-negative.

This property is only sensible when the alignment is AlignmentStart or AlignmentEnd. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node. This sets the rootDefaults' property of the same name.

nodeIndentPastParent
{number}

Gets or sets the fraction of this node's breadth is added to nodeIndent to determine any spacing at the start of the children.More...

The default value is 0.0 -- the only indentation is specified by nodeIndent. When the value is 1.0, the children will be indented past the breadth of the parent node.

This property is only sensible when the alignment is AlignmentStart or AlignmentEnd. This sets the rootDefaults' property of the same name.

nodeSpacing {number} | Gets or sets the distance between child nodes.More... The default value is 20. A negative value causes sibling nodes to overlap. This sets the rootDefaults' property of the same name.
path {EnumValue} | Gets or sets how the tree should be constructed from the TreeEdges connecting TreeVertexes.More... Must be TreeLayout.PathDestination or TreeLayout.PathSource or TreeLayout.PathDefault. The default value is TreeLayout.PathDefault, where the value of Diagram.isTreePathToChildren determines the effective value of this property.

portSpot
{Spot}

Gets or sets the spot that this node's port gets as its FromSpot.More...

The default value is Spot.Default.

A value of Spot.Default will cause the TreeLayout to assign a FromSpot based on the parent node's TreeVertex.angle. If the value is other than NoSpot, it is just assigned. When path is PathSource, the port's ToSpot is set instead of the FromSpot. This sets the rootDefaults' property of the same name.

rootDefaults
{TreeVertex}

Gets or sets the object holding the default values for root TreeVertexes.More...

The values for the following inheritable properties are actually stored in this object: sorting, comparer, angle, alignment, nodeIndent, nodeIndentPastParent, nodeSpacing, layerSpacing, layerSpacingParentOverlap, compaction, breadthLimit, rowSpacing, rowIndent, commentSpacing, commentMargin, setsPortSpot, portSpot, setsChildPortSpot, childPortSpot. The other properties of this TreeVertex are ignored.

roots {Set.<(TreeVertex|Node)>} | Gets or sets the collection of root vertexes.More... Initially this will be an empty Set. If the path is either PathDestination or PathSource, this layout can easily determine all of the tree roots by searching the whole network. Otherwise, you should explicitly initialize this collection with one or more TreeVertexes.
rowIndent {number} | Gets or sets the default indentation of the first child of each row, if the alignment is not a "Center" alignment.More... The default value is 10. The value should be non-negative. This is used to leave room for the links that connect a parent node with the child nodes that are in additional rows. This sets the rootDefaults' property of the same name.
rowSpacing {number} | Gets or sets the distance between rows of children.More... The default value is 25. This property is only used when there is more than one row of children for a given parent node. layerSpacing determines the distance between the parent node and its first row of child nodes. This sets the rootDefaults' property of the same name.
setsChildPortSpot {boolean} | Gets or sets whether the TreeLayout should set the ToSpot for each child node port.More... The default value is true -- this may modify the spot of the ports of the children nodes, if the node has only a single port. The spot used depends on the value of childPortSpot. This sets the rootDefaults' property of the same name.
setsPortSpot {boolean} | Gets or sets whether the TreeLayout should set the FromSpot for this parent node port.More... The default value is true -- this may modify the spot of the port of this node, the parent, if the node has only a single port. The spot used depends on the value of portSpot. This sets the rootDefaults' property of the same name.
sorting {EnumValue} | Gets or sets the default sorting policy for ordering the immediate children of a vertex.More... Must be TreeLayout.SortingForwards, TreeLayout.SortingReverse, TreeLayout.SortingAscending, or TreeLayout.SortingDescending. The default value is TreeLayout.SortingForwards. This sets the rootDefaults' property of the same name. The sort order is determined by comparer.
treeStyle {EnumValue} | Gets or sets the Style for the resulting trees.More... Must be TreeLayout.StyleLayered, TreeLayout.StyleAlternating, TreeLayout.StyleLastParents, or TreeLayout.StyleRootOnly. The default value is TreeLayout.StyleLayered.

Properties borrowed from class Layout:
  arrangementOrigin, diagram, group, isInitial, isOngoing, isRealtime, isRouting, isValidLayout, isViewportSized, network

## Method Summary Details

Name, Return Type | Description
--- | ---

addComments(v)
1.2

Find any associated objects to be positioned along with the LayoutVertex.node.More...

This looks for visible Node's whose category is "Comment" and that refer to the tree vertex's Node. This method is only called when comments is true.

You may want to override this method in order to customize how any associated objects are found and how the node's LayoutVertex.bounds are set to reserve space for those associated objects. This method should not walk the tree, since it is called for each TreeVertex in an indeterminate order. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{TreeVertex} v

arrangeTrees() 1.2 | Position each separate tree.More... This is called after each tree has been laid out and thus each subtree bounds are known. The arrangement and arrangementSpacing and Layout.arrangementOrigin properties affect this method's behavior. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

assignTreeVertexValues(v)
1.1

Assign final property values for a TreeVertex.More...

This method is commonly overridden in order to provide tree layout properties for particular nodes. This method is called after values have been inherited from other TreeVertexes, so you can examine and modify the values of related tree nodes. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

However, when TreeVertex.alignment is TreeLayout.AlignmentBusBranching, changing the TreeVertex.sorting or TreeVertex.comparer properties in this method will have no effect.

This method should not walk the tree, since it is called for each TreeVertex in a depth-first manner starting at a root.

Here is an example where the children are squeezed together if there are many of them, but only on nodes that have no grandchildren. This makes use of two TreeVertex properties that are automatically computed for you, TreeVertex.childrenCount and TreeVertex.descendantCount.

      function SqueezingTreeLayout() {
        go.TreeLayout.call(this);
      }
      go.Diagram.inherit(SqueezingTreeLayout, go.TreeLayout);

      SqueezingTreeLayout.prototype.assignTreeVertexValues = function(v) {
        if (v.childrenCount > 6 && v.childrenCount === v.descendantCount) {
          v.alignment = go.TreeLayout.AlignmentBottomRightBus;
          v.layerSpacing = 10;
          v.rowSpacing = 0;
        }
      };

If you need to assign TreeVertex values and also have them be "inherited" by the child vertexes, you should override initializeTreeVertexValues instead. However at the time that method is called, the computed properties of TreeVertex will not be available.

Parameters:
{TreeVertex} v

commitLayers(layerRects, offset)
1.4

This overridable method is called by commitLayout if layerStyle is LayerUniform to support custom arrangement of bands or labels across each layout layer.More... By default this method does nothing.

The coordinates used in the resulting Rects may need to be offset by the Layout.arrangementOrigin and/or by the arrangement of subtrees done by arrangeTrees.

Parameters:
{Array.<Rect>} layerRects
  an Array of Rects with the bounds of each of the "layers"
{Point} offset
  the position of the top-left corner of the banded area relative to the coordinates given by the layerRects

commitLayout()

Set the fromSpot and toSpot on each Link, position each Node according to the vertex position, and then position/route the Links.More...

This calls the commitNodes and commitLinks methods, the latter only if isRouting is true. You should not call this method -- it is a "protected virtual" method. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

commitLinks() | Routes the links.More... This is called by commitLayout. This is only called if Layout.isRouting is true. See also commitNodes. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
commitNodes() | Commit the position of all nodes.More... This is called by commitLayout. See also commitLinks. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

createNetwork()
{LayoutNetwork}

Create a new LayoutNetwork of TreeVertexes and TreeEdges.

Returns:
{LayoutNetwork} a new LayoutNetwork.

doLayout(coll)

Perform the tree layout.More...

If there is no Layout.network, this calls makeNetwork to create a TreeNetwork from the given collection of Parts.

If there are no TreeVertex roots specified, this finds all roots in the Layout.network.

This initializes all of the TreeVertexes and TreeEdges, calling initializeTreeVertexValues on each vertex, supporting inheritance of vertex values. Then it calls assignTreeVertexValues on each one, to allow for node/vertex-specific customizations. Next it sorts all of the child vertexes for each parent vertex, if needed.

This also calls addComments of each vertex, in order to find any comment nodes associated with each vertex, so that they can be accommodated by the layout.

This then actually does the "layout" of the vertexes and optionally the routing of the edges of each tree in the network. To deal with multiple roots/trees this also calls arrangeTrees to position each separate tree relative to each other.

Finally this calls Layout.updateParts to commit the Node positions from the vertex positions and the Link routes from the edges. Layout.updateParts calls commitLayout within a transaction.

Parameters:
{Diagram|Group|Iterable.<Part>} coll
  A Diagram or a Group or a collection of Parts.

initializeTreeVertexValues(v)
1.2

Assign initial property values for a TreeVertex.More...

The values may be inherited, so this method is called while propagating values from the root nodes. This method should not walk the tree, since it is called for each TreeVertex in a depth-first manner starting at a root.

You probably do not need to override this method, but if you do you should call first either the base method or TreeVertex.copyInheritedPropertiesFrom, since they assign most of the TreeVertex property values used to influence the layout. Informational properties such as TreeVertex.descendantCount and TreeVertex.maxGenerationCount will not yet have been initialized by the time this method is called. It is more common to override assignTreeVertexValues in order to modify a property or two to customize the layout at that node. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

When the TreeVertex.alignment is TreeLayout.AlignmentBusBranching, this will modify the TreeVertex.angle appropriately depending on which side of the bus the vertex is on.

Parameters:
{TreeVertex} v

layoutComments(v)
1.2

Position and TreeVertex.comments around the vertex.More...

This method should not walk the tree, since it is called for each TreeVertex in an indeterminate order. Please read the Introduction page on Extensions for how to override methods and how to call this base method.

Parameters:
{TreeVertex} v

makeNetwork(coll)
{LayoutNetwork}

Create and initialize a TreeNetwork with the given nodes and links.More...

This does not include any nodes of category "Comment". Comment nodes are added by the addComments method.

Parameters:
{Diagram|Group|Iterable.<Part>} coll
  A Diagram or a Group or a collection of Parts.

Returns:
{LayoutNetwork}

Methods borrowed from class Layout:
  cloneProtected, copy, invalidateLayout, updateParts

## Constants Summary Details

Name | Description
--- | ---
AlignmentBottomRightBus {EnumValue} | The children are positioned in a bus, only on the bottom or right side of the parent; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment; A bus does not take TreeVertex.breadthLimit into account.

AlignmentBus {EnumValue}

The children are positioned in a bus on both sides of an "aisle" where the links to them go, with the last odd child (if any) placed at the end of the aisle in the middle; The children, if they are themselves parents, continue at the same inherited angle; use TreeLayout.AlignmentBusBranching if you want grandchildren to proceed growing in the different angle as determined by the side; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment.More... A bus does not take TreeVertex.breadthLimit into account.

AlignmentBusBranching {EnumValue}

Like TreeLayout.AlignmentBus with the children arranged on both sides of an "aisle" with any last odd child placed at the end of the aisle, but the children get an TreeVertex.angle that depends on which side of the aisle they were placed; This only works well when the TreeLayout.treeStyle is TreeLayout.StyleLayered; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment; A bus does not take TreeVertex.breadthLimit into account.

AlignmentCenterChildren {EnumValue} | The parent is centered at the middle of the range of its immediate child nodes; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment; When there is a breadth limit that causes there to be multiple rows, the links that extend from the parent to those children in rows past the first one may cross over the nodes that are in earlier rows.
AlignmentCenterSubtrees {EnumValue} | The parent is centered at the middle of the range of its child subtrees; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment; When there is a breadth limit that causes there to be multiple rows, the links that extend from the parent to those children in rows past the first one may cross over the nodes that are in earlier rows.
AlignmentEnd {EnumValue} | The parent is positioned near the last of its children; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment.
AlignmentStart {EnumValue} | The parent is positioned near the first of its children; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment.
AlignmentTopLeftBus {EnumValue} | The children are positioned in a bus, only on the top or left side of the parent; This value is used for TreeLayout.alignment or TreeLayout.alternateAlignment; A bus does not take TreeVertex.breadthLimit into account.
ArrangementFixedRoots {EnumValue} | Do not move each root node, but position all of their descendants relative to their root; This value is used for TreeLayout.arrangement.
ArrangementHorizontal {EnumValue} | Position each tree in a non-overlapping fashion by increasing X coordinates, starting at the Layout.arrangementOrigin; This value is used for TreeLayout.arrangement.
ArrangementVertical {EnumValue} | Position each tree in a non-overlapping fashion by increasing Y coordinates, starting at the Layout.arrangementOrigin; This value is used for TreeLayout.arrangement.

CompactionBlock {EnumValue}

A simple fitting of subtrees; This value is used for TreeLayout.compaction or TreeLayout.alternateCompaction; This mode produces more compact trees -- often nicer looking too; Nodes will not overlap each other, unless you have negative values for some of the spacing properties; However it is possible when the links are orthogonally styled that occasionally the subtrees will be placed so close together that some links may overlap the links or even the nodes of other subtrees.

CompactionNone {EnumValue}

Only simple placement of children next to each other, as determined by their subtree breadth; This value is used for TreeLayout.compaction or TreeLayout.alternateCompaction; For any node, there will not be another node at any depth occupying the same breadth position, unless there are multiple rows; In other words, if there is no breadth limit resulting in multiple rows, with this compaction mode it is as if every node were infinitely deep.

LayerIndividual 1.4 {EnumValue} | The normal layer style, where each node takes up only the depth that it needs; this value is used for TreeLayout.layerStyle.
LayerSiblings 1.4 {EnumValue} | A layer style where all of the children of a parent node take up the same amount of depth -- this typically causes all cousins to be aligned; this value is used for TreeLayout.layerStyle.
LayerUniform 1.4 {EnumValue} | A layer style where all nodes with the same TreeVertex.level throughout the tree take up the same amount of depth -- if the TreeVertex.angle is the same for all nodes, this will result in all nodes in the same layer to be aligned; this value is used for TreeLayout.layerStyle.
PathDefault {EnumValue} | This value for TreeLayout.path causes the value of Diagram.isTreePathToChildren to effectively choose either TreeLayout.PathDestination (if true) or TreeLayout.PathSource (if false).
PathDestination {EnumValue} | The children of a TreeVertex are its LayoutVertex.destinationVertexes, the collection of connected LayoutEdge.toVertexes; This value is used for TreeLayout.path; The tree roots are those TreeVertexes that have zero source edges}.
PathSource {EnumValue} | The children of a TreeVertex are its LayoutVertex.sourceVertexes, the collection of connected LayoutEdge.fromVertexes; This value is used for TreeLayout.path; The tree roots are those TreeVertexes that have zero destination edges.
SortingAscending {EnumValue} | Lay out each child according to the sort order given by TreeVertex.comparer; This value is used for TreeLayout.sorting or TreeLayout.alternateSorting.
SortingDescending {EnumValue} | Lay out each child in reverse sort order given by TreeVertex.comparer; This value is used for TreeLayout.sorting or TreeLayout.alternateSorting.
SortingForwards {EnumValue} | Lay out each child in the order in which they were found; This value is used for TreeLayout.sorting or TreeLayout.alternateSorting.
SortingReverse {EnumValue} | Lay out each child in reverse order from which they were found; This value is used for TreeLayout.sorting or TreeLayout.alternateSorting.

StyleAlternating {EnumValue}

Alternate layers of the tree have different properties, typically including the angle; This value is used for TreeLayout.treeStyle; Each TreeVertex gets its properties from its grandparent node; The root nodes get their defaults from TreeLayout.rootDefaults; the immediate children of root nodes get their defaults from TreeLayout.alternateDefaults; Depending on the properties used, it is possible for some link routes to cross over nodes.

StyleLastParents {EnumValue}

Just like the standard layered tree style, except that the nodes with children but no grandchildren have alternate properties; This value is used for TreeLayout.treeStyle; Each TreeVertex gets its properties from its parent node; However, for those nodes whose TreeVertex.maxGenerationCount is 1, in other words when it has children but no grandchildren, the properties are copied from TreeLayout.alternateDefaults; If the tree only has two levels, the root node gets the TreeLayout.rootDefaults.

StyleLayered {EnumValue} | The normal tree style, where all of the children of each TreeVertex are lined up horizontally or vertically; This value is used for TreeLayout.treeStyle; Each TreeVertex gets its properties from its parent node; TreeLayout.rootDefaults is used for all default TreeVertex property values; TreeLayout.alternateDefaults is ignored.
StyleRootOnly {EnumValue} | All of the nodes get the alternate properties, except the root node gets the default properties; This value is used for TreeLayout.treeStyle; The root node gets the TreeLayout.rootDefaults properties, the root node's children get the TreeLayout.alternateDefaults properties, and all the rest of the TreeVertexes get their properties from their parent node.