Skip to content

fix(layout): Resolve force-directed overlaps, straight-edge routing, and rank ordering#60

Merged
mhiro2 merged 6 commits into
mainfrom
fix/layout-improvements
Apr 12, 2026
Merged

fix(layout): Resolve force-directed overlaps, straight-edge routing, and rank ordering#60
mhiro2 merged 6 commits into
mainfrom
fix/layout-improvements

Conversation

@mhiro2

@mhiro2 mhiro2 commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix force-directed layout overlapping rectangular nodes by adding rectangle-aware repulsion
    impulses and a post-simulation overlap resolution pass
  • Differentiate Straight edge style to render as a direct line, separate from Orthogonal polyline
    backbones, and change the default style to Orthogonal
  • Reverse rank assignment so parent/referenced tables appear first in layout direction, matching
    conventional ER diagram hierarchy
  • Add post-layout group packing pass that separates schema groups along the cross-axis and preserves
    visible corridors between connected tables
  • Align documentation and skill reference with the updated default edge style and routing model

Changes

  • 8ed6316 : fix(layout): resolve force-directed node overlap and excess spacing
    • Add rectangle-aware overlap impulses to repulsion so nodes no longer overlap along their shorter
      axis
    • Introduce a post-simulation overlap resolution pass and direction-aware edge attraction targets
    • Add a compaction pass that pulls connected nodes closer after overlap resolution
  • 4fb21ce : fix(layout): differentiate straight edge routing from orthogonal
    • Make Straight produce a direct line with no control points while Orthogonal and Curved keep
      axis-aligned polyline backbones
    • Change the default edge style from Straight to Orthogonal to preserve existing rendering
      behavior
  • 1877fb6 : fix(layout): reverse rank assignment so parent tables appear first in layout direction
    • Assign lower ranks to parent/referenced tables so they appear at the top in TopToBottom or
      left in LeftToRight layouts
  • 876a51e : fix(layout): prevent force-directed schema groups from overlapping
    • Add a post-layout group packing pass that separates grouped nodes along the layout cross-axis
    • Render group labels after nodes so schema names stay visible when containers sit close together
  • fc299a6 : fix(layout): preserve force-directed group spacing and prefix clusters
    • Refine prefix grouping so related tables share stable clusters
    • Widen minimum connected-node clearance and make post-pack separation honor connected pairs
  • 63141de : docs(layout): align edge-style docs with routing behavior
    • Update the skill reference and architecture guide so documented defaults and routing model match
      the current implementation

mhiro2 added 6 commits April 12, 2026 22:17
The force-directed layout had two issues:
- Repulsion only treated rectangular nodes as circles (max(w,h) as
  diameter), so table nodes could overlap along their shorter axis.
- No post-simulation pass existed to resolve remaining overlaps.

Add rectangle-aware overlap impulses to repulsion, a post-simulation
overlap resolution pass, direction-aware edge attraction targets, and
a compaction pass that pulls connected nodes closer after overlap
resolution.
Previously build_backbone_route and rebuild_route_from_points always
generated orthogonal control points regardless of the style parameter,
making Straight and Orthogonal visually identical.

Now Straight produces a direct line (no control points) while
Orthogonal and Curved keep axis-aligned polyline backbones. The
default edge style is changed from Straight to Orthogonal to preserve
existing rendering behaviour.
… layout direction

Parent/referenced tables now get lower ranks, placing them at the top
in TopToBottom or left in LeftToRight layouts. This matches the
conventional ER diagram hierarchy where parent tables are upstream.
Force-directed layouts could still leave schema group containers stacked
on top of each other, which let one group hide another group's title
band even after node overlap resolution.

Add a post-layout group packing pass that separates grouped nodes along
the layout cross-axis, and render group labels after nodes so schema
names stay visible when containers sit close together.
Force-directed layouts were still packing connected tables too tightly in
left-to-right mode, which left only edge labels visible between
customers/addresses and similar pairs even after overlap resolution.

Refine prefix grouping so related tables share stable clusters, widen the
minimum connected-node clearance, and make post-pack separation honor
connected pairs so force-directed groups keep visible edge corridors.
The layout fixes changed the default edge style to Orthogonal and made
Straight render as a direct source-to-target segment instead of
reusing the orthogonal backbone.

Update the skill reference and architecture guide so the documented
defaults and routing model match the current implementation.
@mhiro2 mhiro2 self-assigned this Apr 12, 2026
@mhiro2 mhiro2 added the bug Something isn't working label Apr 12, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (80c7b3d) #60 (e647239) +/-
Coverage 94.1% 94.2% +0.1%
Test Execution Time 2m47s 2m46s -1s
Details
  |                     | main (80c7b3d) | #60 (e647239) |  +/-  |
  |---------------------|----------------|---------------|-------|
+ | Coverage            |          94.1% |         94.2% | +0.1% |
  |   Files             |             77 |            77 |     0 |
  |   Lines             |          30010 |         30814 |  +804 |
+ |   Covered           |          28257 |         29045 |  +788 |
+ | Test Execution Time |          2m47s |         2m46s |   -1s |

Code coverage of files in pull request scope (96.4% → 96.5%)

Files Coverage +/- Status
crates/relune-cli/src/cli.rs 84.0% -4.0% modified
crates/relune-core/src/layout.rs 100.0% 0.0% modified
crates/relune-layout/src/graph.rs 98.6% -0.3% modified
crates/relune-layout/src/layout.rs 95.6% +0.3% modified
crates/relune-layout/src/order.rs 99.3% +0.1% affected
crates/relune-layout/src/port.rs 96.9% +0.1% affected
crates/relune-layout/src/rank.rs 98.4% 0.0% modified
crates/relune-layout/src/route/geometry.rs 93.6% +0.4% modified
crates/relune-layout/src/route/mod.rs 98.6% +0.0% modified
crates/relune-render-svg/src/group.rs 98.9% +0.4% modified
crates/relune-render-svg/src/lib.rs 97.9% +0.0% modified
crates/relune-testkit/src/lib.rs 86.9% +0.0% modified

Reported by octocov

@mhiro2
mhiro2 merged commit 0cdee8e into main Apr 12, 2026
4 checks passed
@mhiro2
mhiro2 deleted the fix/layout-improvements branch April 12, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant