@antv/layout 1.2.13 → 1.2.14-beta.0
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/85db61ddc757dae66e04.worker.js +2 -0
- package/dist/85db61ddc757dae66e04.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib/{dagre → antv-dagre}/acyclic.d.ts +1 -1
- package/lib/antv-dagre/acyclic.js +65 -0
- package/lib/antv-dagre/acyclic.js.map +1 -0
- package/lib/antv-dagre/add-border-segments.js +41 -0
- package/lib/antv-dagre/add-border-segments.js.map +1 -0
- package/lib/{dagre → antv-dagre}/coordinate-system.d.ts +2 -1
- package/lib/antv-dagre/coordinate-system.js +69 -0
- package/lib/antv-dagre/coordinate-system.js.map +1 -0
- package/lib/{dagre → antv-dagre}/data/list.d.ts +1 -1
- package/lib/{dagre → antv-dagre}/data/list.js +23 -22
- package/lib/antv-dagre/data/list.js.map +1 -0
- package/lib/{dagre → antv-dagre}/greedy-fas.d.ts +2 -2
- package/lib/antv-dagre/greedy-fas.js +141 -0
- package/lib/antv-dagre/greedy-fas.js.map +1 -0
- package/lib/{dagre → antv-dagre}/layout.d.ts +2 -1
- package/lib/{dagre → antv-dagre}/layout.js +156 -154
- package/lib/antv-dagre/layout.js.map +1 -0
- package/lib/{dagre → antv-dagre}/nesting-graph.js +42 -39
- package/lib/antv-dagre/nesting-graph.js.map +1 -0
- package/lib/{dagre → antv-dagre}/normalize.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/normalize.js +29 -25
- package/lib/antv-dagre/normalize.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/add-subgraph-constraints.js +13 -9
- package/lib/antv-dagre/order/add-subgraph-constraints.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/barycenter.d.ts +2 -2
- package/lib/antv-dagre/order/barycenter.js +27 -0
- package/lib/antv-dagre/order/barycenter.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/build-layer-graph.js +23 -23
- package/lib/antv-dagre/order/build-layer-graph.js.map +1 -0
- package/lib/antv-dagre/order/cross-count.d.ts +3 -0
- package/lib/{dagre → antv-dagre}/order/cross-count.js +21 -17
- package/lib/antv-dagre/order/cross-count.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/index.d.ts +1 -1
- package/lib/antv-dagre/order/index.js +95 -0
- package/lib/antv-dagre/order/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/init-data-order.js +12 -9
- package/lib/antv-dagre/order/init-data-order.js.map +1 -0
- package/lib/antv-dagre/order/init-order.js +51 -0
- package/lib/antv-dagre/order/init-order.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/resolve-conflicts.d.ts +3 -3
- package/lib/{dagre → antv-dagre}/order/resolve-conflicts.js +35 -36
- package/lib/antv-dagre/order/resolve-conflicts.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/sort-subgraph.js +28 -23
- package/lib/antv-dagre/order/sort-subgraph.js.map +1 -0
- package/lib/{dagre → antv-dagre}/order/sort.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/order/sort.js +23 -19
- package/lib/antv-dagre/order/sort.js.map +1 -0
- package/lib/{dagre → antv-dagre}/parent-dummy-chains.js +32 -28
- package/lib/antv-dagre/parent-dummy-chains.js.map +1 -0
- package/lib/{dagre → antv-dagre}/position/bk.d.ts +5 -4
- package/lib/{dagre → antv-dagre}/position/bk.js +162 -148
- package/lib/antv-dagre/position/bk.js.map +1 -0
- package/lib/{dagre → antv-dagre}/position/index.d.ts +2 -1
- package/lib/antv-dagre/position/index.js +55 -0
- package/lib/antv-dagre/position/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/feasible-tree.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/feasible-tree.js +42 -38
- package/lib/antv-dagre/rank/feasible-tree.js.map +1 -0
- package/lib/antv-dagre/rank/index.d.ts +2 -0
- package/lib/{dagre → antv-dagre}/rank/index.js +17 -13
- package/lib/antv-dagre/rank/index.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/network-simplex.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/network-simplex.js +90 -81
- package/lib/antv-dagre/rank/network-simplex.js.map +1 -0
- package/lib/{dagre → antv-dagre}/rank/util.d.ts +2 -2
- package/lib/{dagre → antv-dagre}/rank/util.js +37 -32
- package/lib/antv-dagre/rank/util.js.map +1 -0
- package/lib/antv-dagre/types.d.ts +2 -0
- package/lib/antv-dagre/types.js +3 -0
- package/lib/antv-dagre/types.js.map +1 -0
- package/lib/{dagre → antv-dagre}/util.d.ts +1 -1
- package/lib/antv-dagre/util.js +299 -0
- package/lib/antv-dagre/util.js.map +1 -0
- package/lib/antv-dagre.d.ts +50 -0
- package/lib/antv-dagre.js +542 -0
- package/lib/antv-dagre.js.map +1 -0
- package/lib/bundle-entry.d.ts +2 -18
- package/lib/bundle-entry.js +5 -18
- package/lib/bundle-entry.js.map +1 -1
- package/lib/bundle-supervisor.d.ts +4 -22
- package/lib/bundle-supervisor.js +59 -54
- package/lib/bundle-supervisor.js.map +1 -1
- package/lib/bundle-worker.d.ts +1 -1
- package/lib/bundle-worker.js +38 -35
- package/lib/bundle-worker.js.map +1 -1
- package/lib/circular.d.ts +1 -1
- package/lib/circular.js +133 -145
- package/lib/circular.js.map +1 -1
- package/lib/comboCombined.d.ts +1 -1
- package/lib/comboCombined.js +273 -299
- package/lib/comboCombined.js.map +1 -1
- package/lib/concentric.d.ts +1 -1
- package/lib/concentric.js +173 -179
- package/lib/concentric.js.map +1 -1
- package/lib/d3Force/forceInBox.js +80 -78
- package/lib/d3Force/forceInBox.js.map +1 -1
- package/lib/d3Force/index.d.ts +2 -2
- package/lib/d3Force/index.js +207 -229
- package/lib/d3Force/index.js.map +1 -1
- package/lib/dagre.d.ts +13 -24
- package/lib/dagre.js +61 -542
- package/lib/dagre.js.map +1 -1
- package/lib/exports.d.ts +17 -0
- package/lib/exports.js +20 -0
- package/lib/exports.js.map +1 -0
- package/lib/force/forceNBody.js +48 -47
- package/lib/force/forceNBody.js.map +1 -1
- package/lib/force/index.d.ts +1 -1
- package/lib/force/index.js +301 -324
- package/lib/force/index.js.map +1 -1
- package/lib/force/types.d.ts +5 -5
- package/lib/force/types.js +2 -1
- package/lib/forceAtlas2/body.d.ts +1 -1
- package/lib/forceAtlas2/body.js +32 -31
- package/lib/forceAtlas2/body.js.map +1 -1
- package/lib/forceAtlas2/index.d.ts +1 -1
- package/lib/forceAtlas2/index.js +219 -227
- package/lib/forceAtlas2/index.js.map +1 -1
- package/lib/forceAtlas2/quad.d.ts +2 -2
- package/lib/forceAtlas2/quad.js +43 -42
- package/lib/forceAtlas2/quad.js.map +1 -1
- package/lib/forceAtlas2/quadTree.js +19 -17
- package/lib/forceAtlas2/quadTree.js.map +1 -1
- package/lib/fruchterman.d.ts +1 -1
- package/lib/fruchterman.js +203 -219
- package/lib/fruchterman.js.map +1 -1
- package/lib/grid.d.ts +1 -1
- package/lib/grid.js +201 -207
- package/lib/grid.js.map +1 -1
- package/lib/index.d.ts +1 -15
- package/lib/index.js +5 -16
- package/lib/index.js.map +1 -1
- package/lib/mds.d.ts +1 -1
- package/lib/mds.js +73 -79
- package/lib/mds.js.map +1 -1
- package/lib/radial/index.d.ts +1 -1
- package/lib/radial/index.js +183 -186
- package/lib/radial/index.js.map +1 -1
- package/lib/radial/mds.d.ts +1 -1
- package/lib/radial/mds.js +20 -14
- package/lib/radial/mds.js.map +1 -1
- package/lib/radial/radial-nonoverlap-force.d.ts +2 -2
- package/lib/radial/radial-nonoverlap-force.js +40 -37
- package/lib/radial/radial-nonoverlap-force.js.map +1 -1
- package/lib/random.d.ts +1 -1
- package/lib/random.js +57 -66
- package/lib/random.js.map +1 -1
- package/lib/registry.d.ts +2 -2
- package/lib/registry.js +30 -25
- package/lib/registry.js.map +1 -1
- package/lib/supervisor.d.ts +2 -3
- package/lib/supervisor.js +63 -58
- package/lib/supervisor.js.map +1 -1
- package/lib/types.d.ts +20 -75
- package/lib/types.js +5 -1
- package/lib/types.js.map +1 -1
- package/lib/util/array.js +4 -1
- package/lib/util/array.js.map +1 -1
- package/lib/util/common.d.ts +1 -1
- package/lib/util/common.js +11 -8
- package/lib/util/common.js.map +1 -1
- package/lib/util/function.js +41 -37
- package/lib/util/function.js.map +1 -1
- package/lib/util/index.d.ts +0 -2
- package/lib/util/index.js +7 -6
- package/lib/util/index.js.map +1 -1
- package/lib/util/math.d.ts +1 -26
- package/lib/util/math.js +55 -154
- package/lib/util/math.js.map +1 -1
- package/lib/util/object.d.ts +1 -1
- package/lib/util/object.js +20 -15
- package/lib/util/object.js.map +1 -1
- package/lib/util/size.d.ts +3 -0
- package/lib/util/size.js +16 -0
- package/lib/util/size.js.map +1 -0
- package/lib/worker.js +36 -35
- package/lib/worker.js.map +1 -1
- package/package.json +10 -6
- package/dist/aa1bb0ccc06b11cf79c1.worker.js +0 -2
- package/dist/aa1bb0ccc06b11cf79c1.worker.js.map +0 -1
- package/lib/dagre/acyclic.js +0 -62
- package/lib/dagre/acyclic.js.map +0 -1
- package/lib/dagre/add-border-segments.js +0 -37
- package/lib/dagre/add-border-segments.js.map +0 -1
- package/lib/dagre/coordinate-system.js +0 -65
- package/lib/dagre/coordinate-system.js.map +0 -1
- package/lib/dagre/data/list.js.map +0 -1
- package/lib/dagre/greedy-fas.js +0 -147
- package/lib/dagre/greedy-fas.js.map +0 -1
- package/lib/dagre/layout.js.map +0 -1
- package/lib/dagre/nesting-graph.js.map +0 -1
- package/lib/dagre/normalize.js.map +0 -1
- package/lib/dagre/order/add-subgraph-constraints.js.map +0 -1
- package/lib/dagre/order/barycenter.js +0 -23
- package/lib/dagre/order/barycenter.js.map +0 -1
- package/lib/dagre/order/build-layer-graph.js.map +0 -1
- package/lib/dagre/order/cross-count.d.ts +0 -3
- package/lib/dagre/order/cross-count.js.map +0 -1
- package/lib/dagre/order/index.js +0 -91
- package/lib/dagre/order/index.js.map +0 -1
- package/lib/dagre/order/init-data-order.js.map +0 -1
- package/lib/dagre/order/init-order.js +0 -50
- package/lib/dagre/order/init-order.js.map +0 -1
- package/lib/dagre/order/resolve-conflicts.js.map +0 -1
- package/lib/dagre/order/sort-subgraph.js.map +0 -1
- package/lib/dagre/order/sort.js.map +0 -1
- package/lib/dagre/parent-dummy-chains.js.map +0 -1
- package/lib/dagre/position/bk.js.map +0 -1
- package/lib/dagre/position/index.js +0 -54
- package/lib/dagre/position/index.js.map +0 -1
- package/lib/dagre/rank/feasible-tree.js.map +0 -1
- package/lib/dagre/rank/index.d.ts +0 -2
- package/lib/dagre/rank/index.js.map +0 -1
- package/lib/dagre/rank/network-simplex.js.map +0 -1
- package/lib/dagre/rank/util.js.map +0 -1
- package/lib/dagre/util.js +0 -289
- package/lib/dagre/util.js.map +0 -1
- package/lib/util/gpu.d.ts +0 -45
- package/lib/util/gpu.js +0 -214
- package/lib/util/gpu.js.map +0 -1
- package/lib/util/number.d.ts +0 -1
- package/lib/util/number.js +0 -5
- package/lib/util/number.js.map +0 -1
- package/lib/util/string.d.ts +0 -1
- package/lib/util/string.js +0 -15
- package/lib/util/string.js.map +0 -1
- /package/lib/{dagre → antv-dagre}/add-border-segments.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/nesting-graph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/add-subgraph-constraints.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/build-layer-graph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/init-data-order.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/init-order.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/order/sort-subgraph.d.ts +0 -0
- /package/lib/{dagre → antv-dagre}/parent-dummy-chains.d.ts +0 -0
package/lib/bundle-supervisor.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Supervisor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const event_emitter_1 = tslib_1.__importDefault(require("@antv/event-emitter"));
|
|
4
6
|
// @ts-ignore
|
|
5
7
|
// Inline the worker as a Blob. @see https://github.com/developit/workerize-loader#inline
|
|
6
|
-
|
|
8
|
+
const bundle_worker_1 = tslib_1.__importDefault(require("workerize-loader?inline!./bundle-worker"));
|
|
7
9
|
/**
|
|
8
10
|
* @example
|
|
9
11
|
* const graph = new Graph();
|
|
@@ -14,17 +16,15 @@ import worker from "workerize-loader?inline!./bundle-worker";
|
|
|
14
16
|
* supervisor.stop();
|
|
15
17
|
* supervisor.kill();
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this.spawnWorker();
|
|
25
|
-
return _this;
|
|
19
|
+
class Supervisor extends event_emitter_1.default {
|
|
20
|
+
constructor(graph, layout, options) {
|
|
21
|
+
super();
|
|
22
|
+
this.graph = graph;
|
|
23
|
+
this.layout = layout;
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.spawnWorker();
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
spawnWorker() {
|
|
28
28
|
if (this.worker) {
|
|
29
29
|
this.worker.terminate();
|
|
30
30
|
}
|
|
@@ -35,60 +35,65 @@ var Supervisor = /** @class */ (function (_super) {
|
|
|
35
35
|
// this.worker.addEventListener('message', this.handleWorkerMessage);
|
|
36
36
|
// Use workerize-loader to create WebWorker.
|
|
37
37
|
// @see https://github.com/developit/workerize-loader
|
|
38
|
-
this.worker =
|
|
38
|
+
this.worker = (0, bundle_worker_1.default)();
|
|
39
39
|
if (this.running) {
|
|
40
40
|
this.running = false;
|
|
41
41
|
this.execute();
|
|
42
42
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
}
|
|
44
|
+
execute() {
|
|
45
45
|
var _a;
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (this.running)
|
|
48
|
+
return this;
|
|
49
|
+
this.running = true;
|
|
50
|
+
// Payload should include nodes & edges(if needed).
|
|
51
|
+
const _b = this.layout.options, { onTick } = _b, rest = tslib_1.__rest(_b, ["onTick"]);
|
|
52
|
+
const payload = {
|
|
53
|
+
layout: {
|
|
54
|
+
id: this.layout.id,
|
|
55
|
+
options: rest,
|
|
56
|
+
iterations: (_a = this.options) === null || _a === void 0 ? void 0 : _a.iterations,
|
|
57
|
+
},
|
|
58
|
+
nodes: this.graph.getAllNodes(),
|
|
59
|
+
edges: this.graph.getAllEdges(),
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* TODO: Convert graph object to linear memory(e.g. csr, adjacency matrix), then transfer the ownership to worker.
|
|
63
|
+
* @example
|
|
64
|
+
* const arraybufferWithNodesEdges = graphToByteArrays(this.graph); // Float32Array
|
|
65
|
+
*/
|
|
66
|
+
const arraybufferWithNodesEdges = new Float32Array([0]);
|
|
67
|
+
// TODO: Support transferables.
|
|
68
|
+
// @see https://www.npmjs.com/package/@naoak/workerize-transferable
|
|
69
|
+
// setupTransferableMethodsOnMain(this.worker, {
|
|
70
|
+
// calculateLayout: {
|
|
71
|
+
// // pick a transferable object from the method parameters
|
|
72
|
+
// pickTransferablesFromParams: (params) => [params[1].buffer],
|
|
73
|
+
// },
|
|
74
|
+
// });
|
|
75
|
+
const [positions] = yield this.worker.calculateLayout(payload, [
|
|
76
|
+
arraybufferWithNodesEdges,
|
|
77
|
+
]);
|
|
78
|
+
return positions;
|
|
73
79
|
});
|
|
74
|
-
}
|
|
75
|
-
|
|
80
|
+
}
|
|
81
|
+
stop() {
|
|
76
82
|
this.running = false;
|
|
77
83
|
// trigger `layout.stop()` if needed
|
|
78
84
|
this.worker.stopLayout();
|
|
79
85
|
return this;
|
|
80
|
-
}
|
|
81
|
-
|
|
86
|
+
}
|
|
87
|
+
kill() {
|
|
82
88
|
if (this.worker) {
|
|
83
89
|
this.worker.terminate();
|
|
84
90
|
}
|
|
85
91
|
// TODO: unbind listeners on graph.
|
|
86
92
|
// TODO: release attached memory
|
|
87
|
-
}
|
|
88
|
-
|
|
93
|
+
}
|
|
94
|
+
isRunning() {
|
|
89
95
|
return this.running;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
export { Supervisor };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.Supervisor = Supervisor;
|
|
94
99
|
//# sourceMappingURL=bundle-supervisor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-supervisor.js","sourceRoot":"","sources":["../src/bundle-supervisor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle-supervisor.js","sourceRoot":"","sources":["../src/bundle-supervisor.ts"],"names":[],"mappings":";;;;AAAA,gFAA+C;AAG/C,aAAa;AACb,yFAAyF;AACzF,oGAA6D;AAG7D;;;;;;;;;GASG;AACH,MAAa,UAAW,SAAQ,uBAAY;IAW1C,YACU,KAAsB,EACtB,MAAmB,EACnB,OAAoC;QAE5C,KAAK,EAAE,CAAC;QAJA,UAAK,GAAL,KAAK,CAAiB;QACtB,WAAM,GAAN,MAAM,CAAa;QACnB,YAAO,GAAP,OAAO,CAA6B;QAI5C,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;SACzB;QAED;;WAEG;QACH,yDAAyD;QACzD,qEAAqE;QAErE,4CAA4C;QAC5C,qDAAqD;QACrD,IAAI,CAAC,MAAM,GAAG,IAAA,uBAAM,GAAE,CAAC;QAEvB,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;IACH,CAAC;IAEK,OAAO;;;YACX,IAAI,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAC;YAE9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YAEpB,mDAAmD;YACnD,MAAM,KAAsB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAzC,EAAE,MAAM,OAAiC,EAA5B,IAAI,sBAAjB,UAAmB,CAAsB,CAAC;YAChD,MAAM,OAAO,GAAG;gBACd,MAAM,EAAE;oBACN,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;oBAClB,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU;iBACrC;gBACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;gBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;aAChC,CAAC;YAEF;;;;eAIG;YACH,MAAM,yBAAyB,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExD,+BAA+B;YAC/B,mEAAmE;YACnE,gDAAgD;YAChD,uBAAuB;YACvB,+DAA+D;YAC/D,mEAAmE;YACnE,OAAO;YACP,MAAM;YAEN,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE;gBAC7D,yBAAyB;aAC1B,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC;;KAClB;IAED,IAAI;QACF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,oCAAoC;QACpC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAEzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;SACzB;QAED,mCAAmC;QAEnC,gCAAgC;IAClC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAxGD,gCAwGC"}
|
package/lib/bundle-worker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Payload } from
|
|
1
|
+
import type { Payload } from './supervisor';
|
|
2
2
|
export declare function stopLayout(): void;
|
|
3
3
|
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): Promise<(import("./types").LayoutMapping | Float32Array[])[]>;
|
package/lib/bundle-worker.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateLayout = exports.stopLayout = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphlib_1 = require("@antv/graphlib");
|
|
3
6
|
// import { setupTransferableMethodsOnWorker } from "@naoak/workerize-transferable";
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
const registry_1 = require("./registry");
|
|
8
|
+
const types_1 = require("./types");
|
|
6
9
|
// @see https://www.npmjs.com/package/@naoak/workerize-transferable
|
|
7
10
|
// setupTransferableMethodsOnWorker({
|
|
8
11
|
// // The name of function which use some transferables.
|
|
@@ -13,41 +16,41 @@ import { isLayoutWithIterations } from "./types";
|
|
|
13
16
|
// pickTransferablesFromResult: (result) => [result[1].buffer],
|
|
14
17
|
// },
|
|
15
18
|
// });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if ((_a = currentLayout) === null || _a === void 0 ? void 0 : _a.stop) {
|
|
19
|
+
let currentLayout;
|
|
20
|
+
function stopLayout() {
|
|
21
|
+
if (currentLayout === null || currentLayout === void 0 ? void 0 : currentLayout.stop) {
|
|
20
22
|
currentLayout.stop();
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
layoutCtor = registry[id];
|
|
35
|
-
if (layoutCtor) {
|
|
36
|
-
currentLayout = new layoutCtor(options);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error("Unknown layout id: " + id);
|
|
40
|
-
}
|
|
41
|
-
return [4 /*yield*/, currentLayout.execute(graph)];
|
|
42
|
-
case 1:
|
|
43
|
-
positions = _b.sent();
|
|
44
|
-
if (isLayoutWithIterations(currentLayout)) {
|
|
45
|
-
currentLayout.stop();
|
|
46
|
-
positions = currentLayout.tick(iterations);
|
|
47
|
-
}
|
|
48
|
-
return [2 /*return*/, [positions, transferables]];
|
|
49
|
-
}
|
|
25
|
+
exports.stopLayout = stopLayout;
|
|
26
|
+
function calculateLayout(payload, transferables) {
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const { layout: { id, options, iterations }, nodes, edges, } = payload;
|
|
29
|
+
// Sync graph on the worker side.
|
|
30
|
+
// TODO: Use transferable objects like ArrayBuffer for nodes & edges,
|
|
31
|
+
// in which case we don't need the whole graph.
|
|
32
|
+
// @see https://github.com/graphology/graphology/blob/master/src/layout-noverlap/webworker.tpl.js#L32
|
|
33
|
+
const graph = new graphlib_1.Graph({
|
|
34
|
+
nodes,
|
|
35
|
+
edges,
|
|
50
36
|
});
|
|
37
|
+
/**
|
|
38
|
+
* Create layout instance on the worker side.
|
|
39
|
+
*/
|
|
40
|
+
const layoutCtor = registry_1.registry[id];
|
|
41
|
+
if (layoutCtor) {
|
|
42
|
+
currentLayout = new layoutCtor(options);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error(`Unknown layout id: ${id}`);
|
|
46
|
+
}
|
|
47
|
+
let positions = yield currentLayout.execute(graph);
|
|
48
|
+
if ((0, types_1.isLayoutWithIterations)(currentLayout)) {
|
|
49
|
+
currentLayout.stop();
|
|
50
|
+
positions = currentLayout.tick(iterations);
|
|
51
|
+
}
|
|
52
|
+
return [positions, transferables];
|
|
51
53
|
});
|
|
52
54
|
}
|
|
55
|
+
exports.calculateLayout = calculateLayout;
|
|
53
56
|
//# sourceMappingURL=bundle-worker.js.map
|
package/lib/bundle-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-worker.js","sourceRoot":"","sources":["../src/bundle-worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle-worker.js","sourceRoot":"","sources":["../src/bundle-worker.ts"],"names":[],"mappings":";;;;AAAA,6CAAuC;AACvC,oFAAoF;AACpF,yCAAsC;AAEtC,mCAA+E;AAE/E,mEAAmE;AACnE,qCAAqC;AACrC,0DAA0D;AAC1D,uBAAuB;AACvB,6CAA6C;AAC7C,2BAA2B;AAC3B,yFAAyF;AACzF,mEAAmE;AACnE,OAAO;AACP,MAAM;AAEN,IAAI,aAA0B,CAAC;AAE/B,SAAgB,UAAU;IACxB,IAAK,aAA2C,aAA3C,aAAa,uBAAb,aAAa,CAAgC,IAAI,EAAE;QACrD,aAA2C,CAAC,IAAI,EAAE,CAAC;KACrD;AACH,CAAC;AAJD,gCAIC;AAED,SAAsB,eAAe,CACnC,OAAgB,EAChB,aAA6B;;QAE7B,MAAM,EACJ,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EACnC,KAAK,EACL,KAAK,GACN,GAAG,OAAO,CAAC;QAEZ,iCAAiC;QACjC,qEAAqE;QACrE,+CAA+C;QAC/C,qGAAqG;QACrG,MAAM,KAAK,GAAG,IAAI,gBAAK,CAAC;YACtB,KAAK;YACL,KAAK;SACN,CAAC,CAAC;QAEH;;WAEG;QAEH,MAAM,UAAU,GAAG,mBAAQ,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,UAAU,EAAE;YACd,aAAa,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;SACzC;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;SAC7C;QAED,IAAI,SAAS,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,IAAA,8BAAsB,EAAC,aAAa,CAAC,EAAE;YACzC,aAAa,CAAC,IAAI,EAAE,CAAC;YACrB,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC5C;QACD,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACpC,CAAC;CAAA;AApCD,0CAoCC"}
|
package/lib/circular.d.ts
CHANGED
package/lib/circular.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CircularLayout = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
const common_1 = require("./util/common");
|
|
7
|
+
const DEFAULTS_LAYOUT_OPTIONS = {
|
|
5
8
|
radius: null,
|
|
6
9
|
startRadius: null,
|
|
7
10
|
endRadius: null,
|
|
@@ -27,138 +30,126 @@ var DEFAULTS_LAYOUT_OPTIONS = {
|
|
|
27
30
|
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
28
31
|
* await layout.assign(graph, { radius: 20 });
|
|
29
32
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (options === void 0) { options = {}; }
|
|
33
|
+
class CircularLayout {
|
|
34
|
+
constructor(options = {}) {
|
|
33
35
|
this.options = options;
|
|
34
36
|
this.id = 'circular';
|
|
35
|
-
this.options =
|
|
37
|
+
this.options = Object.assign(Object.assign({}, DEFAULTS_LAYOUT_OPTIONS), options);
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Return the positions of nodes and edges(if needed).
|
|
39
41
|
*/
|
|
40
|
-
|
|
41
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
-
return
|
|
43
|
-
return [2 /*return*/, this.genericCircularLayout(false, graph, options)];
|
|
44
|
-
});
|
|
42
|
+
execute(graph, options) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this.genericCircularLayout(false, graph, options);
|
|
45
45
|
});
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
/**
|
|
48
48
|
* To directly assign the positions to the nodes.
|
|
49
49
|
*/
|
|
50
|
-
|
|
51
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
|
|
53
|
-
switch (_a.label) {
|
|
54
|
-
case 0: return [4 /*yield*/, this.genericCircularLayout(true, graph, options)];
|
|
55
|
-
case 1:
|
|
56
|
-
_a.sent();
|
|
57
|
-
return [2 /*return*/];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
50
|
+
assign(graph, options) {
|
|
51
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
yield this.genericCircularLayout(true, graph, options);
|
|
60
53
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
54
|
+
}
|
|
55
|
+
genericCircularLayout(assign, graph, options) {
|
|
56
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const mergedOptions = Object.assign(Object.assign({}, this.options), options);
|
|
58
|
+
const { width, height, center, divisions, startAngle = 0, endAngle = 2 * Math.PI, angleRatio, ordering, clockwise, nodeSpacing: paramNodeSpacing, nodeSize: paramNodeSize, } = mergedOptions;
|
|
59
|
+
const nodes = graph.getAllNodes();
|
|
60
|
+
const edges = graph.getAllEdges();
|
|
61
|
+
// Calculate center according to `window` if not provided.
|
|
62
|
+
const [calculatedWidth, calculatedHeight, calculatedCenter] = calculateCenter(width, height, center);
|
|
63
|
+
const n = nodes === null || nodes === void 0 ? void 0 : nodes.length;
|
|
64
|
+
if (!n || n === 1) {
|
|
65
|
+
return (0, common_1.handleSingleNodeGraph)(graph, assign, calculatedCenter);
|
|
66
|
+
}
|
|
67
|
+
const angleStep = (endAngle - startAngle) / n;
|
|
68
|
+
let { radius, startRadius, endRadius } = mergedOptions;
|
|
69
|
+
if (paramNodeSpacing) {
|
|
70
|
+
const nodeSpacing = (0, util_1.formatNumberFn)(10, paramNodeSpacing);
|
|
71
|
+
const nodeSize = (0, util_1.formatSizeFn)(10, paramNodeSize);
|
|
72
|
+
let maxNodeSize = -Infinity;
|
|
73
|
+
nodes.forEach((node) => {
|
|
74
|
+
const nSize = nodeSize(node);
|
|
75
|
+
if (maxNodeSize < nSize)
|
|
76
|
+
maxNodeSize = nSize;
|
|
77
|
+
});
|
|
78
|
+
let perimeter = 0;
|
|
79
|
+
nodes.forEach((node, i) => {
|
|
80
|
+
if (i === 0)
|
|
81
|
+
perimeter += maxNodeSize || 10;
|
|
82
|
+
else
|
|
83
|
+
perimeter += (nodeSpacing(node) || 0) + (maxNodeSize || 10);
|
|
84
|
+
});
|
|
85
|
+
radius = perimeter / (2 * Math.PI);
|
|
86
|
+
}
|
|
87
|
+
else if (!radius && !startRadius && !endRadius) {
|
|
88
|
+
radius = Math.min(calculatedHeight, calculatedWidth) / 2;
|
|
89
|
+
}
|
|
90
|
+
else if (!startRadius && endRadius) {
|
|
91
|
+
startRadius = endRadius;
|
|
92
|
+
}
|
|
93
|
+
else if (startRadius && !endRadius) {
|
|
94
|
+
endRadius = startRadius;
|
|
95
|
+
}
|
|
96
|
+
const astep = angleStep * angleRatio;
|
|
97
|
+
// calculated nodes as temporary result
|
|
98
|
+
let layoutNodes = [];
|
|
99
|
+
if (ordering === 'topology') {
|
|
100
|
+
// layout according to the topology
|
|
101
|
+
layoutNodes = topologyOrdering(graph, nodes);
|
|
102
|
+
}
|
|
103
|
+
else if (ordering === 'topology-directed') {
|
|
104
|
+
// layout according to the topology
|
|
105
|
+
layoutNodes = topologyOrdering(graph, nodes, true);
|
|
106
|
+
}
|
|
107
|
+
else if (ordering === 'degree') {
|
|
108
|
+
// layout according to the descent order of degrees
|
|
109
|
+
layoutNodes = degreeOrdering(graph, nodes);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// layout according to the original order in the data.nodes
|
|
113
|
+
layoutNodes = nodes.map((node) => (0, util_1.cloneFormatData)(node));
|
|
114
|
+
}
|
|
115
|
+
const divN = Math.ceil(n / divisions); // node number in each division
|
|
116
|
+
for (let i = 0; i < n; ++i) {
|
|
117
|
+
let r = radius;
|
|
118
|
+
if (!r && startRadius !== null && endRadius !== null) {
|
|
119
|
+
r = startRadius + (i * (endRadius - startRadius)) / (n - 1);
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
layoutNodes = nodes.map(function (node) { return cloneFormatData(node); });
|
|
121
|
+
if (!r) {
|
|
122
|
+
r = 10 + (i * 100) / (n - 1);
|
|
121
123
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
angle = startAngle +
|
|
132
|
-
(i % divN) * astep +
|
|
133
|
-
((2 * Math.PI) / divisions) * Math.floor(i / divN);
|
|
134
|
-
if (!clockwise) {
|
|
135
|
-
angle =
|
|
136
|
-
endAngle -
|
|
137
|
-
(i % divN) * astep -
|
|
138
|
-
((2 * Math.PI) / divisions) * Math.floor(i / divN);
|
|
139
|
-
}
|
|
140
|
-
layoutNodes[i].data.x = calculatedCenter[0] + Math.cos(angle) * r;
|
|
141
|
-
layoutNodes[i].data.y = calculatedCenter[1] + Math.sin(angle) * r;
|
|
124
|
+
let angle = startAngle +
|
|
125
|
+
(i % divN) * astep +
|
|
126
|
+
((2 * Math.PI) / divisions) * Math.floor(i / divN);
|
|
127
|
+
if (!clockwise) {
|
|
128
|
+
angle =
|
|
129
|
+
endAngle -
|
|
130
|
+
(i % divN) * astep -
|
|
131
|
+
((2 * Math.PI) / divisions) * Math.floor(i / divN);
|
|
142
132
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
133
|
+
layoutNodes[i].data.x = calculatedCenter[0] + Math.cos(angle) * r;
|
|
134
|
+
layoutNodes[i].data.y = calculatedCenter[1] + Math.sin(angle) * r;
|
|
135
|
+
}
|
|
136
|
+
if (assign) {
|
|
137
|
+
layoutNodes.forEach((node) => {
|
|
138
|
+
graph.mergeNodeData(node.id, {
|
|
139
|
+
x: node.data.x,
|
|
140
|
+
y: node.data.y,
|
|
149
141
|
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const result = {
|
|
145
|
+
nodes: layoutNodes,
|
|
146
|
+
edges,
|
|
147
|
+
};
|
|
148
|
+
return result;
|
|
157
149
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
export { CircularLayout };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.CircularLayout = CircularLayout;
|
|
162
153
|
/**
|
|
163
154
|
* order the nodes acoording to the graph topology
|
|
164
155
|
* @param graph
|
|
@@ -166,44 +157,43 @@ export { CircularLayout };
|
|
|
166
157
|
* @param directed
|
|
167
158
|
* @returns
|
|
168
159
|
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
var n = nodes.length;
|
|
160
|
+
const topologyOrdering = (graph, nodes, directed = false) => {
|
|
161
|
+
const orderedCNodes = [(0, util_1.cloneFormatData)(nodes[0])];
|
|
162
|
+
const pickFlags = {};
|
|
163
|
+
const n = nodes.length;
|
|
174
164
|
pickFlags[nodes[0].id] = true;
|
|
175
165
|
// write children into cnodes
|
|
176
|
-
|
|
177
|
-
nodes.forEach(
|
|
166
|
+
let k = 0;
|
|
167
|
+
nodes.forEach((node, i) => {
|
|
178
168
|
if (i !== 0) {
|
|
179
169
|
if ((i === n - 1 ||
|
|
180
170
|
graph.getDegree(node.id, 'both') !==
|
|
181
171
|
graph.getDegree(nodes[i + 1].id, 'both') ||
|
|
182
172
|
graph.areNeighbors(orderedCNodes[k].id, node.id)) &&
|
|
183
173
|
!pickFlags[node.id]) {
|
|
184
|
-
orderedCNodes.push(cloneFormatData(node));
|
|
174
|
+
orderedCNodes.push((0, util_1.cloneFormatData)(node));
|
|
185
175
|
pickFlags[node.id] = true;
|
|
186
176
|
k++;
|
|
187
177
|
}
|
|
188
178
|
else {
|
|
189
|
-
|
|
179
|
+
const children = directed
|
|
190
180
|
? graph.getSuccessors(orderedCNodes[k].id)
|
|
191
181
|
: graph.getNeighbors(orderedCNodes[k].id);
|
|
192
|
-
|
|
193
|
-
for (
|
|
194
|
-
|
|
182
|
+
let foundChild = false;
|
|
183
|
+
for (let j = 0; j < children.length; j++) {
|
|
184
|
+
const child = children[j];
|
|
195
185
|
if (graph.getDegree(child.id) === graph.getDegree(node.id) &&
|
|
196
186
|
!pickFlags[child.id]) {
|
|
197
|
-
orderedCNodes.push(cloneFormatData(child));
|
|
187
|
+
orderedCNodes.push((0, util_1.cloneFormatData)(child));
|
|
198
188
|
pickFlags[child.id] = true;
|
|
199
189
|
foundChild = true;
|
|
200
190
|
break;
|
|
201
191
|
}
|
|
202
192
|
}
|
|
203
|
-
|
|
193
|
+
let ii = 0;
|
|
204
194
|
while (!foundChild) {
|
|
205
195
|
if (!pickFlags[nodes[ii].id]) {
|
|
206
|
-
orderedCNodes.push(cloneFormatData(nodes[ii]));
|
|
196
|
+
orderedCNodes.push((0, util_1.cloneFormatData)(nodes[ii]));
|
|
207
197
|
pickFlags[nodes[ii].id] = true;
|
|
208
198
|
foundChild = true;
|
|
209
199
|
}
|
|
@@ -224,13 +214,11 @@ var topologyOrdering = function (graph, nodes, directed) {
|
|
|
224
214
|
* @returns
|
|
225
215
|
*/
|
|
226
216
|
function degreeOrdering(graph, nodes) {
|
|
227
|
-
|
|
228
|
-
nodes.forEach(
|
|
229
|
-
orderedNodes.push(cloneFormatData(node));
|
|
230
|
-
});
|
|
231
|
-
orderedNodes.sort(function (nodeA, nodeB) {
|
|
232
|
-
return graph.getDegree(nodeA.id, 'both') - graph.getDegree(nodeB.id, 'both');
|
|
217
|
+
const orderedNodes = [];
|
|
218
|
+
nodes.forEach((node, i) => {
|
|
219
|
+
orderedNodes.push((0, util_1.cloneFormatData)(node));
|
|
233
220
|
});
|
|
221
|
+
orderedNodes.sort((nodeA, nodeB) => graph.getDegree(nodeA.id, 'both') - graph.getDegree(nodeB.id, 'both'));
|
|
234
222
|
return orderedNodes;
|
|
235
223
|
}
|
|
236
224
|
/**
|
|
@@ -240,10 +228,10 @@ function degreeOrdering(graph, nodes) {
|
|
|
240
228
|
* @param center
|
|
241
229
|
* @returns
|
|
242
230
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
231
|
+
const calculateCenter = (width, height, center) => {
|
|
232
|
+
let calculatedWidth = width;
|
|
233
|
+
let calculatedHeight = height;
|
|
234
|
+
let calculatedCenter = center;
|
|
247
235
|
if (!calculatedWidth && typeof window !== 'undefined') {
|
|
248
236
|
calculatedWidth = window.innerWidth;
|
|
249
237
|
}
|