Refactor ElkSharp hybrid routing and document speed path
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace StellaOps.ElkSharp;
|
||||
|
||||
internal static partial class ElkEdgeRouterIterative
|
||||
{
|
||||
private static (ElkRoutedEdge[] Edges, EdgeRoutingScore Score, RoutingRetryState RetryState, int RemainingBrokenHighways, ElkIterativeRouteDiagnostics RouteDiagnostics)? TryApplyVerifiedIssueRepairRound(
|
||||
ElkRoutedEdge[] edges,
|
||||
ElkPositionedNode[] nodes,
|
||||
double baseObstacleMargin,
|
||||
RoutingStrategy strategy,
|
||||
RoutingRetryState retryState,
|
||||
ElkLayoutDirection direction,
|
||||
CancellationToken cancellationToken,
|
||||
int maxParallelRepairBuilds,
|
||||
bool trustIndependentParallelBuilds = false,
|
||||
bool useHybridCleanup = false)
|
||||
{
|
||||
var score = ElkEdgeRoutingScoring.ComputeScore(edges, nodes);
|
||||
var focusedPlan = BuildRepairPlan(
|
||||
edges,
|
||||
nodes,
|
||||
score,
|
||||
retryState,
|
||||
strategy,
|
||||
int.MaxValue);
|
||||
if (focusedPlan is null || focusedPlan.Value.EdgeIds.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var reroutedResult = RepairPenalizedEdges(
|
||||
edges,
|
||||
nodes,
|
||||
baseObstacleMargin,
|
||||
strategy,
|
||||
focusedPlan.Value,
|
||||
cancellationToken,
|
||||
maxParallelRepairBuilds,
|
||||
trustIndependentParallelBuilds);
|
||||
var rerouted = reroutedResult.Edges;
|
||||
var cleaned = useHybridCleanup
|
||||
? ApplyHybridTerminalRuleCleanupRound(
|
||||
rerouted,
|
||||
nodes,
|
||||
direction,
|
||||
strategy.MinLineClearance,
|
||||
focusedPlan.Value.EdgeIds)
|
||||
: ApplyTerminalRuleCleanupRound(
|
||||
rerouted,
|
||||
nodes,
|
||||
direction,
|
||||
strategy.MinLineClearance,
|
||||
focusedPlan.Value.EdgeIds);
|
||||
var cleanedScore = ElkEdgeRoutingScoring.ComputeScore(cleaned, nodes);
|
||||
var remainingBrokenHighways = HighwayProcessingEnabled
|
||||
? ElkEdgeRouterHighway.DetectRemainingBrokenHighways(cleaned, nodes).Count
|
||||
: 0;
|
||||
var cleanedRetryState = BuildRetryState(cleanedScore, remainingBrokenHighways);
|
||||
return (cleaned, cleanedScore, cleanedRetryState, remainingBrokenHighways, reroutedResult.Diagnostics);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user