fix(layout): Resolve force-directed overlaps, straight-edge routing, and rank ordering#60
Merged
Conversation
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.
Code Metrics Report
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%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
impulses and a post-simulation overlap resolution pass
backbones, and change the default style to
Orthogonalconventional ER diagram hierarchy
visible corridors between connected tables
Changes
axis
OrthogonalandCurvedkeepaxis-aligned polyline backbones
StraighttoOrthogonalto preserve existing renderingbehavior
TopToBottomorleft in
LeftToRightlayoutsthe current implementation