@dagrejs/dagre 3.1.0 → 3.1.2
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.cjs +3 -0
- package/dist/dagre.cjs.map +7 -0
- package/dist/dagre.esm.js +1 -1
- package/dist/dagre.esm.js.map +4 -4
- package/dist/dagre.js +315 -249
- package/dist/dagre.js.map +4 -4
- package/dist/dagre.min.js +1 -1
- package/dist/dagre.min.js.map +4 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/acyclic.d.ts +1 -1
- package/dist/types/lib/acyclic.d.ts.map +1 -1
- package/dist/types/lib/graph-lib.d.ts +5 -2
- package/dist/types/lib/graph-lib.d.ts.map +1 -1
- package/dist/types/lib/layout.d.ts +2 -2
- package/dist/types/lib/layout.d.ts.map +1 -1
- package/dist/types/lib/position/bk.d.ts.map +1 -1
- package/dist/types/lib/types.d.ts +3 -2
- package/dist/types/lib/types.d.ts.map +1 -1
- package/dist/types/lib/version.d.ts +1 -1
- package/package.json +5 -4
- package/dist/dagre.cjs.js +0 -3
- package/dist/dagre.cjs.js.map +0 -7
- /package/dist/{dagre.cjs.js.LEGAL.txt → dagre.cjs.LEGAL.txt} +0 -0
package/dist/dagre.js
CHANGED
|
@@ -23,25 +23,25 @@ var dagre = (() => {
|
|
|
23
23
|
// index.ts
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
|
-
Graph: () =>
|
|
26
|
+
Graph: () => Graph,
|
|
27
27
|
debug: () => debugOrdering,
|
|
28
28
|
default: () => index_default,
|
|
29
|
-
graphlib: () =>
|
|
29
|
+
graphlib: () => graph_lib_exports,
|
|
30
30
|
layout: () => layout,
|
|
31
31
|
util: () => util,
|
|
32
32
|
version: () => version
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
var
|
|
37
|
-
__export(
|
|
38
|
-
Graph: () =>
|
|
39
|
-
alg: () =>
|
|
40
|
-
json: () => G,
|
|
41
|
-
version: () => H
|
|
35
|
+
// lib/graph-lib.ts
|
|
36
|
+
var graph_lib_exports = {};
|
|
37
|
+
__export(graph_lib_exports, {
|
|
38
|
+
Graph: () => Graph,
|
|
39
|
+
alg: () => F
|
|
42
40
|
});
|
|
41
|
+
|
|
42
|
+
// node_modules/@dagrejs/graphlib/dist/graphlib.esm.js
|
|
43
43
|
var V = Object.defineProperty;
|
|
44
|
-
var
|
|
44
|
+
var x = (s, e) => {
|
|
45
45
|
for (var t in e) V(s, t, { get: e[t], enumerable: true });
|
|
46
46
|
};
|
|
47
47
|
var p = class {
|
|
@@ -95,8 +95,8 @@ var dagre = (() => {
|
|
|
95
95
|
return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
|
|
96
96
|
}
|
|
97
97
|
setNodes(e, t) {
|
|
98
|
-
return e.forEach((
|
|
99
|
-
t !== void 0 ? this.setNode(
|
|
98
|
+
return e.forEach((r) => {
|
|
99
|
+
t !== void 0 ? this.setNode(r, t) : this.setNode(r);
|
|
100
100
|
}), this;
|
|
101
101
|
}
|
|
102
102
|
setNode(e, t) {
|
|
@@ -110,9 +110,9 @@ var dagre = (() => {
|
|
|
110
110
|
}
|
|
111
111
|
removeNode(e) {
|
|
112
112
|
if (e in this._nodes) {
|
|
113
|
-
let t = (
|
|
114
|
-
delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((
|
|
115
|
-
this.setParent(
|
|
113
|
+
let t = (r) => this.removeEdge(this._edgeObjs[r]);
|
|
114
|
+
delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((r) => {
|
|
115
|
+
this.setParent(r);
|
|
116
116
|
}), delete this._children[e]), Object.keys(this._in[e]).forEach(t), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(t), delete this._out[e], delete this._sucs[e], --this._nodeCount;
|
|
117
117
|
}
|
|
118
118
|
return this;
|
|
@@ -122,7 +122,7 @@ var dagre = (() => {
|
|
|
122
122
|
if (t === void 0) t = "\0";
|
|
123
123
|
else {
|
|
124
124
|
t += "";
|
|
125
|
-
for (let
|
|
125
|
+
for (let r = t; r !== void 0; r = this.parent(r)) if (r === e) throw new Error("Setting " + t + " as parent of " + e + " would create a cycle");
|
|
126
126
|
this.setNode(t);
|
|
127
127
|
}
|
|
128
128
|
return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = t, this._children[t][e] = true, this;
|
|
@@ -154,27 +154,28 @@ var dagre = (() => {
|
|
|
154
154
|
neighbors(e) {
|
|
155
155
|
let t = this.predecessors(e);
|
|
156
156
|
if (t) {
|
|
157
|
-
let
|
|
158
|
-
for (let
|
|
159
|
-
return Array.from(
|
|
157
|
+
let r = new Set(t), i = this.successors(e);
|
|
158
|
+
if (i) for (let n of i) r.add(n);
|
|
159
|
+
return Array.from(r.values());
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
isLeaf(e) {
|
|
163
|
+
var r;
|
|
163
164
|
let t;
|
|
164
|
-
return this.isDirected() ? t = this.successors(e) : t = this.neighbors(e), t.length === 0;
|
|
165
|
+
return this.isDirected() ? t = this.successors(e) : t = this.neighbors(e), ((r = t == null ? void 0 : t.length) != null ? r : 0) === 0;
|
|
165
166
|
}
|
|
166
167
|
filterNodes(e) {
|
|
167
168
|
let t = new this.constructor({ directed: this._isDirected, multigraph: this._isMultigraph, compound: this._isCompound });
|
|
168
|
-
t.setGraph(this.graph()), Object.entries(this._nodes).forEach(([
|
|
169
|
-
e(
|
|
170
|
-
}), Object.values(this._edgeObjs).forEach((
|
|
171
|
-
t.hasNode(
|
|
169
|
+
t.setGraph(this.graph()), Object.entries(this._nodes).forEach(([n, o]) => {
|
|
170
|
+
e(n) && t.setNode(n, o);
|
|
171
|
+
}), Object.values(this._edgeObjs).forEach((n) => {
|
|
172
|
+
t.hasNode(n.v) && t.hasNode(n.w) && t.setEdge(n, this.edge(n));
|
|
172
173
|
});
|
|
173
|
-
let
|
|
174
|
-
let o = this.parent(
|
|
175
|
-
return !o || t.hasNode(o) ? (n
|
|
174
|
+
let r = {}, i = (n) => {
|
|
175
|
+
let o = this.parent(n);
|
|
176
|
+
return !o || t.hasNode(o) ? (r[n] = o, o) : o in r ? r[o] : i(o);
|
|
176
177
|
};
|
|
177
|
-
return this._isCompound && t.nodes().forEach((
|
|
178
|
+
return this._isCompound && t.nodes().forEach((n) => t.setParent(n, i(n))), t;
|
|
178
179
|
}
|
|
179
180
|
setDefaultEdgeLabel(e) {
|
|
180
181
|
return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
|
|
@@ -186,34 +187,34 @@ var dagre = (() => {
|
|
|
186
187
|
return Object.values(this._edgeObjs);
|
|
187
188
|
}
|
|
188
189
|
setPath(e, t) {
|
|
189
|
-
return e.reduce((
|
|
190
|
+
return e.reduce((r, i) => (t !== void 0 ? this.setEdge(r, i, t) : this.setEdge(r, i), i)), this;
|
|
190
191
|
}
|
|
191
|
-
setEdge(e, t,
|
|
192
|
-
let
|
|
193
|
-
typeof e == "object" && e !== null && "v" in e ? (
|
|
194
|
-
let
|
|
195
|
-
if (
|
|
192
|
+
setEdge(e, t, r, i) {
|
|
193
|
+
let n, o, d, h, c = false;
|
|
194
|
+
typeof e == "object" && e !== null && "v" in e ? (n = e.v, o = e.w, d = e.name, arguments.length === 2 && (h = t, c = true)) : (n = e, o = t, d = i, arguments.length > 2 && (h = r, c = true)), n = "" + n, o = "" + o, d !== void 0 && (d = "" + d);
|
|
195
|
+
let a = _(this._isDirected, n, o, d);
|
|
196
|
+
if (a in this._edgeLabels) return c && (this._edgeLabels[a] = h), this;
|
|
196
197
|
if (d !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
|
|
197
|
-
this.setNode(
|
|
198
|
-
let u = J(this._isDirected,
|
|
199
|
-
return
|
|
198
|
+
this.setNode(n), this.setNode(o), this._edgeLabels[a] = c ? h : this._defaultEdgeLabelFn(n, o, d);
|
|
199
|
+
let u = J(this._isDirected, n, o, d);
|
|
200
|
+
return n = u.v, o = u.w, Object.freeze(u), this._edgeObjs[a] = u, R(this._preds[o], n), R(this._sucs[n], o), this._in[o][a] = u, this._out[n][a] = u, this._edgeCount++, this;
|
|
200
201
|
}
|
|
201
|
-
edge(e, t,
|
|
202
|
-
let i = arguments.length === 1 ?
|
|
202
|
+
edge(e, t, r) {
|
|
203
|
+
let i = arguments.length === 1 ? G(this._isDirected, e) : _(this._isDirected, e, t, r);
|
|
203
204
|
return this._edgeLabels[i];
|
|
204
205
|
}
|
|
205
|
-
edgeAsObj(e, t,
|
|
206
|
-
let i = arguments.length === 1 ? this.edge(e) : this.edge(e, t,
|
|
207
|
-
return typeof i != "object" ? { label: i } : i;
|
|
206
|
+
edgeAsObj(e, t, r) {
|
|
207
|
+
let i = arguments.length === 1 ? this.edge(e) : this.edge(e, t, r);
|
|
208
|
+
return typeof i != "object" || i === null ? { label: i } : i;
|
|
208
209
|
}
|
|
209
|
-
hasEdge(e, t,
|
|
210
|
-
return (arguments.length === 1 ?
|
|
210
|
+
hasEdge(e, t, r) {
|
|
211
|
+
return (arguments.length === 1 ? G(this._isDirected, e) : _(this._isDirected, e, t, r)) in this._edgeLabels;
|
|
211
212
|
}
|
|
212
|
-
removeEdge(e, t,
|
|
213
|
-
let i = arguments.length === 1 ?
|
|
214
|
-
if (
|
|
215
|
-
let o =
|
|
216
|
-
delete this._edgeLabels[i], delete this._edgeObjs[i],
|
|
213
|
+
removeEdge(e, t, r) {
|
|
214
|
+
let i = arguments.length === 1 ? G(this._isDirected, e) : _(this._isDirected, e, t, r), n = this._edgeObjs[i];
|
|
215
|
+
if (n) {
|
|
216
|
+
let o = n.v, d = n.w;
|
|
217
|
+
delete this._edgeLabels[i], delete this._edgeObjs[i], k(this._preds[d], o), k(this._sucs[o], d), delete this._in[d][i], delete this._out[o][i], this._edgeCount--;
|
|
217
218
|
}
|
|
218
219
|
return this;
|
|
219
220
|
}
|
|
@@ -229,58 +230,57 @@ var dagre = (() => {
|
|
|
229
230
|
_removeFromParentsChildList(e) {
|
|
230
231
|
delete this._children[this._parent[e]][e];
|
|
231
232
|
}
|
|
232
|
-
filterEdges(e, t,
|
|
233
|
+
filterEdges(e, t, r) {
|
|
233
234
|
if (!e) return;
|
|
234
235
|
let i = Object.values(e);
|
|
235
|
-
return
|
|
236
|
+
return r ? i.filter((n) => n.v === t && n.w === r || n.v === r && n.w === t) : i;
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
|
-
function
|
|
239
|
+
function R(s, e) {
|
|
239
240
|
s[e] ? s[e]++ : s[e] = 1;
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function k(s, e) {
|
|
242
243
|
s[e] !== void 0 && !--s[e] && delete s[e];
|
|
243
244
|
}
|
|
244
|
-
function
|
|
245
|
-
let i = "" + e,
|
|
246
|
-
if (!s && i >
|
|
245
|
+
function _(s, e, t, r) {
|
|
246
|
+
let i = "" + e, n = "" + t;
|
|
247
|
+
if (!s && i > n) {
|
|
247
248
|
let o = i;
|
|
248
|
-
i =
|
|
249
|
+
i = n, n = o;
|
|
249
250
|
}
|
|
250
|
-
return i + "" +
|
|
251
|
+
return i + "" + n + "" + (r === void 0 ? "\0" : r);
|
|
251
252
|
}
|
|
252
|
-
function J(s, e, t,
|
|
253
|
-
let i = "" + e,
|
|
254
|
-
if (!s && i >
|
|
253
|
+
function J(s, e, t, r) {
|
|
254
|
+
let i = "" + e, n = "" + t;
|
|
255
|
+
if (!s && i > n) {
|
|
255
256
|
let d = i;
|
|
256
|
-
i =
|
|
257
|
+
i = n, n = d;
|
|
257
258
|
}
|
|
258
|
-
let o = { v: i, w:
|
|
259
|
-
return
|
|
259
|
+
let o = { v: i, w: n };
|
|
260
|
+
return r && (o.name = r), o;
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
-
return
|
|
262
|
+
function G(s, e) {
|
|
263
|
+
return _(s, e.v, e.w, e.name);
|
|
263
264
|
}
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
F(G, { read: () => z, write: () => U });
|
|
265
|
+
var v = {};
|
|
266
|
+
x(v, { read: () => K, write: () => U });
|
|
267
267
|
function U(s) {
|
|
268
|
-
let e = { options: { directed: s.isDirected(), multigraph: s.isMultigraph(), compound: s.isCompound() }, nodes: Y(s), edges:
|
|
268
|
+
let e = { options: { directed: s.isDirected(), multigraph: s.isMultigraph(), compound: s.isCompound() }, nodes: Y(s), edges: z(s) }, t = s.graph();
|
|
269
269
|
return t !== void 0 && (e.value = structuredClone(t)), e;
|
|
270
270
|
}
|
|
271
271
|
function Y(s) {
|
|
272
272
|
return s.nodes().map((e) => {
|
|
273
|
-
let t = s.node(e),
|
|
274
|
-
return t !== void 0 && (i.value = t),
|
|
273
|
+
let t = s.node(e), r = s.parent(e), i = { v: e };
|
|
274
|
+
return t !== void 0 && (i.value = t), r !== void 0 && (i.parent = r), i;
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function z(s) {
|
|
278
278
|
return s.edges().map((e) => {
|
|
279
|
-
let t = s.edge(e),
|
|
280
|
-
return e.name !== void 0 && (
|
|
279
|
+
let t = s.edge(e), r = { v: e.v, w: e.w };
|
|
280
|
+
return e.name !== void 0 && (r.name = e.name), t !== void 0 && (r.value = t), r;
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function K(s) {
|
|
284
284
|
let e = new p(s.options);
|
|
285
285
|
return s.value !== void 0 && e.setGraph(s.value), s.nodes.forEach((t) => {
|
|
286
286
|
e.setNode(t.v, t.value), t.parent && e.setParent(t.v, t.parent);
|
|
@@ -288,23 +288,26 @@ var dagre = (() => {
|
|
|
288
288
|
e.setEdge({ v: t.v, w: t.w, name: t.name }, t.value);
|
|
289
289
|
}), e;
|
|
290
290
|
}
|
|
291
|
-
var
|
|
292
|
-
F
|
|
291
|
+
var F = {};
|
|
292
|
+
x(F, { CycleException: () => l, bellmanFord: () => y, components: () => P, dijkstra: () => E, dijkstraAll: () => I, findCycles: () => D, floydWarshall: () => O, isAcyclic: () => j, postorder: () => A, preorder: () => W, prim: () => S, shortestPaths: () => M, tarjan: () => L, topsort: () => w });
|
|
293
293
|
var Q = () => 1;
|
|
294
|
-
function
|
|
295
|
-
return $(s, String(e), t || Q,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
294
|
+
function y(s, e, t, r) {
|
|
295
|
+
return $(s, String(e), t || Q, r || function(i) {
|
|
296
|
+
var n;
|
|
297
|
+
return (n = s.outEdges(i)) != null ? n : [];
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function $(s, e, t, r) {
|
|
301
|
+
let i = {}, n, o = 0, d = s.nodes(), h = function(u) {
|
|
302
|
+
let g = i[u.v], f = i[u.w];
|
|
303
|
+
if (!g || !f) return;
|
|
304
|
+
let m = t(u);
|
|
305
|
+
g.distance + m < f.distance && (i[u.w] = { distance: g.distance + m, predecessor: u.v }, n = true);
|
|
303
306
|
}, c = function() {
|
|
304
307
|
d.forEach(function(u) {
|
|
305
|
-
|
|
306
|
-
let f = g.v === u ? g.v : g.w,
|
|
307
|
-
|
|
308
|
+
r(u).forEach(function(g) {
|
|
309
|
+
let f = g.v === u ? g.v : g.w, m = f === g.v ? g.w : g.v;
|
|
310
|
+
h({ v: f, w: m });
|
|
308
311
|
});
|
|
309
312
|
});
|
|
310
313
|
};
|
|
@@ -312,21 +315,22 @@ var dagre = (() => {
|
|
|
312
315
|
let g = u === e ? 0 : Number.POSITIVE_INFINITY;
|
|
313
316
|
i[u] = { distance: g, predecessor: "" };
|
|
314
317
|
});
|
|
315
|
-
let
|
|
316
|
-
for (let u = 1; u <
|
|
317
|
-
if (o ===
|
|
318
|
+
let a = d.length;
|
|
319
|
+
for (let u = 1; u < a && (n = false, o++, c(), !!n); u++) ;
|
|
320
|
+
if (o === a - 1 && (n = false, c(), n)) throw new Error("The graph contains a negative weight cycle");
|
|
318
321
|
return i;
|
|
319
322
|
}
|
|
320
|
-
function
|
|
321
|
-
let e = {}, t = [],
|
|
322
|
-
function i(
|
|
323
|
-
|
|
323
|
+
function P(s) {
|
|
324
|
+
let e = {}, t = [], r;
|
|
325
|
+
function i(n) {
|
|
326
|
+
var o, d;
|
|
327
|
+
n in e || (e[n] = true, r.push(n), (o = s.successors(n)) == null || o.forEach(i), (d = s.predecessors(n)) == null || d.forEach(i));
|
|
324
328
|
}
|
|
325
|
-
return s.nodes().forEach(function(
|
|
326
|
-
|
|
329
|
+
return s.nodes().forEach(function(n) {
|
|
330
|
+
r = [], i(n), r.length && t.push(r);
|
|
327
331
|
}), t;
|
|
328
332
|
}
|
|
329
|
-
var
|
|
333
|
+
var b = class {
|
|
330
334
|
constructor() {
|
|
331
335
|
this._arr = [];
|
|
332
336
|
this._keyIndices = {};
|
|
@@ -349,205 +353,242 @@ var dagre = (() => {
|
|
|
349
353
|
return this._arr[0].key;
|
|
350
354
|
}
|
|
351
355
|
add(e, t) {
|
|
352
|
-
let
|
|
353
|
-
if (!(i in
|
|
354
|
-
let
|
|
355
|
-
return
|
|
356
|
+
let r = this._keyIndices, i = String(e);
|
|
357
|
+
if (!(i in r)) {
|
|
358
|
+
let n = this._arr, o = n.length;
|
|
359
|
+
return r[i] = o, n.push({ key: i, priority: t }), this._decrease(o), true;
|
|
356
360
|
}
|
|
357
361
|
return false;
|
|
358
362
|
}
|
|
359
363
|
removeMin() {
|
|
364
|
+
if (this.size() === 0) throw new Error("Queue underflow");
|
|
360
365
|
this._swap(0, this._arr.length - 1);
|
|
361
366
|
let e = this._arr.pop();
|
|
362
367
|
return delete this._keyIndices[e.key], this._heapify(0), e.key;
|
|
363
368
|
}
|
|
364
369
|
decrease(e, t) {
|
|
365
|
-
let
|
|
366
|
-
if (
|
|
367
|
-
let i = this._arr[
|
|
370
|
+
let r = this._keyIndices[e];
|
|
371
|
+
if (r === void 0) throw new Error(`Key not found: ${e}`);
|
|
372
|
+
let i = this._arr[r].priority;
|
|
368
373
|
if (t > i) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${i} New: ${t}`);
|
|
369
|
-
this._arr[
|
|
374
|
+
this._arr[r].priority = t, this._decrease(r);
|
|
370
375
|
}
|
|
371
376
|
_heapify(e) {
|
|
372
|
-
let t = this._arr,
|
|
373
|
-
|
|
377
|
+
let t = this._arr, r = 2 * e, i = r + 1, n = e;
|
|
378
|
+
r < t.length && (n = t[r].priority < t[n].priority ? r : n, i < t.length && (n = t[i].priority < t[n].priority ? i : n), n !== e && (this._swap(e, n), this._heapify(n)));
|
|
374
379
|
}
|
|
375
380
|
_decrease(e) {
|
|
376
|
-
let t = this._arr,
|
|
377
|
-
for (; e !== 0 && (i = e >> 1, !(t[i].priority <
|
|
381
|
+
let t = this._arr, r = t[e].priority, i;
|
|
382
|
+
for (; e !== 0 && (i = e >> 1, !(t[i].priority < r)); ) this._swap(e, i), e = i;
|
|
378
383
|
}
|
|
379
384
|
_swap(e, t) {
|
|
380
|
-
let
|
|
381
|
-
|
|
385
|
+
let r = this._arr, i = this._keyIndices, n = r[e], o = r[t];
|
|
386
|
+
r[e] = o, r[t] = n, i[o.key] = e, i[n.key] = t;
|
|
382
387
|
}
|
|
383
388
|
};
|
|
384
389
|
var q = () => 1;
|
|
385
|
-
function E(s, e, t,
|
|
386
|
-
let i = function(
|
|
387
|
-
|
|
390
|
+
function E(s, e, t, r) {
|
|
391
|
+
let i = function(n) {
|
|
392
|
+
var o;
|
|
393
|
+
return (o = s.outEdges(n)) != null ? o : [];
|
|
388
394
|
};
|
|
389
|
-
return B(s, String(e), t || q,
|
|
395
|
+
return B(s, String(e), t || q, r || i);
|
|
390
396
|
}
|
|
391
|
-
function B(s, e, t,
|
|
392
|
-
let i = {},
|
|
393
|
-
let
|
|
397
|
+
function B(s, e, t, r) {
|
|
398
|
+
let i = {}, n = new b(), o, d, h = function(c) {
|
|
399
|
+
let a = c.v !== o ? c.v : c.w, u = i[a];
|
|
400
|
+
if (!u) return;
|
|
401
|
+
let g = t(c), f = d.distance + g;
|
|
394
402
|
if (g < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + c + " Weight: " + g);
|
|
395
|
-
f < u.distance && (u.distance = f, u.predecessor = o,
|
|
403
|
+
f < u.distance && (u.distance = f, u.predecessor = o, n.decrease(a, f));
|
|
396
404
|
};
|
|
397
405
|
for (s.nodes().forEach(function(c) {
|
|
398
|
-
let
|
|
399
|
-
i[c] = { distance:
|
|
400
|
-
});
|
|
406
|
+
let a = c === e ? 0 : Number.POSITIVE_INFINITY;
|
|
407
|
+
i[c] = { distance: a, predecessor: "" }, n.add(c, a);
|
|
408
|
+
}); n.size() > 0; ) {
|
|
409
|
+
o = n.removeMin();
|
|
410
|
+
let c = i[o];
|
|
411
|
+
if (!c || c.distance === Number.POSITIVE_INFINITY) break;
|
|
412
|
+
d = c, r(o).forEach(h);
|
|
413
|
+
}
|
|
401
414
|
return i;
|
|
402
415
|
}
|
|
403
|
-
function
|
|
404
|
-
return s.nodes().reduce(function(
|
|
405
|
-
return
|
|
416
|
+
function I(s, e, t) {
|
|
417
|
+
return s.nodes().reduce(function(r, i) {
|
|
418
|
+
return r[i] = E(s, i, e, t), r;
|
|
406
419
|
}, {});
|
|
407
420
|
}
|
|
408
|
-
function
|
|
409
|
-
let e = 0, t = [],
|
|
410
|
-
function
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
421
|
+
function L(s) {
|
|
422
|
+
let e = 0, t = [], r = {}, i = [];
|
|
423
|
+
function n(o) {
|
|
424
|
+
var h;
|
|
425
|
+
let d = r[o] = { onStack: true, lowlink: e, index: e++ };
|
|
426
|
+
if (t.push(o), (h = s.successors(o)) == null || h.forEach(function(c) {
|
|
427
|
+
if (c in r) {
|
|
428
|
+
let a = r[c];
|
|
429
|
+
a != null && a.onStack && (d.lowlink = Math.min(d.lowlink, a.index));
|
|
430
|
+
} else {
|
|
431
|
+
n(c);
|
|
432
|
+
let a = r[c];
|
|
433
|
+
a && (d.lowlink = Math.min(d.lowlink, a.lowlink));
|
|
434
|
+
}
|
|
414
435
|
}), d.lowlink === d.index) {
|
|
415
|
-
let
|
|
416
|
-
do
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
436
|
+
let c = [], a;
|
|
437
|
+
do {
|
|
438
|
+
a = t.pop();
|
|
439
|
+
let u = r[a];
|
|
440
|
+
u && (u.onStack = false), c.push(a);
|
|
441
|
+
} while (o !== a);
|
|
442
|
+
i.push(c);
|
|
420
443
|
}
|
|
421
444
|
}
|
|
422
445
|
return s.nodes().forEach(function(o) {
|
|
423
|
-
o in
|
|
446
|
+
o in r || n(o);
|
|
424
447
|
}), i;
|
|
425
448
|
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
428
|
-
|
|
449
|
+
function D(s) {
|
|
450
|
+
return L(s).filter(function(e) {
|
|
451
|
+
var r;
|
|
452
|
+
let t = e[0];
|
|
453
|
+
return t ? e.length > 1 || e.length === 1 && ((r = s.outEdges(t, t)) != null ? r : []).length > 0 : false;
|
|
429
454
|
});
|
|
430
455
|
}
|
|
431
456
|
var X = () => 1;
|
|
432
|
-
function
|
|
433
|
-
return Z(s, e || X, t || function(
|
|
434
|
-
|
|
457
|
+
function O(s, e, t) {
|
|
458
|
+
return Z(s, e || X, t || function(r) {
|
|
459
|
+
var i;
|
|
460
|
+
return (i = s.outEdges(r)) != null ? i : [];
|
|
435
461
|
});
|
|
436
462
|
}
|
|
437
463
|
function Z(s, e, t) {
|
|
438
|
-
let
|
|
439
|
-
return i.forEach(function(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
464
|
+
let r = {}, i = s.nodes();
|
|
465
|
+
return i.forEach(function(n) {
|
|
466
|
+
let o = {};
|
|
467
|
+
r[n] = o, o[n] = { distance: 0, predecessor: "" }, i.forEach(function(d) {
|
|
468
|
+
n !== d && (o[d] = { distance: Number.POSITIVE_INFINITY, predecessor: "" });
|
|
469
|
+
}), t(n).forEach(function(d) {
|
|
470
|
+
let h = d.v === n ? d.w : d.v, c = e(d);
|
|
471
|
+
o[h] = { distance: c, predecessor: n };
|
|
445
472
|
});
|
|
446
|
-
}), i.forEach(function(
|
|
447
|
-
let o = n
|
|
448
|
-
i.forEach(function(d) {
|
|
449
|
-
let
|
|
450
|
-
i.forEach(function(c) {
|
|
451
|
-
let
|
|
452
|
-
|
|
473
|
+
}), i.forEach(function(n) {
|
|
474
|
+
let o = r[n];
|
|
475
|
+
o && i.forEach(function(d) {
|
|
476
|
+
let h = r[d];
|
|
477
|
+
h && i.forEach(function(c) {
|
|
478
|
+
let a = h[n], u = o[c], g = h[c];
|
|
479
|
+
if (a && u && g) {
|
|
480
|
+
let f = a.distance + u.distance;
|
|
481
|
+
f < g.distance && (g.distance = f, g.predecessor = u.predecessor);
|
|
482
|
+
}
|
|
453
483
|
});
|
|
454
484
|
});
|
|
455
|
-
}),
|
|
485
|
+
}), r;
|
|
456
486
|
}
|
|
457
487
|
var l = class extends Error {
|
|
458
|
-
constructor(
|
|
459
|
-
super(
|
|
488
|
+
constructor(e) {
|
|
489
|
+
super(e), this.name = "CycleException";
|
|
460
490
|
}
|
|
461
491
|
};
|
|
462
|
-
function
|
|
463
|
-
let e = {}, t = {},
|
|
464
|
-
function i(
|
|
465
|
-
|
|
466
|
-
|
|
492
|
+
function w(s) {
|
|
493
|
+
let e = {}, t = {}, r = [];
|
|
494
|
+
function i(n) {
|
|
495
|
+
var o;
|
|
496
|
+
if (n in t) throw new l();
|
|
497
|
+
n in e || (t[n] = true, e[n] = true, (o = s.predecessors(n)) == null || o.forEach(i), delete t[n], r.push(n));
|
|
467
498
|
}
|
|
468
499
|
if (s.sinks().forEach(i), Object.keys(e).length !== s.nodeCount()) throw new l();
|
|
469
|
-
return
|
|
500
|
+
return r;
|
|
470
501
|
}
|
|
471
|
-
function
|
|
502
|
+
function j(s) {
|
|
472
503
|
try {
|
|
473
|
-
|
|
504
|
+
w(s);
|
|
474
505
|
} catch (e) {
|
|
475
506
|
if (e instanceof l) return false;
|
|
476
507
|
throw e;
|
|
477
508
|
}
|
|
478
509
|
return true;
|
|
479
510
|
}
|
|
480
|
-
function
|
|
511
|
+
function C(s, e, t, r, i) {
|
|
481
512
|
Array.isArray(e) || (e = [e]);
|
|
482
|
-
let
|
|
483
|
-
var
|
|
484
|
-
return (
|
|
513
|
+
let n = ((d) => {
|
|
514
|
+
var h;
|
|
515
|
+
return (h = s.isDirected() ? s.successors(d) : s.neighbors(d)) != null ? h : [];
|
|
485
516
|
}), o = {};
|
|
486
517
|
return e.forEach(function(d) {
|
|
487
518
|
if (!s.hasNode(d)) throw new Error("Graph does not have node: " + d);
|
|
488
|
-
i =
|
|
519
|
+
i = T(s, d, t === "post", o, n, r, i);
|
|
489
520
|
}), i;
|
|
490
521
|
}
|
|
491
|
-
function
|
|
492
|
-
return e in
|
|
493
|
-
o =
|
|
494
|
-
}), t && (o =
|
|
522
|
+
function T(s, e, t, r, i, n, o) {
|
|
523
|
+
return e in r || (r[e] = true, t || (o = n(o, e)), i(e).forEach(function(d) {
|
|
524
|
+
o = T(s, d, t, r, i, n, o);
|
|
525
|
+
}), t && (o = n(o, e))), o;
|
|
495
526
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
498
|
-
return
|
|
527
|
+
function N(s, e, t) {
|
|
528
|
+
return C(s, e, t, function(r, i) {
|
|
529
|
+
return r.push(i), r;
|
|
499
530
|
}, []);
|
|
500
531
|
}
|
|
501
|
-
function T(s, e) {
|
|
502
|
-
return w(s, e, "post");
|
|
503
|
-
}
|
|
504
532
|
function A(s, e) {
|
|
505
|
-
return
|
|
533
|
+
return N(s, e, "post");
|
|
506
534
|
}
|
|
507
535
|
function W(s, e) {
|
|
508
|
-
|
|
536
|
+
return N(s, e, "pre");
|
|
537
|
+
}
|
|
538
|
+
function S(s, e) {
|
|
539
|
+
var c;
|
|
540
|
+
let t = new p(), r = {}, i = new b(), n;
|
|
509
541
|
function o(a) {
|
|
510
|
-
let
|
|
511
|
-
if (
|
|
512
|
-
let
|
|
513
|
-
|
|
542
|
+
let u = a.v === n ? a.w : a.v, g = i.priority(u);
|
|
543
|
+
if (g !== void 0) {
|
|
544
|
+
let f = e(a);
|
|
545
|
+
f < g && (r[u] = n, i.decrease(u, f));
|
|
514
546
|
}
|
|
515
547
|
}
|
|
516
548
|
if (s.nodeCount() === 0) return t;
|
|
517
549
|
s.nodes().forEach(function(a) {
|
|
518
550
|
i.add(a, Number.POSITIVE_INFINITY), t.setNode(a);
|
|
519
|
-
})
|
|
520
|
-
let d =
|
|
551
|
+
});
|
|
552
|
+
let d = s.nodes()[0];
|
|
553
|
+
d !== void 0 && i.decrease(d, 0);
|
|
554
|
+
let h = false;
|
|
521
555
|
for (; i.size() > 0; ) {
|
|
522
|
-
if (
|
|
556
|
+
if (n = i.removeMin(), n in r) t.setEdge(n, r[n]);
|
|
523
557
|
else {
|
|
524
|
-
if (
|
|
525
|
-
|
|
558
|
+
if (h) throw new Error("Input graph is not connected: " + s);
|
|
559
|
+
h = true;
|
|
526
560
|
}
|
|
527
|
-
s.nodeEdges(
|
|
561
|
+
(c = s.nodeEdges(n)) == null || c.forEach(o);
|
|
528
562
|
}
|
|
529
563
|
return t;
|
|
530
564
|
}
|
|
531
|
-
function
|
|
532
|
-
return ee(s, e, t,
|
|
533
|
-
|
|
534
|
-
return
|
|
565
|
+
function M(s, e, t, r) {
|
|
566
|
+
return ee(s, e, t, r != null ? r : ((i) => {
|
|
567
|
+
var n;
|
|
568
|
+
return (n = s.outEdges(i)) != null ? n : [];
|
|
535
569
|
}));
|
|
536
570
|
}
|
|
537
|
-
function ee(s, e, t,
|
|
538
|
-
if (t === void 0) return E(s, e, t,
|
|
539
|
-
let i = false,
|
|
540
|
-
for (let o = 0; o <
|
|
541
|
-
let d = n
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
571
|
+
function ee(s, e, t, r) {
|
|
572
|
+
if (t === void 0) return E(s, e, t, r);
|
|
573
|
+
let i = false, n = s.nodes();
|
|
574
|
+
for (let o = 0; o < n.length; o++) {
|
|
575
|
+
let d = n[o];
|
|
576
|
+
if (d === void 0) continue;
|
|
577
|
+
let h = r(d);
|
|
578
|
+
for (let c = 0; c < h.length; c++) {
|
|
579
|
+
let a = h[c];
|
|
580
|
+
if (!a) continue;
|
|
581
|
+
let u = a.v === d ? a.v : a.w, g = u === a.v ? a.w : a.v;
|
|
582
|
+
t({ v: u, w: g }) < 0 && (i = true);
|
|
545
583
|
}
|
|
546
|
-
if (i) return
|
|
584
|
+
if (i) return y(s, e, t, r);
|
|
547
585
|
}
|
|
548
|
-
return E(s, e, t,
|
|
586
|
+
return E(s, e, t, r);
|
|
549
587
|
}
|
|
550
588
|
|
|
589
|
+
// lib/graph-lib.ts
|
|
590
|
+
var Graph = p;
|
|
591
|
+
|
|
551
592
|
// lib/util.ts
|
|
552
593
|
function addDummyNode(graph, type, attrs, name) {
|
|
553
594
|
let v2 = name;
|
|
@@ -559,7 +600,7 @@ var dagre = (() => {
|
|
|
559
600
|
return v2;
|
|
560
601
|
}
|
|
561
602
|
function simplify(graph) {
|
|
562
|
-
const simplified = new
|
|
603
|
+
const simplified = new Graph().setGraph(graph.graph());
|
|
563
604
|
graph.nodes().forEach((v2) => simplified.setNode(v2, graph.node(v2)));
|
|
564
605
|
graph.edges().forEach((e) => {
|
|
565
606
|
const simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 };
|
|
@@ -572,7 +613,7 @@ var dagre = (() => {
|
|
|
572
613
|
return simplified;
|
|
573
614
|
}
|
|
574
615
|
function asNonCompoundGraph(graph) {
|
|
575
|
-
const simplified = new
|
|
616
|
+
const simplified = new Graph({ multigraph: graph.isMultigraph() }).setGraph(graph.graph());
|
|
576
617
|
graph.nodes().forEach((v2) => {
|
|
577
618
|
if (!graph.children(v2).length) {
|
|
578
619
|
simplified.setNode(v2, graph.node(v2));
|
|
@@ -594,7 +635,7 @@ var dagre = (() => {
|
|
|
594
635
|
throw new Error("Not possible to find intersection inside of the rectangle");
|
|
595
636
|
}
|
|
596
637
|
let sx, sy;
|
|
597
|
-
if (Math.abs(dy) * w2 > Math.abs(dx) * h) {
|
|
638
|
+
if (dx === 0 || Math.abs(dy) * w2 > Math.abs(dx) * h) {
|
|
598
639
|
if (dy < 0) {
|
|
599
640
|
h = -h;
|
|
600
641
|
}
|
|
@@ -796,7 +837,7 @@ var dagre = (() => {
|
|
|
796
837
|
}
|
|
797
838
|
|
|
798
839
|
// lib/version.ts
|
|
799
|
-
var version = "3.1.
|
|
840
|
+
var version = "3.1.2";
|
|
800
841
|
|
|
801
842
|
// lib/data/list.ts
|
|
802
843
|
var List = class {
|
|
@@ -908,7 +949,7 @@ var dagre = (() => {
|
|
|
908
949
|
return results;
|
|
909
950
|
}
|
|
910
951
|
function buildState(graph, weightFn) {
|
|
911
|
-
const fasGraph = new
|
|
952
|
+
const fasGraph = new Graph();
|
|
912
953
|
let maxIn = 0;
|
|
913
954
|
let maxOut = 0;
|
|
914
955
|
graph.nodes().forEach((v2) => {
|
|
@@ -1136,7 +1177,7 @@ var dagre = (() => {
|
|
|
1136
1177
|
// lib/rank/feasible-tree.ts
|
|
1137
1178
|
var feasible_tree_default = feasibleTree;
|
|
1138
1179
|
function feasibleTree(graph) {
|
|
1139
|
-
const tree = new
|
|
1180
|
+
const tree = new Graph({ directed: false });
|
|
1140
1181
|
const nodes = graph.nodes();
|
|
1141
1182
|
if (nodes.length === 0) {
|
|
1142
1183
|
throw new Error("Graph must have at least one node");
|
|
@@ -1190,7 +1231,7 @@ var dagre = (() => {
|
|
|
1190
1231
|
}
|
|
1191
1232
|
|
|
1192
1233
|
// lib/rank/network-simplex.ts
|
|
1193
|
-
var { preorder, postorder } =
|
|
1234
|
+
var { preorder, postorder } = F;
|
|
1194
1235
|
var network_simplex_default = networkSimplex;
|
|
1195
1236
|
networkSimplex.initLowLimValues = initLowLimValues;
|
|
1196
1237
|
networkSimplex.initCutValues = initCutValues;
|
|
@@ -1905,7 +1946,7 @@ var dagre = (() => {
|
|
|
1905
1946
|
entries.splice(i, 1);
|
|
1906
1947
|
i--;
|
|
1907
1948
|
break;
|
|
1908
|
-
} else {
|
|
1949
|
+
} else if (!reversedPairs[nameI]) {
|
|
1909
1950
|
reversedPairs[nameI] = entries[j2];
|
|
1910
1951
|
entries.splice(j2, 1);
|
|
1911
1952
|
j2--;
|
|
@@ -1962,7 +2003,7 @@ var dagre = (() => {
|
|
|
1962
2003
|
nodesWithRank = graph.nodes();
|
|
1963
2004
|
}
|
|
1964
2005
|
const root = createRootNode(graph);
|
|
1965
|
-
const result = new
|
|
2006
|
+
const result = new Graph({ compound: true }).setGraph({ root }).setDefaultNodeLabel((v2) => graph.node(v2));
|
|
1966
2007
|
nodesWithRank.forEach((v2) => {
|
|
1967
2008
|
const node = graph.node(v2);
|
|
1968
2009
|
const parent = graph.parent(v2);
|
|
@@ -2078,7 +2119,7 @@ var dagre = (() => {
|
|
|
2078
2119
|
}
|
|
2079
2120
|
function sweepLayerGraphs(layerGraphs, switchBias, constraints, oldNodes) {
|
|
2080
2121
|
let biasRight = true;
|
|
2081
|
-
const cg = new
|
|
2122
|
+
const cg = new Graph();
|
|
2082
2123
|
layerGraphs.forEach(function(lg) {
|
|
2083
2124
|
constraints.forEach((con) => cg.setEdge(con.left, con.right));
|
|
2084
2125
|
const root = lg.graph().root;
|
|
@@ -2129,6 +2170,14 @@ var dagre = (() => {
|
|
|
2129
2170
|
}
|
|
2130
2171
|
function findType2Conflicts(graph, layering) {
|
|
2131
2172
|
const conflicts = {};
|
|
2173
|
+
function isBorderDummy(v2) {
|
|
2174
|
+
var _a;
|
|
2175
|
+
return ((_a = graph.node(v2)) == null ? void 0 : _a.dummy) === "border";
|
|
2176
|
+
}
|
|
2177
|
+
const hasBorderDummy = graph.nodes().some(isBorderDummy);
|
|
2178
|
+
if (!hasBorderDummy) {
|
|
2179
|
+
return conflicts;
|
|
2180
|
+
}
|
|
2132
2181
|
function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) {
|
|
2133
2182
|
range(southPos, southEnd).forEach((i) => {
|
|
2134
2183
|
const v2 = south[i];
|
|
@@ -2152,7 +2201,7 @@ var dagre = (() => {
|
|
|
2152
2201
|
let nextNorthPos = -1;
|
|
2153
2202
|
let southPos = 0;
|
|
2154
2203
|
south.forEach((v2, southLookahead) => {
|
|
2155
|
-
if (
|
|
2204
|
+
if (isBorderDummy(v2)) {
|
|
2156
2205
|
const predecessors = graph.predecessors(v2);
|
|
2157
2206
|
if (predecessors && predecessors.length) {
|
|
2158
2207
|
const firstPred = predecessors[0];
|
|
@@ -2330,7 +2379,7 @@ var dagre = (() => {
|
|
|
2330
2379
|
return xs;
|
|
2331
2380
|
}
|
|
2332
2381
|
function buildBlockGraph(graph, layering, root, reverseSep) {
|
|
2333
|
-
const blockGraph = new
|
|
2382
|
+
const blockGraph = new Graph();
|
|
2334
2383
|
const graphLabel = graph.graph();
|
|
2335
2384
|
const sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
|
|
2336
2385
|
layering.forEach((layer) => {
|
|
@@ -2537,8 +2586,7 @@ var dagre = (() => {
|
|
|
2537
2586
|
}
|
|
2538
2587
|
|
|
2539
2588
|
// lib/layout.ts
|
|
2540
|
-
var
|
|
2541
|
-
var _rawOldNodes = null;
|
|
2589
|
+
var previousLayouts = /* @__PURE__ */ new WeakMap();
|
|
2542
2590
|
function layout(g, opts = {}) {
|
|
2543
2591
|
recursiveClusterLayout(g, notime, opts);
|
|
2544
2592
|
return g;
|
|
@@ -2553,12 +2601,13 @@ var dagre = (() => {
|
|
|
2553
2601
|
return void 0;
|
|
2554
2602
|
}
|
|
2555
2603
|
function recursiveClusterLayout(g, time2, opts) {
|
|
2604
|
+
var _a;
|
|
2556
2605
|
const clusterNodes = g.nodes().filter((v2) => g.children(v2).length);
|
|
2557
2606
|
const clusterBounds = {};
|
|
2558
2607
|
clusterNodes.forEach((v2) => {
|
|
2559
2608
|
const node = g.node(v2);
|
|
2560
2609
|
if (node && node.rankdir) {
|
|
2561
|
-
const subgraph = new
|
|
2610
|
+
const subgraph = new Graph({ multigraph: true, compound: true });
|
|
2562
2611
|
subgraph.setGraph({ rankdir: node.rankdir });
|
|
2563
2612
|
const children = g.children(v2);
|
|
2564
2613
|
children.forEach((childId) => {
|
|
@@ -2573,7 +2622,9 @@ var dagre = (() => {
|
|
|
2573
2622
|
g.edges().forEach((e) => {
|
|
2574
2623
|
const srcChild = topLevelChildOf(g, e.v, v2);
|
|
2575
2624
|
const tgtChild = topLevelChildOf(g, e.w, v2);
|
|
2576
|
-
if (srcChild
|
|
2625
|
+
if (srcChild === e.v && tgtChild === e.w) {
|
|
2626
|
+
subgraph.setEdge(e, { ...g.edge(e) });
|
|
2627
|
+
} else if (srcChild && tgtChild && srcChild !== tgtChild) {
|
|
2577
2628
|
const key = `${srcChild}\0${tgtChild}`;
|
|
2578
2629
|
if (!proxiedEdges.has(key)) {
|
|
2579
2630
|
proxiedEdges.add(key);
|
|
@@ -2583,7 +2634,7 @@ var dagre = (() => {
|
|
|
2583
2634
|
});
|
|
2584
2635
|
recursiveClusterLayout(subgraph, time2, opts);
|
|
2585
2636
|
const subLayoutG = buildLayoutGraph(subgraph);
|
|
2586
|
-
runLayout(subLayoutG, time2, opts);
|
|
2637
|
+
runLayout(subLayoutG, time2, opts, null);
|
|
2587
2638
|
updateInputGraph(subgraph, subLayoutG);
|
|
2588
2639
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2589
2640
|
subgraph.nodes().forEach((u) => {
|
|
@@ -2617,14 +2668,14 @@ var dagre = (() => {
|
|
|
2617
2668
|
});
|
|
2618
2669
|
const isolatedClusters = [];
|
|
2619
2670
|
const getAllDescendants = (nodeId) => {
|
|
2620
|
-
const
|
|
2671
|
+
const result2 = [];
|
|
2621
2672
|
const queue = (g.children(nodeId) || []).filter((c) => c !== nodeId);
|
|
2622
2673
|
while (queue.length > 0) {
|
|
2623
2674
|
const curr = queue.shift();
|
|
2624
|
-
|
|
2675
|
+
result2.push(curr);
|
|
2625
2676
|
(g.children(curr) || []).filter((c) => c !== curr).forEach((c) => queue.push(c));
|
|
2626
2677
|
}
|
|
2627
|
-
return
|
|
2678
|
+
return result2;
|
|
2628
2679
|
};
|
|
2629
2680
|
const rawClusterMap = /* @__PURE__ */ new Map();
|
|
2630
2681
|
clusterNodes.forEach((v2) => {
|
|
@@ -2698,7 +2749,8 @@ var dagre = (() => {
|
|
|
2698
2749
|
}
|
|
2699
2750
|
});
|
|
2700
2751
|
const layoutG = buildLayoutGraph(g);
|
|
2701
|
-
runLayout(layoutG, time2, opts);
|
|
2752
|
+
const result = runLayout(layoutG, time2, opts, (_a = previousLayouts.get(g)) != null ? _a : null);
|
|
2753
|
+
previousLayouts.set(g, result);
|
|
2702
2754
|
updateInputGraph(g, layoutG);
|
|
2703
2755
|
proxyEdgeKeys.forEach((key) => {
|
|
2704
2756
|
const sep2 = key.indexOf("\0");
|
|
@@ -2707,9 +2759,9 @@ var dagre = (() => {
|
|
|
2707
2759
|
if (g.hasEdge(effV, effW)) g.removeEdge(effV, effW);
|
|
2708
2760
|
});
|
|
2709
2761
|
isolatedClusters.forEach(({ clusterId, subgraph, bounds, removedNodes, removedEdges }) => {
|
|
2710
|
-
var
|
|
2762
|
+
var _a2, _b;
|
|
2711
2763
|
const clusterNode = g.node(clusterId);
|
|
2712
|
-
const clusterX = (
|
|
2764
|
+
const clusterX = (_a2 = clusterNode == null ? void 0 : clusterNode.x) != null ? _a2 : 0;
|
|
2713
2765
|
const clusterY = (_b = clusterNode == null ? void 0 : clusterNode.y) != null ? _b : 0;
|
|
2714
2766
|
const subgraphCenterX = (bounds.minX + bounds.maxX) / 2;
|
|
2715
2767
|
const subgraphCenterY = (bounds.minY + bounds.maxY) / 2;
|
|
@@ -2729,15 +2781,16 @@ var dagre = (() => {
|
|
|
2729
2781
|
mainNode.y = clusterY + (subNode.y - subgraphCenterY);
|
|
2730
2782
|
}
|
|
2731
2783
|
});
|
|
2784
|
+
updateClusterEdges(g, subgraph, clusterX - subgraphCenterX, clusterY - subgraphCenterY);
|
|
2732
2785
|
delete clusterNode._dagreClusterSubgraph;
|
|
2733
2786
|
});
|
|
2734
2787
|
clusterNodes.forEach((v2) => {
|
|
2735
|
-
var
|
|
2788
|
+
var _a2, _b;
|
|
2736
2789
|
const node = g.node(v2);
|
|
2737
2790
|
const bounds = clusterBounds[v2];
|
|
2738
2791
|
if (node && node.rankdir && node._dagreClusterSubgraph && bounds) {
|
|
2739
2792
|
const subgraph = node._dagreClusterSubgraph;
|
|
2740
|
-
const parentX = (
|
|
2793
|
+
const parentX = (_a2 = node.x) != null ? _a2 : 0;
|
|
2741
2794
|
const parentY = (_b = node.y) != null ? _b : 0;
|
|
2742
2795
|
const subgraphCenterX = (bounds.minX + bounds.maxX) / 2;
|
|
2743
2796
|
const subgraphCenterY = (bounds.minY + bounds.maxY) / 2;
|
|
@@ -2752,18 +2805,31 @@ var dagre = (() => {
|
|
|
2752
2805
|
mainNode.y = parentY + dy;
|
|
2753
2806
|
}
|
|
2754
2807
|
});
|
|
2808
|
+
updateClusterEdges(g, subgraph, parentX - subgraphCenterX, parentY - subgraphCenterY);
|
|
2755
2809
|
delete node._dagreClusterSubgraph;
|
|
2756
2810
|
}
|
|
2757
2811
|
});
|
|
2758
2812
|
}
|
|
2759
|
-
function
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2813
|
+
function updateClusterEdges(g, subgraph, offsetX, offsetY) {
|
|
2814
|
+
subgraph.edges().forEach((e) => {
|
|
2815
|
+
if (!g.hasEdge(e)) return;
|
|
2816
|
+
const source = subgraph.edge(e);
|
|
2817
|
+
const target = g.edge(e);
|
|
2818
|
+
target.points = source.points.map((p2) => ({ x: p2.x + offsetX, y: p2.y + offsetY }));
|
|
2819
|
+
if (Object.hasOwn(source, "x")) {
|
|
2820
|
+
target.x = source.x + offsetX;
|
|
2821
|
+
target.y = source.y + offsetY;
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
function runLayout(g, time2, opts, previous = null) {
|
|
2826
|
+
var _a, _b;
|
|
2827
|
+
const dynamic = (opts == null ? void 0 : opts.useDynamic) !== false;
|
|
2828
|
+
const oldGraph = dynamic ? (_a = previous == null ? void 0 : previous.graph) != null ? _a : null : null;
|
|
2829
|
+
const rawOldNodes = dynamic ? (_b = previous == null ? void 0 : previous.rawNodes) != null ? _b : null : null;
|
|
2764
2830
|
time2(" makeSpaceForEdgeLabels", () => makeSpaceForEdgeLabels(g));
|
|
2765
2831
|
time2(" removeSelfEdges", () => removeSelfEdges(g));
|
|
2766
|
-
time2(" acyclic", () => run(g,
|
|
2832
|
+
time2(" acyclic", () => run(g, oldGraph));
|
|
2767
2833
|
time2(" nestingGraph.run", () => run3(g));
|
|
2768
2834
|
time2(" rank", () => rank_default(asNonCompoundGraph(g)));
|
|
2769
2835
|
time2(" injectEdgeLabelProxies", () => injectEdgeLabelProxies(g));
|
|
@@ -2775,12 +2841,12 @@ var dagre = (() => {
|
|
|
2775
2841
|
time2(" normalize.run", () => run2(g));
|
|
2776
2842
|
time2(" parentDummyChains", () => parent_dummy_chains_default(g));
|
|
2777
2843
|
time2(" addBorderSegments", () => add_border_segments_default(g));
|
|
2778
|
-
time2(" order", () => order(g, opts,
|
|
2844
|
+
time2(" order", () => order(g, opts, rawOldNodes));
|
|
2779
2845
|
time2(" insertSelfEdges", () => insertSelfEdges(g));
|
|
2780
2846
|
time2(" adjustCoordinateSystem", () => adjust(g));
|
|
2781
2847
|
time2(" position", () => position(g, opts.corePath));
|
|
2782
2848
|
time2(" positionSelfEdges", () => positionSelfEdges(g));
|
|
2783
|
-
|
|
2849
|
+
const rawNodes = JSON.parse(JSON.stringify(g._nodes));
|
|
2784
2850
|
time2(" removeBorderNodes", () => removeBorderNodes(g));
|
|
2785
2851
|
time2(" normalize.undo", () => undo2(g));
|
|
2786
2852
|
time2(" fixupEdgeLabelCoords", () => fixupEdgeLabelCoords(g));
|
|
@@ -2789,7 +2855,7 @@ var dagre = (() => {
|
|
|
2789
2855
|
time2(" assignNodeIntersects", () => assignNodeIntersects(g));
|
|
2790
2856
|
time2(" reversePoints", () => reversePointsForReversedEdges(g));
|
|
2791
2857
|
time2(" acyclic.undo", () => undo(g));
|
|
2792
|
-
|
|
2858
|
+
return { graph: g, rawNodes };
|
|
2793
2859
|
}
|
|
2794
2860
|
function updateInputGraph(inputGraph, layoutGraph) {
|
|
2795
2861
|
inputGraph.nodes().forEach((v2) => {
|
|
@@ -2834,7 +2900,7 @@ var dagre = (() => {
|
|
|
2834
2900
|
};
|
|
2835
2901
|
var edgeAttrs = ["labelpos"];
|
|
2836
2902
|
function buildLayoutGraph(inputGraph) {
|
|
2837
|
-
const g = new
|
|
2903
|
+
const g = new Graph({ multigraph: true, compound: true });
|
|
2838
2904
|
const graph = canonicalize(inputGraph.graph());
|
|
2839
2905
|
g.setGraph(Object.assign(
|
|
2840
2906
|
{},
|
|
@@ -3144,7 +3210,7 @@ var dagre = (() => {
|
|
|
3144
3210
|
// lib/debug.ts
|
|
3145
3211
|
function debugOrdering(graph) {
|
|
3146
3212
|
const layerMatrix = buildLayerMatrix(graph);
|
|
3147
|
-
const h = new
|
|
3213
|
+
const h = new Graph({ compound: true, multigraph: true }).setGraph({});
|
|
3148
3214
|
graph.nodes().forEach((node) => {
|
|
3149
3215
|
h.setNode(node, { label: node });
|
|
3150
3216
|
h.setParent(node, "layer" + graph.node(node).rank);
|
|
@@ -3164,7 +3230,7 @@ var dagre = (() => {
|
|
|
3164
3230
|
// index.ts
|
|
3165
3231
|
var util = { time, notime };
|
|
3166
3232
|
var dagre = {
|
|
3167
|
-
graphlib:
|
|
3233
|
+
graphlib: graph_lib_exports,
|
|
3168
3234
|
version,
|
|
3169
3235
|
layout,
|
|
3170
3236
|
debug: debugOrdering,
|