Skip to content

Commit e0ad4de

Browse files
committed
Checking for empty layers before checking for conflicts
1 parent 354a2ec commit e0ad4de

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/order/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function order(g, opts) {
3838
let maxRank = util.maxRank(g),
3939
downLayerGraphs = buildLayerGraphs(g, util.range(1, maxRank + 1), "inEdges"),
4040
upLayerGraphs = buildLayerGraphs(g, util.range(maxRank - 1, -1, -1), "outEdges");
41+
4142
let layering = (0, _initOrder.default)(g);
4243
assignOrder(g, layering);
4344

@@ -47,6 +48,7 @@ function order(g, opts) {
4748

4849
let bestCC = Number.POSITIVE_INFINITY,
4950
best;
51+
5052
for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
5153
sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);
5254
layering = util.buildLayerMatrix(g);

lib/position/bk.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function findType1Conflicts(g, layering) {
7070
});
7171
return layer;
7272
}
73-
layering.reduce(visitLayer);
73+
layering.length && layering.reduce(visitLayer);
7474
return conflicts;
7575
}
7676
function findType2Conflicts(g, layering) {
@@ -107,7 +107,7 @@ function findType2Conflicts(g, layering) {
107107
});
108108
return south;
109109
}
110-
layering.reduce(visitLayer);
110+
layering.length && layering.reduce(visitLayer);
111111
return conflicts;
112112
}
113113
function findOtherInnerSegmentNode(g, v) {

0 commit comments

Comments
 (0)