Constraint priorities (HL)

A set of constraints may cause conflicts. This means that not all of the constraints can be satisfied at the same time. For instance, it is impossible to force two nodes into the same level by an ibm_ilog.graphlayout.hierarchical.HierarchicalSameLevelConstraint while at the same time forcing one of the nodes to a higher level than the other node by an ibm_ilog.graphlayout.hierarchical.HierarchicalRelativeLevelConstraint. In this case, one of the two constraints must be ignored during layout.
In general, constraint conflicts are resolved by ignoring the constraints with the lowest priority while the constraints with the highest priority get satisfied. The following rules explain the constraint priorities in detail.
  • The constraints that influence the level into which a node is placed are applied before the constraints that influence the position of the node within a level.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalExtremityConstraint is translated into a sequence of constraints with high priority.
    For instance, the extremity constraint with the south side is translated into several same level constraints and several relative level constraints.
  • They are never in conflict with each other. They dominate all other constraints, even the specified level index.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalLevelRangeConstraint (and the direct level index specification) has the second highest priority.
    If two nodes are forced to the same level but have disjoint specified level ranges, then the level range is ignored. In the following example:
    layout.addConstraint(new ibm_ilog.graphlayout.hierarchical.HierarchicalSameLevelConstraint(node1,node2));
    layout.setSpecNodeLevelIndex(node1, 5);
    layout.setSpecNodeLevelIndex(node2, 10);
    
    both node1 and node2 are placed at level 5. The conflicting specification: layout.setSpecNodeLevelIndex(node2, 10) is ignored.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalRelativeLevelConstraint is dominated by the same level constraint, by the level range constraint, and by the direct specification of level indexes.
    If several relative level constraints conflict with each other, the one with the highest specified priority dominates. However, all links are implicitly considered relative level constraints as well. If links with high priority force a node to a certain level, then a relative level constraint with lower priority is ignored.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalSwimLaneConstraint is always evaluated, even if the incremental mode is enabled.
    The constraint has a higher priority than the relative position constraint and the side-by-side constraint. You can specify side-by-side constraints for a group of nodes that belong to the same swimlane, but side-by-side constraints of nodes of different swimlanes are ignored. You can specify relative position constraints between nodes of the same swimlane. You can also specify relative position constraints between one entire swimlane group and another swimlane group, which effectively orders the swimlanes. But relative position constraints are ignored if they would require breaking the swimlanes apart. The swimlane constraint dominates the specified position indexes and the extremity constraints, that is, if a swimlane constraint is used, you cannot specify position indexes or east/west extremity constraints for any node.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalSideBySideConstraint is evaluated only if the corresponding nodes belong to the same level.
    Typically you use a same level constraint to force the nodes to the same level, and then a side-by-side constraint to force the nodes to a certain ordering. The side-by-side constraints dominate the relative position constraints. If several side-by-side constraints are conflicting, the one with the highest specified priority dominates the other constraints.
  • The ibm_ilog.graphlayout.hierarchical.HierarchicalLayout.HierarchicalRelativePositionConstraint is also evaluated only if the corresponding nodes belong to the same level.
    It is dominated by the side-by-side constraint; however, conflicts with side-by-side constraints are rare. If several relative position constraints are conflicting, the one with the highest specified priority dominates the other constraints.