Layer Constraints Demo
Shows how to use layer constraints to restrict the node layering in
HierarchicalLayout.
The layer is determined by the model data.
A weight property determines the position of the node. Higher weights will force
a placement closer to the bottom. The weight is indicated by the number on the node and
its background color. A darker color indicates a low weight, a brighter color a high
weight. Red and green indicate that the node will be forced at the first or last position,
respectively.
The weight can be changed using the buttons on each node.
A weighted property, controlled by the Constraints button, determines
whether the node should be constrained at all.
Things to Try
- Change the weight of the nodes using the buttons on the each node.
- Disable the layer constraints for a node by unchecking the constraints button.
- Run a layout to see how the layer constraints affect the layout.
- Create a new random graph with the New Graph button.
-
Clicking on activates the constraints
for each node.
-
Clicking on in the toolbar removes
all constraints from the nodes. In this case, integral values between 1 and 100 can be
assigned as labels to the edges using the F2 key. These values will be
interpreted as edge weights during the assignment of the layers. Higher values indicate
higher importance. The algorithm tries to minimize the lengths of important edges. Thus,
assigning higher edge label values will lead to the adjacent nodes coming closer
together with respect to their layering. Although it is possible to assign weights to
edges between nodes that have active constraints, constraints always have priority and
thus, the result won't be visible as easy.