Improve auto link positioning to consider intermediate resources#275
Merged
ugwis merged 2 commits intoawslabs:mainfrom Jan 28, 2026
Merged
Improve auto link positioning to consider intermediate resources#275ugwis merged 2 commits intoawslabs:mainfrom
ugwis merged 2 commits intoawslabs:mainfrom
Conversation
- Add countResourcesInDirections() to count siblings in each direction (N/E/W/S) - Add adjustCountsForLCAChildren() to adjust counts based on intermediate LCA children - Enhance selectOptimalPosition() to choose based on resource counts and LCA direction - Improve perpendicular direction selection using resource position (dx/dy) - Add comprehensive test cases for the new logic This improvement helps links avoid intermediate resources more intelligently, resulting in better visual clarity in complex hierarchical diagrams.
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
This PR improves the auto link positioning algorithm to consider intermediate resources in the hierarchy, resulting in better visual clarity and more intelligent link placement.
Problem
Currently, auto link positioning determines connection points based on:
However, it doesn't account for intermediate resources between source and target, which can lead to links visually overlapping with resources in between.
Solution
Enhanced the auto-positioning algorithm with three key improvements:
1. Resource Counting
countResourcesInDirections(target, lca): Counts sibling resources in each direction (N/E/W/S) from resource to LCA child2. LCA Children Adjustment
adjustCountsForLCAChildren(lca, sourceChild, targetChild, sourceCounts, targetCounts): Adjusts counts based on intermediate LCA childrenLCA{V1, V2, V3}with linkV1→V3, adds V2 count to appropriate directions3. Optimal Position Selection
selectOptimalPosition(counts, lcaDirection, dx, dy): Chooses best position with priority:Changes
AutoCalculatePositions()to use LCA child ancestors and apply adjustmentsTesting
TestCountResourcesInDirections: Validates resource counting logicTestAutoCalculatePositionsWithResourceCounts: Tests adjustment and position selectionTestAutoCalculatePositionsPerpendicularSelection: Validates perpendicular direction selectionBenefits
Related Issue
Closes #274