Skip to content

MudChart: Fix Sankey hang on circular edge definitions - #13322

Merged
danielchalmers merged 1 commit into
MudBlazor:devfrom
danielchalmers:claude/fix-sankey-circular-loop
Jun 19, 2026
Merged

danielchalmers merged 1 commit into
MudBlazor:devfrom
danielchalmers:claude/fix-sankey-circular-loop

Conversation

@danielchalmers

@danielchalmers danielchalmers commented Jun 19, 2026 •

Copy link
Copy Markdown
Member

A Sankey chart whose edges form a cycle (e.g. A -> B, B -> A) hangs the render. Sankey.CalculateNodeColumns runs a BFS that always re-enqueues every target to find the longest path. With a cycle there is no root node, so the source-node fallback treats every node as a source and each pass around the cycle increases the column — the queue never drains and rendering loops forever.

The fix is to only enqueue a target when the edge actually pushes it into a deeper column and cap the column at the node count (the longest path in a graph of N nodes spans at most N-1 edges). This terminates on cyclic input while producing identical columns for valid acyclic graphs, so existing layout behaviour is unchanged.

Checklist:

  • I've read the contribution guidelines
  • My code follows the style of this project
  • I've added or updated relevant unit tests

Sankey's CalculateNodeColumns ran a BFS that always re-enqueued every target
to find the longest path. With circular edges (e.g. A->B, B->A) no node is a
root, so the source-node fallback treats every node as a source and the column
keeps increasing on each pass around the cycle. The queue never drains and the
render hangs.

Only enqueue a target when the edge pushes it into a deeper column, and cap the
column at the node count (the longest path in a graph of N nodes spans at most
N-1 edges). This terminates on cyclic input while producing identical columns
for valid acyclic graphs.

Adds a regression test rendering a two-node cycle.
@danielchalmers
danielchalmers merged commit 40f20f4 into MudBlazor:dev Jun 19, 2026
11 checks passed
@danielchalmers
danielchalmers deleted the claude/fix-sankey-circular-loop branch June 19, 2026 12:11
@danielchalmers danielchalmers added the bug Unexpected behavior or functionality not working as intended label Jun 19, 2026
This was referenced Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant