@dagrejs/dagre 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dagre.js CHANGED
@@ -837,7 +837,7 @@ var dagre = (() => {
837
837
  }
838
838
 
839
839
  // lib/version.ts
840
- var version = "3.1.2";
840
+ var version = "3.1.4";
841
841
 
842
842
  // lib/data/list.ts
843
843
  var List = class {
@@ -1268,28 +1268,33 @@ var dagre = (() => {
1268
1268
  const parent = childLab.parent;
1269
1269
  let childIsTail = true;
1270
1270
  let graphEdge = graph.edge(child, parent);
1271
- let cutValue = 0;
1271
+ let cutValue;
1272
1272
  if (!graphEdge) {
1273
1273
  childIsTail = false;
1274
1274
  graphEdge = graph.edge(parent, child);
1275
1275
  }
1276
1276
  cutValue = graphEdge.weight;
1277
- const nodeEdges = graph.nodeEdges(child);
1278
- if (nodeEdges) {
1279
- nodeEdges.forEach((edge) => {
1280
- const isOutEdge = edge.v === child;
1281
- const other = isOutEdge ? edge.w : edge.v;
1282
- if (other !== parent) {
1283
- const pointsToHead = isOutEdge === childIsTail;
1284
- const otherWeight = graph.edge(edge).weight;
1285
- cutValue += pointsToHead ? otherWeight : -otherWeight;
1286
- if (isTreeEdge(tree, child, other)) {
1287
- const treeEdge = tree.edge(child, other);
1288
- const otherCutValue = treeEdge.cutvalue;
1289
- cutValue += pointsToHead ? -otherCutValue : otherCutValue;
1290
- }
1277
+ const inEdges = graph.inEdges(child) || [];
1278
+ const outEdges = graph.outEdges(child) || [];
1279
+ const inCount = inEdges.length;
1280
+ const total = inCount + outEdges.length;
1281
+ for (let i = 0; i < total; i++) {
1282
+ const edge = i < inCount ? inEdges[i] : outEdges[i - inCount];
1283
+ const isOutEdge = edge.v === child;
1284
+ if (i >= inCount && edge.w === child) {
1285
+ continue;
1286
+ }
1287
+ const other = isOutEdge ? edge.w : edge.v;
1288
+ if (other !== parent) {
1289
+ const pointsToHead = isOutEdge === childIsTail;
1290
+ const otherWeight = graph.edge(edge).weight;
1291
+ cutValue += pointsToHead ? otherWeight : -otherWeight;
1292
+ const treeEdge = tree.edge(child, other);
1293
+ if (treeEdge) {
1294
+ const otherCutValue = treeEdge.cutvalue;
1295
+ cutValue += pointsToHead ? -otherCutValue : otherCutValue;
1291
1296
  }
1292
- });
1297
+ }
1293
1298
  }
1294
1299
  return cutValue;
1295
1300
  }
@@ -1380,9 +1385,6 @@ var dagre = (() => {
1380
1385
  g.node(v2).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen);
1381
1386
  });
1382
1387
  }
1383
- function isTreeEdge(tree, u, v2) {
1384
- return tree.hasEdge(u, v2);
1385
- }
1386
1388
  function isDescendant(tree, vLabel, rootLabel) {
1387
1389
  return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim;
1388
1390
  }
@@ -2069,7 +2071,7 @@ var dagre = (() => {
2069
2071
  }
2070
2072
  const maxRank2 = maxRank(graph);
2071
2073
  const downLayerGraphs = buildLayerGraphs(graph, range(1, maxRank2 + 1), "inEdges");
2072
- const upLayerGraphs = buildLayerGraphs(graph, range(maxRank2 - 1, -1, -1), "outEdges");
2074
+ const upLayerGraphs = buildLayerGraphs(graph, range(maxRank2, -1, -1), "outEdges");
2073
2075
  let layering = initOrder(graph, oldNodes);
2074
2076
  assignOrder(graph, layering);
2075
2077
  if (opts.disableOptimalOrderHeuristic) {