From 3b91367ad2dd4c4331af81fb9d22092e2ad1b3b3 Mon Sep 17 00:00:00 2001 From: f-gueguen Date: Wed, 27 Dec 2023 19:06:26 +0100 Subject: [PATCH 1/4] layout on whole graph (including compound) --- lib/layout.js | 2 +- lib/position/index.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/layout.js b/lib/layout.js index dfccf301..78ea3ec7 100644 --- a/lib/layout.js +++ b/lib/layout.js @@ -31,7 +31,7 @@ function runLayout(g, time) { time(" removeSelfEdges", () => removeSelfEdges(g)); time(" acyclic", () => acyclic.run(g)); time(" nestingGraph.run", () => nestingGraph.run(g)); - time(" rank", () => rank(util.asNonCompoundGraph(g))); + time(" rank", () => rank(g)); time(" injectEdgeLabelProxies", () => injectEdgeLabelProxies(g)); time(" removeEmptyRanks", () => removeEmptyRanks(g)); time(" nestingGraph.cleanup", () => nestingGraph.cleanup(g)); diff --git a/lib/position/index.js b/lib/position/index.js index 2258081c..64de29b5 100644 --- a/lib/position/index.js +++ b/lib/position/index.js @@ -6,8 +6,6 @@ let positionX = require("./bk").positionX; module.exports = position; function position(g) { - g = util.asNonCompoundGraph(g); - positionY(g); Object.entries(positionX(g)).forEach(([v, x]) => g.node(v).x = x); } From 9f77b21ee0e44b43779b746eebfd5d9a03d17f01 Mon Sep 17 00:00:00 2001 From: f-gueguen Date: Wed, 27 Dec 2023 19:06:34 +0100 Subject: [PATCH 2/4] upgrade version --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index cc3eb4f1..75f0003e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@dagrejs/dagre", - "version": "1.0.4", + "version": "1.0.5-pre", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dagrejs/dagre", - "version": "1.0.4", + "version": "1.0.5-pre", "license": "MIT", "dependencies": { "@dagrejs/graphlib": "2.1.13" From ade1689988986578c04d3818524aa77bf97132d5 Mon Sep 17 00:00:00 2001 From: f-gueguen Date: Wed, 27 Dec 2023 22:22:26 +0100 Subject: [PATCH 3/4] infinity slack on non connected edges --- lib/rank/feasible-tree.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rank/feasible-tree.js b/lib/rank/feasible-tree.js index e4e4db5e..95e7f8b0 100644 --- a/lib/rank/feasible-tree.js +++ b/lib/rank/feasible-tree.js @@ -41,7 +41,11 @@ function feasibleTree(g) { var edge, delta; while (tightTree(t, g) < size) { edge = findMinSlackEdge(t, g); - delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); + if (!edge) { + delta = Number.POSITIVE_INFINITY; + } else { + delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); + } shiftRanks(t, g, delta); } From 0becb174be2399bc0295d0c9ed9c731f14d813f7 Mon Sep 17 00:00:00 2001 From: f-gueguen Date: Wed, 27 Dec 2023 22:32:59 +0100 Subject: [PATCH 4/4] revert last commit --- lib/rank/feasible-tree.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/rank/feasible-tree.js b/lib/rank/feasible-tree.js index 95e7f8b0..e4e4db5e 100644 --- a/lib/rank/feasible-tree.js +++ b/lib/rank/feasible-tree.js @@ -41,11 +41,7 @@ function feasibleTree(g) { var edge, delta; while (tightTree(t, g) < size) { edge = findMinSlackEdge(t, g); - if (!edge) { - delta = Number.POSITIVE_INFINITY; - } else { - delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); - } + delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge); shiftRanks(t, g, delta); }