Skip to content

Fix overlapping parallel edges between same node pair - #3

Merged
cmwright merged 1 commit into
mainfrom
fix-parallel-edge-overlap
Jun 1, 2026
Merged

Fix overlapping parallel edges between same node pair#3
cmwright merged 1 commit into
mainfrom
fix-parallel-edge-overlap

Conversation

@cmwright

@cmwright cmwright commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Problem

Parallel edges between the same (from, to) node pair were drawn on top of each other. In the reported vendor-onboarding flowchart, the two Keep waiting → Analyst review approval gate edges (submitted / window lapses) overlapped completely, where mermaid.js splits them into two separate curves.

Root cause

Every edge was registered with dagre under a None name, so parallel edges collapsed to a single edge ID in the multigraph — the second overwrote the first. Downstream extraction and routing maps were keyed only by (from, to), so both edges shared one routing path and one label position.

Fix

Thread a per-edge identity (the edge's positional index — stable because all_edges is iterated in identical order by both graph_builder and route_edges) through the pipeline:

  • graph_builder: assign each edge a unique dagre name so the multigraph + normalize step give each parallel edge its own dummy chain (distinct routing and label-dummy positions).
  • types: add EdgeKey = (String, String, Option<String>).
  • mod: key DagreEdgeExtraction maps by EdgeKey; subgraph-fallback cleanup retains by node pair regardless of name.
  • edge_routing: reconstruct the matching key when routing.

Edge names survive dagre's acyclic reversal (restored via forward_name on undo), so keys stay consistent after layout.

Testing

  • Added test_parallel_edges_are_separated asserting the two parallel wait2 → review edges get distinct label positions and distinct routed paths.
  • Rendered the reported diagram — the two edges now curve apart with side-by-side labels, matching mermaid.js.
  • Full workspace test suite green (0 failures).

🤖 Generated with Claude Code

Parallel edges between the same (from, to) node pair were drawn on top of
each other because every edge was registered with dagre under a `None`
name, collapsing them to a single edge ID in the multigraph. Downstream
extraction and routing maps were keyed only by (from, to), so both edges
shared one routing path and one label position.

Thread a per-edge identity (the edge's positional index, stable because
`all_edges` is shared in identical order between graph_builder and
route_edges) through the pipeline:

- graph_builder: assign each edge a unique dagre name so the multigraph
  and normalize step give each parallel edge its own dummy chain.
- types: add EdgeKey = (String, String, Option<String>).
- mod: key DagreEdgeExtraction maps by EdgeKey; retain-by-pair cleanup.
- edge_routing: reconstruct the matching key when routing.

Add a regression test asserting parallel wait2->review edges get distinct
label positions and distinct routed paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cmwright
cmwright merged commit 432ccf5 into main Jun 1, 2026
1 check passed
@cmwright
cmwright deleted the fix-parallel-edge-overlap branch June 1, 2026 21:09
@cmwright cmwright mentioned this pull request Jun 9, 2026
cmwright added a commit that referenced this pull request Jun 9, 2026
Bump workspace crates to 0.1.2 and publish the fixes landed since 0.1.1:

- Fix overlapping parallel edges between same node pair (#3)
- Fix flaky test_unique_id: make ID counter thread-local (#4)

Update inter-crate dependency pins (mermaid-core -> mermaid-dagre,
mermaid-rs-cli -> mermaid-core) to 0.1.2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant