ELK Rectangle Packing

Property Value
Identifier: org.eclipse.elk.rectpacking
Meta Data Provider: options.RectPackingMetaDataProvider


Algorithm for packing of unconnected boxes, i.e. graphs without edges. The given order of the boxes is always preserved and the main reading direction of the boxes is left to right. The algorithm is divided into two phases. One phase approximates the width in which the rectangles can be placed. The next phase places the rectangles in rows using the previously calculated width as bounding width and bundles rectangles with a similar height in blocks. A compaction step reduces the size of the drawing. Finally, the rectangles are expanded to fill their bounding box and eliminate empty unused spaces.

Additional Documentation

The different phases of the algorithm are illustrated below on an example:

First the drawing width is approximated. Such a drawing can look like this:

After this the initial drawing is created:

This drawing is then compacted to use less space:

Now the nodes can be either expanded to fill the bounding box:

Or, the nodes can be expanded to fit the aspect ratio.

Supported Options

Option Default Value
Aspect Ratio 1.3
Compaction iterations 1
Compaction Strategy PackingStrategy.COMPACTION
Content Alignment ContentAlignment.topLeft()
Current position of a node in the order of nodes -1
Desired index of node -1
Fixed Graph Size false
In new Row false
Interactive false
interactive Layout false
Node Label Placement NodeLabelPlacement.fixed()
Node Size Constraints EnumSet.noneOf(SizeConstraint)
Node Size Minimum new KVector(0, 0)
Node Size Options EnumSet.of(SizeOptions.DEFAULT_MINIMUM_SIZE)
Node Spacing 15
Omit Node Micro Layout false
Optimization Goal OptimizationGoal.MAX_SCALE_DRIVEN
Padding new ElkPadding(15)
Port Label Placement PortLabelPlacement.outside()
Row Height Reevaluation false
Shift Last Placed. true
Target Width -1
Try box layout first false
White Space Approximation Strategy <not defined>
Width Approximation Strategy WidthApproximationStrategy.GREEDY