This layout algorithm arranges a graph on a disk packing the nodes as dense as possible.
Remarks
Layout Style
The nodes are arranged on a disk such that the disk's radius is minimized. The layout mostly optimizes the dense placement of the nodes, while edges play a minor role. Hence, the compact disk layout is mostly suitable for graphs with small components whose loosely connected nodes should be grouped and packed in a small area.
Concept
The CompactDiskLayout arranges the nodes on a disk from the inside out packing them as dense as possible. During this iterative process it avoids node overlaps and label overlaps (if activated; see nodeLabelPlacement). In particular, to keep the layout compact the CompactDiskLayout may decide to place a single node or multiple nodes in the center of the disk.
Features
Connected Components
By default, the CompactDiskLayout takes the connected components for the placement of the nodes into account. In that case the nodes of the same component are placed sequentially in the iterative placement process ensuring that they form a visual component.Node Types
If nodeTypes are defined, the CompactDiskLayout takes these into account instead of the connected components. In particular, nodes of the same type are placed closely together forming a visual component.From Sketch
Use fromSketchMode to take the coordinates of the input diagram into account when arranging the nodes on the disk.Node Labeling
The CompactDiskLayout allows for integrated node labeling. Node labels are placed automatically without generating overlaps with other labels or graph elements.Port Placement Constraints
This layout algorithm handles port placement constraints by applying the PortPlacementStage as a postprocessing step.
Layout Stages
This class provides a configurable pipeline that contains various ILayoutStages. Each ILayoutStage can incorporate preprocessing or postprocessing steps into the layout calculation to streamline the input graph and enhance the resulting layout. Additionally, custom ILayoutStages can be added and executed either before or after the predefined ones.
The following default ILayoutStages are included:
- PortPlacementStage: Assigns edges to ports.
- GroupHidingStage: Removes group nodes and their adjacent edges before layout processing, and reinserts them afterward.
- ComponentLayout: Arranges graph components with customizable styles. Note: This stage is disabled by default.
- GenericLabeling: Efficiently places node and edge labels. The property fillEmptyScope is set to
false
and stopDuration is set to ZERO. - SelfLoopRouter: Routes self-loops in a graph, allowing for either orthogonal or rounded routing styles. The property routingStyle is set to ROUNDED.
- ParallelEdgeRouter: Routes multiple edges between the same nodes in parallel.
With these layoutStages the layout algorithm is configured well, so they usually don't need to be changed.
Default Values of Properties
edgeLabelPlacement | IGNORE
| Edge labels are placed by an independent labeling algorithm. |
fromSketchMode | false | The layout algorithm does not consider the initial coordinates of the nodes. |
minimumNodeDistance | 0 | |
nodeLabelPlacement | CONSIDER
| Node labels are considered. |
Type Details
- yFiles module
- algorithms
See Also
Constructors
Creates a new CompactDiskLayout instance with the default settings.
Parameters
A map of options to pass to the method.
- nodeLabelSpacing - number
- The spacing used for node labels when integrated node labeling is enabled. This option sets the nodeLabelSpacing property on the created object.
- nodeLabelPlacement - RadialNodeLabelPlacement
- How the layout handles the position of node labels. This option sets the nodeLabelPlacement property on the created object.
- edgeLabelPlacement - RadialEdgeLabelPlacement
- How the layout handles the position of edge labels. This option sets the edgeLabelPlacement property on the created object.
- fromSketchMode - boolean
- Whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk. This option sets the fromSketchMode property on the created object.
- minimumNodeDistance - number
- The minimum node distance that this algorithm should enforce between all pairs of nodes. This option sets the minimumNodeDistance property on the created object.
Properties
Gets or sets how the layout handles the position of edge labels.
Default Value
Property Value
Gets or sets whether or not to take the coordinates of the input diagram into account when arranging the nodes on the disk.
Remarks
Default Value
false
.The layout algorithm does not consider the initial coordinates of the nodes.
Property Value
true
if the initial coordinates of the nodes are used, false
otherwiseSee Also
Sample Graphs
Gets the mutable stack of ILayoutStage that will be applied to this layout.
See Also
Gets or sets the minimum node distance that this algorithm should enforce between all pairs of nodes.
Remarks
Default Value
0
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the specified minimum node distance is negative
See Also
Sample Graphs
Gets or sets how the layout handles the position of node labels.
Default Value
Property Value
- IGNORE if node label positions relative to their owner should be maintained and ignored during the layout process.
- CONSIDER if node label positions relative to their owner should be maintained and considered for the placement of other graph elements to avoid overlaps.
- HORIZONTAL if horizontal node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- RAY_LIKE if ray-like node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- RAY_LIKE_LEAVES if a mix of horizontal and ray-like node label positions should be calculated by this layout algorithm, assuring that no overlaps occur.
- GENERIC if the node labels should be placed by the GenericLabeling algorithm subsequently.
See Also
Sample Graphs
Gets or sets the spacing used for node labels when integrated node labeling is enabled.
Remarks
This spacing specifies the distance between labels associated with the same node (if there are multiple labels). In addition, for ray-like labels of outermost nodes, the spacing also defines the distance between the labels and the node they belong to (e.g. for ray-like label placement).
The spacing must have a non-negative value.
Default Value
4.0
.Property Value
Throws
- Exception({ name: 'ArgumentError' })
- if the given spacing value is negative
See Also
Sample Graphs
Methods
Calculates a radial arrangement for the given graph.
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the input graph
See Also
Implements
Calculates a radial arrangement for the given graph.
createLayoutData
(graph: LayoutGraph) : CompactDiskLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the CompactDiskLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - LayoutGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪CompactDiskLayoutData<LayoutNode,LayoutEdge,LayoutNodeLabel,LayoutEdgeLabel>
- an instance of layout data that can be used to perform item-specific configurations for the given CompactDiskLayout.
Returns an instance of LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> that can be used to perform item-specific configurations for the CompactDiskLayout.
Remarks
Parameters
A map of options to pass to the method.
- graph - IGraph
- the graph that determines the generic type arguments of the created layout data
Returns
- ↪CompactDiskLayoutData<INode,IEdge,ILabel,ILabel>
- an instance of layout data that can be used to perform item-specific configurations for the given CompactDiskLayout.
LayoutExecutor
type is available at runtime.