The level index is a special case of a level range constraint
(see Level range constraints (HL)). It forces
the node to one particular level. For your convenience, you can specify
the level index of a node directly by the method:
layout.setSpecNodeLevelIndex(node, 2);
You pass a single node as the first argument (not a node
group). The default index value is
-1
.
If the default value is used, or if a node is set to a negative level
index, the level index is considered to be unspecified. In this case
the layout algorithm automatically calculates an appropriate level
index during the leveling phase of the algorithm. To obtain the specified level index for a node, use the
method:
var index = getSpecNodeLevelIndex(node);
However, this method returns the value that was set by
setSpecNodeLevelIndex
.
If the level index was specified by allocating a corresponding level
range constraint that has the same meaning, getSpecNodeLevelIndex
still
returns -1
. Warning
Using arbitrarily large level indexes is not recommended.
For instance, if you set the level index of a node to
100000
,
the layout algorithm creates 100,000 levels even if the graph has
far fewer nodes. It causes the layout algorithm to become slow.