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

Before Auto-Layout

Applying Auto-Layout

From the Menu

  1. Select the shapes you want to organize (or select all with Cmd+A)
  2. Go to Arrange → Auto-Layout
  3. The selected elements will be rearranged

From the Toolbar

Click the Auto-Layout button in the arrangement toolbar (grid icon).

After Auto-Layout

Layout Direction

You can choose the direction of the layout hierarchy:

DirectionDescriptionBest For
Top to BottomRoot at top, leaves at bottomOrg charts, flowcharts
Bottom to TopRoot at bottom, leaves at topDecision trees
Left to RightRoot at left, leaves at rightProcess flows, timelines
Right to LeftRoot at right, leaves at leftRTL diagrams

Access direction options in Arrange → Auto-Layout → Direction.

Auto-Layout Menu

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:

  1. Assigns layers: Places nodes in hierarchical levels based on connections
  2. Reduces crossings: Minimizes edge crossings between layers
  3. Positions nodes: Places nodes to minimize edge lengths
  4. 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

  1. Delete unnecessary connections: Extra edges increase complexity
  2. Group related items: Groups are treated as single nodes
  3. Consider direction: Think about which direction makes sense for your diagram

After Running Auto-Layout

  1. Fine-tune positions: Adjust individual elements as needed
  2. Check labels: Ensure labels are readable and not overlapping
  3. 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.