Lay Out a Diagram Automatically
Enterprise Architect provides the facility to layout diagrams automatically.
This creates a tree-based structure from the diagram elements and relationships in a diagram. Owing to the complexity of many diagrams, you might then have to do some manual 'tweaking'.
Layout a Diagram
To layout a diagram, follow the steps below:
- Select a diagram.
- Click on either:
- The Diagram | Layout Diagram option, or
- The Auto Layout button on the diagram toolbar.
Access the Diagram Layout Options Dialog
For a fine degree of control of the elements in your diagram, you can use the Diagram Layout Options dialog. Generally the default layout parameters provide adequate layouts for a wide range of diagrams, but there are times when more specific settings are required. To access the Diagram Layout Options dialog, follow the steps below:
- Double-click on the background of the diagram to display the Diagram Properties dialog.
- Click on the Diagram tab, then click on the Set Layout Style button. The Diagram Layout Options dialog displays.
- When you have made the required changes, click on the OK button to save the changes.
You can alter any of the following settings on the Diagram Layout Options dialog to refine your layout:
- Cycle Remove Options panel - these settings remove cycles in the element organization (where element X is the source of a path but also becomes the target of a branch of the path), by reversing the connectors that impose the cycling and then reorganizing the diagram and reinstating the reversed relationships. This identifies the primary source element in the diagram.
- Greedy - Select to use the Greedy Cycle Removal algorithm, which minimizes the number of connectors reversed.
- Depth First Search - Select to use the Depth First Search Cycle Removal algorithm, which establishes the longest linear sequence possible, before establishing parallel sequences and branches. This algorithm is less effective in large and/or complex diagrams, but produces a more natural layout than the Greedy algorithm.
- Crossing Reduction Options panel - these options determine how long the routine should look for ways of reorganizing the layout to avoid crossed relationships:
- Iterations - Type the number of iterations to be used during cycle removal (more than 8 does not usually provide any improvement).
- Aggressive - Select to use an aggressive (detailed and time-consuming) crossing reduction step.
- Layering Options panel - these settings determine how elements are organized in layers during layout:
- Longest Path Sink - Select to use the Longest Path Sink Layering algorithm, where the final target elements (sinks, which have no relationships issuing from them) are arranged in a layer at the top of the diagram, and the relationship paths built downwards from there in as many layers as there are nodes in the longest path.
- Longest Path Source - Select to use the Longest Path Source Layering algorithm, where the original source elements (those with no relationships entering them) are arranged in a layer at the bottom of the diagram and the relationship paths built up from there in as many layers as there are nodes in the longest path.
- Optimal Link Length - Select to use the Optimal Link Length Layering algorithm, which organizes the elements into whichever layers minimize the total source-to-sink relationship chain; in this layout you can have both source elements and sink elements at various levels of the diagram.
- Layout Options panel
- Layer Spacing - Type the default number of logical units between layers of elements (vertical spacing).
- Column Spacing - Type the default number of logical units between elements within a layer (horizontal spacing).
- Up, Down, Left, Right - Select the direction in which directed connectors should point, to set the position of the primary source element and the overall flow of the diagram.
- Initialize Options panel - the autolayout routine inserts line waypoints and connectors into relationship paths to help plot the direction of relationships. The routine then assigns an index number to every node, such that nodes in the same layer are numbered left to right. The settings in this panel determine how those index numbers are assigned.
- Naive - Select to use the Naive Initialize Indices algorithm, which assigns index numbers to nodes as they are encountered in a sweep and tends to place all waypoints to the right of real nodes (and therefore long relationships between a small number of elements to the right of chains of short relationships between several elements).
- Depth First Search Outward - Select to use the Depth First Out Initialize Indices algorithm, which assigns index numbers to nodes as they are encountered in a depth first search from source nodes outwards (and would therefore place longer relationship chains to the left of shorter chains, with the primary source node at the start of the diagram flow).
- Depth First Search Inward - Select to use the Depth First In Initialize Indices algorithm, which also assigns index numbers to nodes as they are encountered in a depth first search, but from sink nodes inwards (and would therefore place longer relationship chains to the left of shorter chains, with the ultimate target node at the end of the diagram flow).
- Set as Project Default checkbox
- Select this checkbox to apply the diagram layout settings to all diagrams in the project. If you later check this box and click on the OK button for a different diagram, the new settings override the settings saved earlier.
The following is an example of an automatically laid out diagram, with the following options set:
- Depth First Search
- Optimal Link Length
- Depth First Search Outward
- Direction - Up.