The HL algorithm

A brief description of the HL algorithm

This algorithm works in four steps:
Step 1: Leveling
The nodes are partitioned into groups. Each group of nodes forms a level. The objective is to group the nodes in such a way that the links always point from a level with smaller index to a level with larger index.
Step 2: Crossing reduction
The nodes are sorted within each level. The algorithm tries to keep the number of link crossings small when, for each level, the nodes are placed in this order on a line (see Level and position indexes). This ordering results in the relative position index of each node within its level.
Step 3: Node positioning
From the level indexes and position indexes, balanced coordinates for the nodes are calculated. For instance, for a layout where the link flow is from top to bottom, the nodes are placed along horizontal lines such that all nodes belonging to the same level have (approximately) the same y-coordinate. The nodes of a level with a smaller index have a smaller y-coordinate than the nodes of a level with a higher index. Within a level, the nodes with a smaller position index have a smaller x-coordinate than the nodes with a higher position index.
Step 4: Link routing
The shapes of the links are calculated such that the links bypass the nodes at the level lines. In many cases, it requires that a bend point is created whenever a link needs to cross a level line. In a top-to-bottom layout, these bend points have the same y-coordinate as the level line they cross. (These bend points also obtain a position index).
Level and position indexes shows how the Hierarchical Layout algorithm uses the level and position indexes to draw the graph.
Diagram
showing level and position indexes in a hierarchical layout
Level and position indexes
You can set parameters for the steps of the layout algorithm in several ways. For instance, you can specify the level index that the algorithm must choose for a node in Step 1 or the relative node position within the level in Step 2. You can also specify the justification of the nodes within a level and the style of the link shapes.

Example of HL

The following code sample shows how to perform a Hierarchical Layout:
var layout = new ibm_ilog.graphlayout.hierarchical.HierarchicalLayout();
graph.setNodeLayout(layout);
graph.performGraphLayout();