From e0ad4de5aac7a7034783bc2332e61cd47e48ab4e Mon Sep 17 00:00:00 2001 From: David Newell Date: Wed, 13 Mar 2024 14:34:51 +0000 Subject: [PATCH] Checking for empty layers before checking for conflicts --- lib/order/index.js | 2 ++ lib/position/bk.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/order/index.js b/lib/order/index.js index 9259f170..504ce11e 100644 --- a/lib/order/index.js +++ b/lib/order/index.js @@ -38,6 +38,7 @@ function order(g, opts) { let maxRank = util.maxRank(g), downLayerGraphs = buildLayerGraphs(g, util.range(1, maxRank + 1), "inEdges"), upLayerGraphs = buildLayerGraphs(g, util.range(maxRank - 1, -1, -1), "outEdges"); + let layering = (0, _initOrder.default)(g); assignOrder(g, layering); @@ -47,6 +48,7 @@ function order(g, opts) { let bestCC = Number.POSITIVE_INFINITY, best; + for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) { sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2); layering = util.buildLayerMatrix(g); diff --git a/lib/position/bk.js b/lib/position/bk.js index f4436c6b..5283b009 100644 --- a/lib/position/bk.js +++ b/lib/position/bk.js @@ -70,7 +70,7 @@ function findType1Conflicts(g, layering) { }); return layer; } - layering.reduce(visitLayer); + layering.length && layering.reduce(visitLayer); return conflicts; } function findType2Conflicts(g, layering) { @@ -107,7 +107,7 @@ function findType2Conflicts(g, layering) { }); return south; } - layering.reduce(visitLayer); + layering.length && layering.reduce(visitLayer); return conflicts; } function findOtherInnerSegmentNode(g, v) {