Compact Disk Layout
The CompactDiskLayout is a layout algorithm that arranges the graph’s nodes on a disk, optimizing the compactness of the placement. Sample layout without edges showcases the most compact settings of the CompactDiskLayout. The layout arranges nodes so that nodes of the same connected component lie closely together, as shown in Sample layout with small connected components. The compact placement of the nodes makes this layout style most suitable for graphs that consist of multiple components, each having a small number of edges. In particular, it is suitable for graphs with one main path and a few other edges that only connect nodes that lie closely together on that path. Moreover, the layout is optimized for nodes that are represented by uniform circles, which admits a strongly compact packing of the nodes.


Minimum Node Distance
Minimal Node Distance

The compactness of the layout can be controlled using the minimum distance between nodes; see Sample layout with minimum node distance. The distance is measured between the boundaries of the nodes. To achieve a particularly dense packing of the nodes, the layout algorithm makes assumptions about the shape of the nodes. By default, the layout algorithm assumes the nodes are circles. Each circle is assumed to have the same center as its node and a radius equal to half the node’s width or height, whichever is greater.
This assumption can lead to overlapping nodes when using non-circular nodes; see Sample layout with partly overlapping rectangular nodes.

To prevent non-circular nodes from overlapping, you can relax this assumption by providing the layout algorithm with nodeMargins. In that case, the layout algorithm approximates the boundary of each node that has a node margin with a sufficiently large circle. This circle is the circumcircle of the bounding box that contains the node as well as its margins.
To activate this relaxation for a node, it is sufficient to add margins of size 0.
From-Sketch

- fromSketchMode
- Enables the "from-sketch" layout.
Node Types
The CompactDiskLayout automatically considers nodeTypes if they are declared. In that case, the connected components are ignored, and the nodes are placed with respect to their node types. Nodes of the same type are placed together, as shown in Node type sample layout.

Node Margins
The CompactDiskLayout automatically considers node margins if they are declared. As described in Section Minimum Node Distance, defining node margins for a particular node causes the layout algorithm to assume a rough approximation of the node’s boundary. This approximation is the circumcircle of the bounding box that contains the node and its margins. This may lead to reduced compactness of the overall layout, but guarantees that there will be no overlaps between nodes or their margins.
Labeling
Edge labels can be placed automatically using the generic labeling support as described in Generic Labeling, which is available with all yFiles layout algorithms. Additionally, the layout algorithm can be set up to take node labels into account during layout. This integrated labeling can be enabled using the following property; see also Integrated Labeling.
Enabling the integrated node labeling support of the CompactDiskLayout ensures that the calculated layout avoids overlaps between labels and between labels and nodes. The CompactDiskLayout supports the following integrated node labeling policies:
- RadialNodeLabelPlacement.HORIZONTAL
- Each node label is placed with its center at the center of its node, with the label oriented horizontally. Multiple node labels will be placed center-aligned and stacked.

- RadialNodeLabelPlacement.RAY_LIKE
- The label of a node is placed on the ray that emanates from the disk’s center and passes through the center of the node. The label is rotated to align with the ray. If the node lies at the boundary of the disk, the label’s distance from the disk’s center is set so it lies outside the disk and touches the node’s boundary. If the node does not lie at the boundary of the disk, the center of the label coincides with the center of the node.In case that a node has multiple labels, these labels are stacked on top of each other, effectively forming a multi-line label.

- RadialNodeLabelPlacement.RAY_LIKE_LEAVES
- The labels are placed in the same way as RAY_LIKE, except that the labels of nodes that do not lie at the boundary of the disk are placed horizontally.In case that a node has multiple labels, these labels are stacked on top of each other, effectively forming a multi-line label.

Note that ray-like labels are only supported for node labels that use a "free" label model, e.g., FreeNodeLabelModel.