Skip to content

Commit

Permalink
Checking for empty layers before checking for conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rustedgrail committed Mar 13, 2024
1 parent 354a2ec commit e0ad4de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/position/bk.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function findType1Conflicts(g, layering) {
});
return layer;
}
layering.reduce(visitLayer);
layering.length && layering.reduce(visitLayer);
return conflicts;
}
function findType2Conflicts(g, layering) {
Expand Down Expand Up @@ -107,7 +107,7 @@ function findType2Conflicts(g, layering) {
});
return south;
}
layering.reduce(visitLayer);
layering.length && layering.reduce(visitLayer);
return conflicts;
}
function findOtherInnerSegmentNode(g, v) {
Expand Down

0 comments on commit e0ad4de

Please sign in to comment.