Auto-Layout
Diagrammix3 includes a powerful auto-layout feature that automatically arranges your diagram elements for optimal readability. The layout engine uses the Sugiyama algorithm, which is specifically designed for hierarchical and directed graphs.
When to Use Auto-Layout
Auto-layout is helpful when:
- You've imported a diagram from Mermaid or another format
- Your diagram has become messy after many edits
- You want to quickly organize a large number of elements
- You're starting from a rough sketch and want a clean layout

Applying Auto-Layout
From the Menu
- Select the shapes you want to organize (or select all with Cmd+A)
- Go to Arrange → Auto-Layout
- The selected elements will be rearranged
From the Toolbar
Click the Auto-Layout button in the arrangement toolbar (grid icon).

Layout Direction
You can choose the direction of the layout hierarchy:
| Direction | Description | Best For |
|---|---|---|
| Top to Bottom | Root at top, leaves at bottom | Org charts, flowcharts |
| Bottom to Top | Root at bottom, leaves at top | Decision trees |
| Left to Right | Root at left, leaves at right | Process flows, timelines |
| Right to Left | Root at right, leaves at left | RTL diagrams |
Access direction options in Arrange → Auto-Layout → Direction.

Layout Options
Spacing
Control the space between elements:
- Horizontal spacing: Distance between sibling nodes
- Vertical spacing: Distance between hierarchy levels
Adjust these in the layout options panel or Inspector.
Alignment
Choose how nodes at the same level are aligned:
- Center: Nodes centered within their level
- Left/Top: Nodes aligned to the start
- Right/Bottom: Nodes aligned to the end
The Sugiyama Algorithm
The auto-layout uses the Sugiyama algorithm (also known as layered graph drawing), which:
- Assigns layers: Places nodes in hierarchical levels based on connections
- Reduces crossings: Minimizes edge crossings between layers
- Positions nodes: Places nodes to minimize edge lengths
- Routes edges: Creates clean connector paths
This algorithm is ideal for:
- Flowcharts
- Organization charts
- Dependency graphs
- UML class hierarchies
- State machines
Tips for Better Results
Before Running Auto-Layout
- Delete unnecessary connections: Extra edges increase complexity
- Group related items: Groups are treated as single nodes
- Consider direction: Think about which direction makes sense for your diagram
After Running Auto-Layout
- Fine-tune positions: Adjust individual elements as needed
- Check labels: Ensure labels are readable and not overlapping
- Adjust spacing: Increase spacing if elements feel cramped
Limitations
- Cyclic graphs: Diagrams with circular references may not layout perfectly
- Dense graphs: Very dense diagrams may still have some edge crossings
- Custom positions: Layout will override any manual positioning
- Aspect ratio: The algorithm doesn't consider canvas aspect ratio
Undo
If you don't like the result, press Cmd+Z to undo the layout and restore the previous positions.