# Modeling - Diagram Layout Options

Go Up to Modeling Options

Tools > Options > Modeling > (level) > Diagram > Layout

Here (level) is used to specify that the Diagram Layout options page can be selected in the Diagram, Project, Project Group, and Default branches of the Modeling options tree. (See Hierarchical Levels of Modeling options in the Modeling Options dialog box topic for more information.)

The Diagram Layout options control the alignment and positioning of diagram elements.

The following tables list the Diagram Layout options:

## General options

Option Description and default value

Layout algorithm

UML diagrams can be thought of as graphs (with vertices and edges). Therefore, the layout algorithms of graphs can be also applied to the layout of UML diagrams.
The Modeling implements the selected algorithm when you choose the Layout > Do Full Layout command on the diagram context menu.
The following algorithms are available:

• `Standard`—this simple algorithm is applicable to all types of diagrams.
• `Hierarchical`—this algorithm draws the UML diagram hierarchically according to the options you select. This algorithm is most suitable to analyze hierarchical structures (for example study inheritance relationships). This algorithm originates from the Sugiyama algorithm.
• `Orthogonal`—this algorithm uses one of three simple structural heuristics (`Smart`, `Tree`, or `Balanced`) to distribute diagram nodes among a lattice. You can use this algorithm when hierarchy is not important.
• `Spring Embedder`—Spring Embedder are force-directed layout algorithms that model the input graph as a system of forces and try to find a minimum energy configuration of this system.
A spring embedder considers nodes as little metal rings in the plane. These rings are connected by springs (all edges are drawn as straight lines) and repel or attract each other. After all forces have been summed up, the rings are moved in the plane according to the forces exerted on them until a state of equilibration is reached, in which the force exerted on each ring is 0.
This type of layout is especially suitable for projects with numerous diagram elements based on large amount of source code. When you lay out a graph according to the Spring Embedder layout algorithm, the program will simulate the graph as a physical model (masses and springs) and subject it to physical forces. The unnecessarily long edges will be the most tense, and will try to contract the most. When the nodes and edges have been balanced, you will have a geometric representation of the graph.
• `Tree`—this algorithm draws the given diagram in a tree layout, according to its maximum spanning tree.
• `<autoselect>`—several algorithms can be available for each diagram type. Each of the layout algorithms contains internal information about the types of diagrams it will work with and the numeric characteristics for the final quality of the produced layout when applied to each applicable diagram type. This option uses such internal information and picks the best algorithm for the current diagram type.

The options for these algorithms are described in the tables for corresponding algorithms below.

The default is `Standard`.

Recursive layout

`True`—enforce to lay out all subelements within containers during laying out diagram nodes.
This option is useful for composite states or components.
This option is available for all layout algorithms.
The default is `True`.

## Standard algorithm options

Option Description and default value

Inheritance

Defines how to align nodes connected by inheritance links. Select either:

• `Left to right`—align horizontally from left to right.
• `Right to left`—align horizontally from right to left.
• `Top to bottom`—align vertically from top to bottom.
• `Bottom to top`—align vertically from bottom to top.

The default is `Top to bottom`.

Justification

Defines the adjustment of nodes. Interpretation of Justification depends on the Inheritance option.
The following values are available: `Top`, `Center`, and `Bottom`.
The default is `Center`.
The elements are aligned as summarized in the following table:

 Inheritance / Justification `Top` `Center` `Bottom` `Left to right` Top of the row Center of the row Bottom of the row `Right to left` Bottom of the row Center of the row Top of the row `Top to bottom` Left of the column Center of the column Right of the column `Bottom to top` Right of the column Center of the column Left of the column

## Hierarchical algorithm options

Option Description and default value

Hybrid proportion parameter

Used in conjunction with the `Hybrid` heuristic selected in Layer ordering heuristic. The optimal value for this option is `0.7`.

Inheritance

Defines how to align nodes connected by inheritance links.

• `Horizontal`—nodes connected by inheritance links are aligned horizontally.
• `Vertical`—nodes connected by inheritance links are aligned vertically.

The default is `Vertical`.

Justification

This option defines the adjustment of nodes. Interpretation of Justification depends on the Inheritance setting. The default is `Center`.
Select from the following:

• `Top`—if Inheritance is `Vertical`, all nodes in a column are aligned at the left of the column.
- If Inheritance is `Horizontal`, all nodes in a row are aligned at the top of the row.
• `Center`—if Inheritance is `Vertical`, all nodes in a column are aligned at the center of the column.
- If Inheritance is `Horizontal`, all nodes in a row are aligned at the center of the row.
• `Bottom`—if Inheritance is `Vertical`, all nodes in a column are aligned at the right of the column.
- If Inheritance is `Horizontal`, all nodes in a row are aligned at the bottom of the row.

Layer ordering heuristics

Heuristics are used to sort nodes among each layer to minimize edge-crossings:

• `Barycenter`—reorders the nodes according to the barycenter weight. The weight of node N is calculated as a simple average of all its successors (or predecessors) relative coordinates.
• `Median`—reorders the nodes according to the median weight. The weight of node N is calculated as a simple average of the relative positions of this node dealing only with two central successors (or predecessors) coordinates.
• `Hybrid`—combines the `Median` and `Barycenter` heuristics. Proportion is defined by Hybrid proportion parameter.

The default is `Barycenter`.

Minimal horizontal distance

Specifies the minimum allowed horizontal distance between diagram elements, in pixels.
The default is `60`.

Minimal vertical distance

Specifies the minimum allowed vertical distance between diagram elements, in pixels.
The default is `60`.

## Orthogonal algorithm options

Option Description and default value

Distance between elements

Specifies the minimum allowed distance between diagram elements in pixels.
The default is `30`.

Node placement strategy

There are three strategies for node placement: `Tree`, `Balanced`, and `Smart`.

• `Tree`—creates a spanning tree diagram layout. The spanning tree for the given graph is calculated and diagram nodes are placed on the lattice to minimize the tree edges length. This minimizes the distance between nodes that are linked with a tree edge.
• `Balanced`—uses a balanced ordering of the graph's vertices as a starting point. `Balanced` means that the neighbors of each vertex V are as evenly distributed to the left and right of V as possible.
• `Smart`—sorts all vertices according to the in and out degrees for each vertex and fills the lattice starting from the center with the vertices with the greatest degree.

The default is `Tree`.

## Spring embedder algorithm options

Option Description and default value

Spring force

Specifies the rigidity of the springs. The greater the value you specify, the less will be the length of edges in the final graph.

Spring movement factor

Specifies the nodes movement factor. The bigger the value you specify, the more distance will be between the nodes in the final graph. If you specify `0` as the movement factor, you will get random layout of the nodes.

## Tree algorithm options

Option Description and default value

Hierarchy

Defines the direction of the hierarchy of elements.

• `Horizontal`—elements are aligned horizontally.
• `Vertical`—elements are aligned vertically.

Justification

Defines the adjustment of elements. Interpretation of Justification depends on the Hierarchy direction setting.

• `Top`—if Hierarchy is `Vertical`, all nodes in a column are aligned at the left of the column.
- If Hierarchy is `Horizontal`, all nodes in a row are aligned at the top of the row.
• `Center`—if Hierarchy is `Vertical`, all nodes in a column are aligned at the center of the column.
- If Hierarchy is `Horizontal`, all nodes in a row are aligned at the center of the row.
• `Bottom`—if Hierarchy is `Vertical`, all nodes in a column are aligned at the right of the column.
- If Hierarchy is `Horizontal`, all nodes in a row are aligned at the bottom of the row.

Minimal horizontal distance

Specifies the minimum allowed horizontal distance between diagram elements in pixels.

Minimal vertical distance

Specifies the minimum allowed vertical distance between diagram elements in pixels.

Process non-tree edges

`True`—non-tree edges are bent to fit into the diagram layout.

Reverse hierarchy

`True`—the last in the hierarchy element is laid out first in the diagram.