LvlGraph: Ensure work was done, or quit. No endless loop.

This commit is contained in:
Martin 2021-12-21 23:04:34 +01:00
parent abb908d498
commit 42d6e0bc85

View File

@ -1877,13 +1877,16 @@ end;
procedure TMinXGraph.SwitchAndShuffle(MaxSingleRun, MaxTotalRun: int64);
var
Run: int64;
Run, LastRun: int64;
begin
Run:=1;
LastRun := 0;
while BestCrossCount<>0 do begin
SwitchCrossingPairs(MaxSingleRun,Run,Graph.NodeCount div 2);
if Run = LastRun then exit;
if Run>MaxTotalRun then break;
Shuffle;
LastRun := Run;
end;
SwitchCrossingPairs(MaxSingleRun,Run, MaxTotalRun);
end;