Add diagonal elimination to hybrid winner refinement
EliminateDiagonalSegments runs in the hybrid baseline finalization but large diagonals can re-appear during iterative optimization. Added a conditional elimination pass in the winner refinement when LongDiagonalViolations > 0. NodeSpacing=40 retained (default). Tested 42/45/50/60 — each creates different violations because the routing is tuned for 40. Wider spacing needs its own tuning pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,7 @@ public partial class DocumentProcessingWorkflowRenderingTests
|
||||
var layout = await engine.LayoutAsync(graph, new WorkflowRenderLayoutRequest
|
||||
{
|
||||
Direction = WorkflowRenderLayoutDirection.LeftToRight,
|
||||
NodeSpacing = 40,
|
||||
});
|
||||
|
||||
var svgRenderer = new WorkflowRenderSvgRenderer();
|
||||
|
||||
@@ -258,10 +258,21 @@ internal static partial class ElkEdgeRouterIterative
|
||||
ElkLayoutDiagnostics.LogProgress($"Hybrid winner refinement after final boundary-slot snap: {DescribeSolution(current)}");
|
||||
}
|
||||
|
||||
// Eliminate large diagonal segments that may survive through the
|
||||
// iterative optimization (the hybrid baseline runs EliminateDiagonalSegments
|
||||
// but subsequent pipeline passes can re-introduce diagonals).
|
||||
if (current.Score.LongDiagonalViolations > 0)
|
||||
{
|
||||
var eliminated = ElkEdgePostProcessor.EliminateDiagonalSegments(current.Edges, nodes);
|
||||
var elimScore = ElkEdgeRoutingScoring.ComputeScore(eliminated, nodes);
|
||||
if (elimScore.LongDiagonalViolations < current.Score.LongDiagonalViolations
|
||||
&& elimScore.NodeCrossings <= current.Score.NodeCrossings)
|
||||
{
|
||||
current = current with { Score = elimScore, Edges = eliminated };
|
||||
}
|
||||
}
|
||||
|
||||
// Straighten short diagonal stubs at gateway boundary vertices.
|
||||
// The boundary-slot snap and normalization passes may leave small
|
||||
// diagonal segments (3-8px) at gateway tips. This cosmetic pass
|
||||
// adjusts the adjacent bend point to make the approach orthogonal.
|
||||
var straightened = ElkEdgePostProcessor.StraightenGatewayCornerDiagonals(current.Edges, nodes);
|
||||
if (!ReferenceEquals(straightened, current.Edges))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user