An alternative way to force a group of nodes to be at
the same level is by specifying a group spread constraint with a spread
size of zero (0). In general, the group spread constraint forces a
group of nodes to k+1 subsequent
levels. The number k is
the spread size. It does not select the lowest or highest level index
of the group, but requires only that the nodes are placed no more
than k levels apart.
Hence, if k=0, all
nodes of the group are placed at the same level.
To illustrate the general group spread constraint on
nodes with ID “nodeA’, “nodeB” and “nodeC”:
To use the group spread constraint call:
var nodeGroup = new ibm_ilog.graphlayout.hierarchical.HierarchicalNodeGroup(); nodeGroup.add(nodeA); nodeGroup.add(nodeB); nodeGroup.add(nodeC); layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalGroupSpreadConstraint(nodeGroup, 2));
The constraint is satisfied if the highest level index
for
nodeA
, nodeB
,
and nodeC
is no more than two levels apart
from the smallest level index of the nodes. For instance, the constraint
is satisfied if the level indexes for nodeA
, nodeB
,
and nodeC
are 1, 2, 3; or if they are 7,
8, 9; or if they are 16, 14, 15. The constraint is also satisfied
if all three nodes are placed at level 5, or if two of the nodes are
placed at level 15 and the third node at level 13. The constraint
is not satisfied if the level indexes for nodeA
, nodeB
,
and nodeC
are 3, 5, 6, because in this
case the highest index (6) is more than two levels away from the lowest
index (3).