Skip to content

Route cross-hierarchy edges to nested endpoint nodes - #47

Merged
Malcolmnixon merged 4 commits into
mainfrom
cross-hierarchy-edges
Nov 13, 2026
Merged

Malcolmnixon merged 4 commits into
mainfrom
cross-hierarchy-edges

Conversation

@Malcolmnixon

@Malcolmnixon Malcolmnixon commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Pull Request

Description

Adds end-to-end support for cross-hierarchy edges: edges declared in an ancestor graph whose endpoints are nested nodes.

  • [Bug]: auto layout drops edges between nodes nested in different containers #45 (auto layout drops edges): AutoLayoutAlgorithm now maps nested endpoints to their top-level ancestor when detecting components, so edges between nodes in different containers are kept and routed. A related bug is also fixed: the multi-group Pack returned boxes in group order instead of input order, which could attach a container's children to the wrong box.
  • [Feature]: Route cross-hierarchy edges to the nested endpoint nodes #46 (route to nested endpoints): edges declared in an ancestor graph are now routed from the actual nested source node to the actual nested target node, under both auto and hierarchical roots. This is the default behavior; no new HierarchyHandling value was added, and the "IncludeChildren planned" note was removed.
    • The ancestor adds layout-only proxy edges between the endpoints' top-level ancestors, so related containers are placed near each other.
    • A new internal ConnectorRouter overload uses a per-edge obstacle set, so routes pass through the endpoints' own containers but not through unrelated boxes.
  • Router quality:
    • Ports slide along a face to align with the routing lane.
    • The corner margin is derived from the arrowhead size.
    • Interior segments are at least 24px.
    • Runs keep 24px clearance from container borders.
    • Cross-hierarchy edges get a crossing penalty.
    • These fix short stubs, jogs in front of arrowheads, and routes that hug container borders.
  • Review fixes:
    • Layout-only proxy edges are tracked by object identity instead of an edge-ID prefix, so a user edge with that prefix is no longer dropped.
    • Real edges always win parallel-edge deduplication when MergeParallelEdges = true.

Behavior change: cross-hierarchy edges previously anchored on container boxes now anchor on the nested endpoint nodes. There are no public API changes.

Before / After

Each pair renders the identical gallery graph from GalleryDiagrams.cs with Themes.Dark and the same options, using main (left) and this PR at 6f95f25 (right).

Cross-hierarchy edges, auto root (#45, #46). Before, the cross-container edges were dropped and the two folders were stacked as unrelated components. After, UI→DB, Auth→Storage and Session→API are routed to the nested nodes.

Before/after: cross-hierarchy edges with auto root

Cross-hierarchy edges, hierarchical root. Before, boxes overlapped and edges were tangled. After, the containers are laid out in clean bands, with orthogonal edges ending on the nested nodes.

Before/after: cross-hierarchy edges with hierarchical root

Orthogonal obstacle. The Source→Sink edge is now routed around Obstacle between the nested nodes, with long straight approaches at both ends.

Before/after: orthogonal obstacle

Hierarchical nested. The edge now goes directly into the nested API node instead of ending on the Service container.

Before/after: hierarchical nested

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Closes #45
Closes #46

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1. Passed: 3555/3555 tests at 6f95f25, across all target frameworks including net481.
  • Code produces zero warnings

Code Quality

  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

  • All linters pass: pwsh ./lint.ps1. Passed.

Testing

Documentation

  • Updated README.md (if applicable). N/A.
  • Updated docs/ documentation (if applicable)
  • Added code examples for new features (if applicable): new gallery diagrams cross-hierarchy-edges.svg (auto) and cross-hierarchy-edges-hierarchical.svg.
  • Updated requirements.yaml (if applicable)

Additional Notes

  • Gallery review: every changed gallery image was compared visually with main.
    • Six improved: hierarchical-nested, the three theme-* images, hierarchical-parallel-edges-side-by-side, and orthogonal-obstacle.
    • Three changed only in z-order and render pixel-identically: the auto-* images.
    • The new and changed images pass the diagram-quality criteria.
  • Gallery input change: the Storage/API declaration order in GalleryDiagrams.CrossHierarchyEdges() was swapped because the placement forced an edge crossing that routing cannot avoid. Crossing minimization across containers is tracked separately.
  • Known residual: arrowhead tips overlap the target border by 3–5px in all gallery images. This is caused by the pre-existing marker geometry and is tracked separately.
  • Consumer: demaconsulting/SysML2Tools, for general-view cross-package edges, General view: draw nested packages inside their owning package frame SysML2Tools#87, and later interconnection-view cross-boundary connectors.

…auto

Fixes AutoLayoutAlgorithm dropping root-declared edges whose endpoints are
nested in different containers (closes #45). Edges declared in an ancestor
graph are now routed from the actual nested source node to the actual nested
target node, and ancestor placement accounts for them via layout-only proxy
edges (closes #46).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 13, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two critical active findings remain: valid public edge IDs can be misclassified as internal proxies, and parallel-edge deduplication can discard the real connector when a layout-only edge is retained.

2 open issues
What changed in this PR

Adds end-to-end support for routing edges declared on ancestor graphs to their actual nested endpoint nodes, while preserving separate child layout and avoiding unrelated boxes.

Changes:

  • Routes cross-hierarchy edges with per-connection obstacles, nested endpoint anchoring, title-band avoidance, anchor separation, and lane handling.
  • Adds layout-only proxy edges so ancestor placement accounts for nested connections without emitting duplicate connectors.
  • Improves automatic connectivity detection and packed box ordering, with expanded tests, documentation, requirements traceability, roadmap notes, and gallery diagrams.
File Description
test/​DemaConsulting.Rendering.Layout.Tests/​LayeredLayoutAlgorithmTests.cs Tests layout-only edge layering and emission behavior.
test/​DemaConsulting.Rendering.Layout.Tests/​HierarchicalLayoutAlgorithmTests.cs Adds cross-hierarchy routing, placement, determinism, and compatibility coverage.
test/​DemaConsulting.Rendering.Layout.Tests/​ContainmentLayoutAlgorithmTests.cs Tests layout-only corridor widening without drawing proxy lines.
test/​DemaConsulting.Rendering.Layout.Tests/​ConnectorRouterTests.cs Tests per-connection obstacles, fixed anchors, and nested-wall routing.
test/​DemaConsulting.Rendering.Layout.Tests/​AutoLayoutAlgorithmTests.cs Tests nested endpoint connectivity and input-order preservation.
test/​DemaConsulting.Rendering.Gallery/​GalleryShowcaseTests.cs Generates the new cross-hierarchy gallery diagrams.
test/​DemaConsulting.Rendering.Gallery/​GalleryDiagrams.cs Defines cross-hierarchy examples and strengthens the obstacle showcase.
test/​DemaConsulting.Rendering.Gallery/​GalleryCatalog.cs Registers the new gallery images and descriptions.
src/​DemaConsulting.Rendering/​Options/​HierarchyHandling.cs Documents nested endpoint routing as the default separate-children behavior.
src/​DemaConsulting.Rendering/​Graph/​LayoutGraph.cs Updates the graph contract for ancestor-declared nested edges.
src/​DemaConsulting.Rendering.Layout/​LayeredLayoutAlgorithm.cs Makes layout-only edges influence placement without emitting connectors.
src/​DemaConsulting.Rendering.Layout/​HierarchicalLayoutAlgorithm.cs Adds proxy placement edges, nested endpoint resolution, obstacle expansion, and cross-hierarchy routing.
src/​DemaConsulting.Rendering.Layout/​ContainmentLayoutAlgorithm.cs Accounts for layout-only edges during corridor sizing while suppressing their output.
src/​DemaConsulting.Rendering.Layout/​ConnectorRouter.cs Adds internal per-connection obstacle routing and fixed-anchor separation.
src/​DemaConsulting.Rendering.Layout/​AutoLayoutAlgorithm.cs Maps nested endpoints for connectivity and restores packed boxes to input order.
ROADMAP.md Clarifies delivered cross-hierarchy routing versus future include-children behavior.
README.md Documents nested endpoint routing in the feature overview.
docs/​verification/​rendering-layout/​layered-layout-algorithm.md Registers layout-only edge verification coverage.
docs/​verification/​rendering-layout/​hierarchical-layout-algorithm.md Documents cross-hierarchy routing and placement verification.
docs/​verification/​rendering-layout/​containment-layout-algorithm.md Documents layout-only edge corridor verification.
docs/​verification/​rendering-layout/​connector-router.md Documents internal batch-router verification.
docs/​verification/​rendering-layout/​auto-layout-algorithm.md Documents nested connectivity and box-order verification.
docs/​user_guide/​introduction.md Explains ancestor-declared nested edge routing and lists its limitations.
docs/​reqstream/​rendering-layout/​layered-layout-algorithm.yaml Adds layout-only edge requirements and test traceability.
docs/​reqstream/​rendering-layout/​hierarchical-layout-algorithm.yaml Adds nested-anchor, placement, and same-container requirements.
docs/​reqstream/​rendering-layout/​containment-layout-algorithm.yaml Adds layout-only corridor requirements.
docs/​reqstream/​rendering-layout/​auto-layout-algorithm.yaml Adds nested connectivity and input-order requirements.
docs/​reqstream/​rendering-layout.yaml Links the new requirements into the rendering layout requirement set.
docs/​gallery/​parallel-edges-and-ports/​hierarchical-parallel-edges-side-by-side.svg Refreshes generated parallel-edge gallery output.
docs/​gallery/​nested-hierarchy/​README.md Documents the cross-hierarchy gallery examples.
docs/​gallery/​nested-hierarchy/​hierarchical-nested.svg Refreshes nested hierarchical output for the new routing behavior.
docs/​gallery/​nested-hierarchy/​cross-hierarchy-edges.svg Adds the auto-layout cross-hierarchy example.
docs/​gallery/​nested-hierarchy/​cross-hierarchy-edges-hierarchical.svg Adds the hierarchical cross-hierarchy example.
docs/​gallery/​nested-hierarchy/​auto-deep-nested-mixed-connectivity.svg Refreshes generated auto-layout output.
docs/​gallery/​flow-pipeline/​orthogonal-obstacle.svg Refreshes the obstacle-routing showcase with explicit intervening edges.
docs/​gallery/​connectivity-and-clusters/​auto-multiple-disconnected-clusters.svg Refreshes generated disconnected-cluster output.
docs/​gallery/​connectivity-and-clusters/​auto-cluster-plus-isolated.svg Refreshes generated cluster-plus-isolated output.
docs/​design/​rendering/​options.md Updates hierarchy-handling design documentation.
docs/​design/​rendering/​layout-graph.md Documents ancestor-declared nested edge semantics.
docs/​design/​rendering-layout/​layered-layout-algorithm.md Documents layout-only edge processing.
docs/​design/​rendering-layout/​hierarchical-layout-algorithm.md Describes nested endpoint resolution, proxy placement, and routing.
docs/​design/​rendering-layout/​containment-layout-algorithm.md Describes layout-only edge handling in containment packing.
docs/​design/​rendering-layout/​connector-router.md Documents the internal per-connection routing entry point.
docs/​design/​rendering-layout/​auto-layout-algorithm.md Documents nested component detection and input-order restoration.
docs/​design/​rendering-layout.md Updates the overall layout subsystem architecture description.

Review effort: Lite

Malcolm Nixon and others added 2 commits November 13, 2026 14:31
Layout-only proxy edges are no longer identified by an edge-ID prefix (a user
edge with such an ID was silently dropped); they are tracked by object
identity and carried through component copying. LayeredLayoutAlgorithm now
orders real edges before layout-only ones so CycleBreaker's parallel-edge
dedup always retains a real edge (MergeParallelEdges=true).

Addresses review comments on #47.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ll keep-out

Router now slides ports along faces to align with the corridor lane (straight
connector when possible), keeps decoration within the face (derived corner
margin), enforces minimum interior segments and end legs, keeps >=24px from
container borders when running parallel, and uses a cross-hierarchy profile
(adjacent-face choice, peer arrowhead zones, crossing penalty) for nested
edges. Gallery: orthogonal-obstacle, cross-hierarchy-edges (Storage/API
declaration order swapped to avoid a planarity-forced crossing) and
cross-hierarchy-edges-hierarchical re-rendered.

Addresses PR #47 review (closes #45, closes #46).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two active nit findings remain: each contains the grammatical error “an placement hint,” which should be corrected to “a placement hint.”

2 open issues
2 resolved since last review

Review effort: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 13, 2026 22:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The changes span hierarchy composition, auto-packing, and orthogonal routing across interacting algorithms, while required build, test, runtime, and visual-routing validation could not be completed.

No open issues 🎉

2 resolved since last review

Review effort: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Route cross-hierarchy edges to the nested endpoint nodes [Bug]: auto layout drops edges between nodes nested in different containers

2 participants