@graphty/layout 1.2.9 → 1.3.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/README.md +393 -403
- package/dist/layout.js +867 -808
- package/dist/layout.js.map +1 -1
- package/dist/src/algorithms/index.d.ts +2 -2
- package/dist/src/algorithms/index.js +2 -2
- package/dist/src/algorithms/index.js.map +1 -1
- package/dist/src/algorithms/optimization/index.d.ts +4 -4
- package/dist/src/algorithms/optimization/index.js +3 -3
- package/dist/src/algorithms/optimization/index.js.map +1 -1
- package/dist/src/algorithms/optimization/kamada-kawai-solver.d.ts +2 -5
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js +6 -9
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js.map +1 -1
- package/dist/src/algorithms/optimization/lbfgs.d.ts +0 -1
- package/dist/src/algorithms/optimization/lbfgs.js +3 -5
- package/dist/src/algorithms/optimization/lbfgs.js.map +1 -1
- package/dist/src/algorithms/optimization/line-search.d.ts +0 -1
- package/dist/src/algorithms/optimization/line-search.js +0 -1
- package/dist/src/algorithms/optimization/line-search.js.map +1 -1
- package/dist/src/algorithms/optimization/types.d.ts +1 -1
- package/dist/src/algorithms/planarity/check.d.ts +2 -2
- package/dist/src/algorithms/planarity/check.js +4 -4
- package/dist/src/algorithms/planarity/check.js.map +1 -1
- package/dist/src/algorithms/planarity/embedding.d.ts +2 -4
- package/dist/src/algorithms/planarity/embedding.js +13 -12
- package/dist/src/algorithms/planarity/embedding.js.map +1 -1
- package/dist/src/algorithms/planarity/index.d.ts +4 -4
- package/dist/src/algorithms/planarity/index.js +4 -4
- package/dist/src/algorithms/planarity/index.js.map +1 -1
- package/dist/src/algorithms/planarity/lr-test.d.ts +2 -2
- package/dist/src/algorithms/planarity/lr-test.js +2 -2
- package/dist/src/algorithms/planarity/lr-test.js.map +1 -1
- package/dist/src/algorithms/planarity/special-graphs.d.ts +1 -4
- package/dist/src/algorithms/planarity/special-graphs.js +18 -15
- package/dist/src/algorithms/planarity/special-graphs.js.map +1 -1
- package/dist/src/generators/basic.d.ts +1 -1
- package/dist/src/generators/basic.js +4 -4
- package/dist/src/generators/basic.js.map +1 -1
- package/dist/src/generators/bipartite.d.ts +1 -1
- package/dist/src/generators/bipartite.js +2 -2
- package/dist/src/generators/bipartite.js.map +1 -1
- package/dist/src/generators/grid.d.ts +1 -1
- package/dist/src/generators/grid.js +1 -1
- package/dist/src/generators/grid.js.map +1 -1
- package/dist/src/generators/index.d.ts +5 -5
- package/dist/src/generators/index.js +5 -5
- package/dist/src/generators/index.js.map +1 -1
- package/dist/src/generators/random.d.ts +1 -1
- package/dist/src/generators/random.js +2 -2
- package/dist/src/generators/random.js.map +1 -1
- package/dist/src/generators/scale-free.d.ts +1 -1
- package/dist/src/generators/scale-free.js +4 -4
- package/dist/src/generators/scale-free.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +4 -4
- package/dist/src/layouts/basic/index.d.ts +1 -1
- package/dist/src/layouts/basic/index.js +1 -1
- package/dist/src/layouts/basic/random.d.ts +1 -2
- package/dist/src/layouts/basic/random.js +3 -4
- package/dist/src/layouts/basic/random.js.map +1 -1
- package/dist/src/layouts/force-directed/arf.d.ts +1 -2
- package/dist/src/layouts/force-directed/arf.js +13 -8
- package/dist/src/layouts/force-directed/arf.js.map +1 -1
- package/dist/src/layouts/force-directed/forceatlas2.d.ts +1 -2
- package/dist/src/layouts/force-directed/forceatlas2.js +58 -35
- package/dist/src/layouts/force-directed/forceatlas2.js.map +1 -1
- package/dist/src/layouts/force-directed/fruchterman-reingold.d.ts +11 -12
- package/dist/src/layouts/force-directed/fruchterman-reingold.js +17 -17
- package/dist/src/layouts/force-directed/fruchterman-reingold.js.map +1 -1
- package/dist/src/layouts/force-directed/index.d.ts +5 -5
- package/dist/src/layouts/force-directed/index.js +5 -5
- package/dist/src/layouts/force-directed/index.js.map +1 -1
- package/dist/src/layouts/force-directed/kamada-kawai.d.ts +2 -3
- package/dist/src/layouts/force-directed/kamada-kawai.js +12 -10
- package/dist/src/layouts/force-directed/kamada-kawai.js.map +1 -1
- package/dist/src/layouts/force-directed/spring.d.ts +11 -12
- package/dist/src/layouts/force-directed/spring.js +11 -12
- package/dist/src/layouts/force-directed/spring.js.map +1 -1
- package/dist/src/layouts/geometric/circular.d.ts +1 -2
- package/dist/src/layouts/geometric/circular.js +10 -9
- package/dist/src/layouts/geometric/circular.js.map +1 -1
- package/dist/src/layouts/geometric/index.d.ts +3 -3
- package/dist/src/layouts/geometric/index.js +3 -3
- package/dist/src/layouts/geometric/shell.d.ts +1 -2
- package/dist/src/layouts/geometric/shell.js +5 -5
- package/dist/src/layouts/geometric/shell.js.map +1 -1
- package/dist/src/layouts/geometric/spiral.d.ts +1 -2
- package/dist/src/layouts/geometric/spiral.js +5 -9
- package/dist/src/layouts/geometric/spiral.js.map +1 -1
- package/dist/src/layouts/hierarchical/bfs.d.ts +2 -3
- package/dist/src/layouts/hierarchical/bfs.js +5 -6
- package/dist/src/layouts/hierarchical/bfs.js.map +1 -1
- package/dist/src/layouts/hierarchical/bipartite.d.ts +2 -3
- package/dist/src/layouts/hierarchical/bipartite.js +8 -9
- package/dist/src/layouts/hierarchical/bipartite.js.map +1 -1
- package/dist/src/layouts/hierarchical/index.d.ts +3 -3
- package/dist/src/layouts/hierarchical/index.js +3 -3
- package/dist/src/layouts/hierarchical/index.js.map +1 -1
- package/dist/src/layouts/hierarchical/multipartite.d.ts +2 -3
- package/dist/src/layouts/hierarchical/multipartite.js +7 -8
- package/dist/src/layouts/hierarchical/multipartite.js.map +1 -1
- package/dist/src/layouts/index.d.ts +5 -5
- package/dist/src/layouts/index.js +5 -5
- package/dist/src/layouts/index.js.map +1 -1
- package/dist/src/layouts/specialized/index.d.ts +2 -2
- package/dist/src/layouts/specialized/index.js +2 -2
- package/dist/src/layouts/specialized/index.js.map +1 -1
- package/dist/src/layouts/specialized/planar.d.ts +1 -2
- package/dist/src/layouts/specialized/planar.js +5 -6
- package/dist/src/layouts/specialized/planar.js.map +1 -1
- package/dist/src/layouts/specialized/spectral.d.ts +1 -2
- package/dist/src/layouts/specialized/spectral.js +30 -20
- package/dist/src/layouts/specialized/spectral.js.map +1 -1
- package/dist/src/types/embedding.d.ts +1 -1
- package/dist/src/types/index.d.ts +3 -3
- package/dist/src/types/index.js +3 -3
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/layout.d.ts +1 -1
- package/dist/src/utils/graph.d.ts +1 -5
- package/dist/src/utils/graph.js +4 -6
- package/dist/src/utils/graph.js.map +1 -1
- package/dist/src/utils/index.d.ts +5 -5
- package/dist/src/utils/index.js +5 -5
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/numpy.js +22 -16
- package/dist/src/utils/numpy.js.map +1 -1
- package/dist/src/utils/params.d.ts +1 -2
- package/dist/src/utils/params.js +0 -1
- package/dist/src/utils/params.js.map +1 -1
- package/dist/src/utils/random.d.ts +17 -0
- package/dist/src/utils/random.js +18 -1
- package/dist/src/utils/random.js.map +1 -1
- package/dist/src/utils/rescale.d.ts +1 -3
- package/dist/src/utils/rescale.js +12 -10
- package/dist/src/utils/rescale.js.map +1 -1
- package/dist/vitest.config.js +14 -14
- package/dist/vitest.config.js.map +1 -1
- package/package.json +29 -24
- package/src/algorithms/index.ts +2 -2
- package/src/algorithms/optimization/index.ts +4 -8
- package/src/algorithms/optimization/kamada-kawai-solver.ts +170 -179
- package/src/algorithms/optimization/lbfgs.ts +41 -48
- package/src/algorithms/optimization/line-search.ts +27 -28
- package/src/algorithms/optimization/types.ts +2 -2
- package/src/algorithms/planarity/check.ts +22 -22
- package/src/algorithms/planarity/embedding.ts +159 -170
- package/src/algorithms/planarity/index.ts +4 -8
- package/src/algorithms/planarity/lr-test.ts +46 -46
- package/src/algorithms/planarity/special-graphs.ts +73 -83
- package/src/generators/basic.ts +57 -57
- package/src/generators/bipartite.ts +37 -31
- package/src/generators/grid.ts +28 -28
- package/src/generators/index.ts +5 -11
- package/src/generators/random.ts +26 -25
- package/src/generators/scale-free.ts +56 -55
- package/src/index.ts +5 -5
- package/src/layouts/basic/index.ts +1 -1
- package/src/layouts/basic/random.ts +20 -16
- package/src/layouts/force-directed/arf.ts +107 -105
- package/src/layouts/force-directed/forceatlas2.ts +365 -351
- package/src/layouts/force-directed/fruchterman-reingold.ts +133 -134
- package/src/layouts/force-directed/index.ts +5 -5
- package/src/layouts/force-directed/kamada-kawai.ts +78 -80
- package/src/layouts/force-directed/spring.ts +24 -25
- package/src/layouts/geometric/circular.ts +63 -57
- package/src/layouts/geometric/index.ts +3 -3
- package/src/layouts/geometric/shell.ts +58 -53
- package/src/layouts/geometric/spiral.ts +60 -64
- package/src/layouts/hierarchical/bfs.ts +58 -59
- package/src/layouts/hierarchical/bipartite.ts +62 -63
- package/src/layouts/hierarchical/index.ts +3 -3
- package/src/layouts/hierarchical/multipartite.ts +62 -63
- package/src/layouts/index.ts +5 -5
- package/src/layouts/specialized/index.ts +2 -2
- package/src/layouts/specialized/planar.ts +41 -42
- package/src/layouts/specialized/spectral.ts +110 -99
- package/src/types/embedding.ts +5 -5
- package/src/types/graph.ts +4 -4
- package/src/types/index.ts +3 -3
- package/src/types/layout.ts +2 -2
- package/src/utils/graph.ts +31 -35
- package/src/utils/index.ts +5 -5
- package/src/utils/numpy.ts +96 -92
- package/src/utils/params.ts +14 -11
- package/src/utils/random.ts +57 -40
- package/src/utils/rescale.ts +169 -174
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Circular layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { getNodesFromGraph } from "../../utils/graph";
|
|
5
|
+
import { np } from "../../utils/numpy";
|
|
6
|
+
import { _processParams } from "../../utils/params";
|
|
7
|
+
import { RandomNumberGenerator } from "../../utils/random";
|
|
8
8
|
/**
|
|
9
9
|
* Position nodes on a circle (2D) or sphere (3D).
|
|
10
|
-
*
|
|
11
10
|
* @param G - Graph or list of nodes
|
|
12
11
|
* @param scale - Scale factor for positions
|
|
13
12
|
* @param center - Coordinate pair around which to center the layout
|
|
@@ -44,8 +43,8 @@ export function circularLayout(G, scale = 1, center = null, dim = 2) {
|
|
|
44
43
|
const goldenRatio = (1 + Math.sqrt(5)) / 2;
|
|
45
44
|
nodes.forEach((node, i) => {
|
|
46
45
|
// Use Fibonacci spiral for even distribution on sphere
|
|
47
|
-
const theta = 2 * Math.PI * i / goldenRatio;
|
|
48
|
-
const phi = Math.acos(1 - 2 * (i + 0.5) / n);
|
|
46
|
+
const theta = (2 * Math.PI * i) / goldenRatio;
|
|
47
|
+
const phi = Math.acos(1 - (2 * (i + 0.5)) / n);
|
|
49
48
|
const x = Math.sin(phi) * Math.cos(theta) * scale + center[0];
|
|
50
49
|
const y = Math.sin(phi) * Math.sin(theta) * scale + center[1];
|
|
51
50
|
const z = Math.cos(phi) * scale + center[2];
|
|
@@ -57,9 +56,11 @@ export function circularLayout(G, scale = 1, center = null, dim = 2) {
|
|
|
57
56
|
const rng = new RandomNumberGenerator();
|
|
58
57
|
nodes.forEach((node) => {
|
|
59
58
|
// Generate random point on unit hypersphere
|
|
60
|
-
const coords = Array(dim)
|
|
59
|
+
const coords = Array(dim)
|
|
60
|
+
.fill(0)
|
|
61
|
+
.map(() => rng.rand() * 2 - 1);
|
|
61
62
|
const norm = Math.sqrt(coords.reduce((sum, c) => sum + c * c, 0));
|
|
62
|
-
pos[node] = coords.map((c, j) => c / norm * scale + center[j]);
|
|
63
|
+
pos[node] = coords.map((c, j) => (c / norm) * scale + center[j]);
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
return pos;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circular.js","sourceRoot":"","sources":["../../../../src/layouts/geometric/circular.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"circular.js","sourceRoot":"","s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CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAE5C,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACP,CAAC;SAAM,CAAC;QACJ,4DAA4D;QAC5D,MAAM,GAAG,GAAG,IAAI,qBAAqB,EAAE,CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAU,EAAE,EAAE;YACzB,4CAA4C;YAC5C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,CAAC,CAAC;iBACP,GAAG,CAAC,GAAG,EAAE,CAAE,GAAG,CAAC,IAAI,EAAa,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAClE,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Geometric layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export { circularLayout } from
|
|
5
|
-
export { shellLayout } from
|
|
6
|
-
export { spiralLayout } from
|
|
4
|
+
export { circularLayout } from "./circular";
|
|
5
|
+
export { shellLayout } from "./shell";
|
|
6
|
+
export { spiralLayout } from "./spiral";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Geometric layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export { circularLayout } from
|
|
5
|
-
export { shellLayout } from
|
|
6
|
-
export { spiralLayout } from
|
|
4
|
+
export { circularLayout } from "./circular";
|
|
5
|
+
export { shellLayout } from "./shell";
|
|
6
|
+
export { spiralLayout } from "./spiral";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shell layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import { Graph, Node, PositionMap } from
|
|
4
|
+
import { Graph, Node, PositionMap } from "../../types";
|
|
5
5
|
/**
|
|
6
6
|
* Position nodes in concentric circles.
|
|
7
|
-
*
|
|
8
7
|
* @param G - Graph or list of nodes
|
|
9
8
|
* @param nlist - List of node lists for each shell
|
|
10
9
|
* @param scale - Scale factor for positions
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shell layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { getNodesFromGraph } from "../../utils/graph";
|
|
5
|
+
import { np } from "../../utils/numpy";
|
|
6
|
+
import { _processParams } from "../../utils/params";
|
|
7
7
|
/**
|
|
8
8
|
* Position nodes in concentric circles.
|
|
9
|
-
*
|
|
10
9
|
* @param G - Graph or list of nodes
|
|
11
10
|
* @param nlist - List of node lists for each shell
|
|
12
11
|
* @param scale - Scale factor for positions
|
|
@@ -47,8 +46,9 @@ export function shellLayout(G, nlist = null, scale = 1, center = null, dim = 2)
|
|
|
47
46
|
}
|
|
48
47
|
for (let i = 0; i < nlist.length; i++) {
|
|
49
48
|
const shell = nlist[i];
|
|
50
|
-
if (shell.length === 0)
|
|
49
|
+
if (shell.length === 0) {
|
|
51
50
|
continue;
|
|
51
|
+
}
|
|
52
52
|
if (shell.length === 1 && i === 0) {
|
|
53
53
|
// Already handled the case of a single center node
|
|
54
54
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../../src/layouts/geometric/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../../src/layouts/geometric/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACvB,CAAQ,EACR,QAAyB,IAAI,EAC7B,QAAgB,CAAC,EACjB,SAA0B,IAAI,EAC9B,MAAc,CAAC;IAEf,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAE1B,MAAM,GAAG,GAAgB,EAAE,CAAC;IAE5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;QACvB,OAAO,GAAG,CAAC;IACf,CAAC;IAED,4DAA4D;IAC5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC;I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AAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAClD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,UAAU,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Spiral layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import { Graph, PositionMap } from
|
|
4
|
+
import { Graph, PositionMap } from "../../types";
|
|
5
5
|
/**
|
|
6
6
|
* Position nodes in a spiral layout.
|
|
7
|
-
*
|
|
8
7
|
* @param G - Graph or list of nodes
|
|
9
8
|
* @param scale - Scale factor for positions
|
|
10
9
|
* @param center - Coordinate pair around which to center the layout
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Spiral layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { rescaleLayout } from
|
|
4
|
+
import { getNodesFromGraph } from "../../utils/graph";
|
|
5
|
+
import { _processParams } from "../../utils/params";
|
|
6
|
+
import { rescaleLayout } from "../../utils/rescale";
|
|
7
7
|
/**
|
|
8
8
|
* Position nodes in a spiral layout.
|
|
9
|
-
*
|
|
10
9
|
* @param G - Graph or list of nodes
|
|
11
10
|
* @param scale - Scale factor for positions
|
|
12
11
|
* @param center - Coordinate pair around which to center the layout
|
|
@@ -47,11 +46,8 @@ export function spiralLayout(G, scale = 1, center = null, dim = 2, resolution =
|
|
|
47
46
|
else {
|
|
48
47
|
// Create points with equal angle but increasing distance
|
|
49
48
|
const dist = Array.from({ length: nodes.length }, (_, i) => parseFloat(String(i)));
|
|
50
|
-
const angle = dist.map(d => resolution * d);
|
|
51
|
-
positions = dist.map((d, i) => [
|
|
52
|
-
Math.cos(angle[i]) * d,
|
|
53
|
-
Math.sin(angle[i]) * d
|
|
54
|
-
]);
|
|
49
|
+
const angle = dist.map((d) => resolution * d);
|
|
50
|
+
positions = dist.map((d, i) => [Math.cos(angle[i]) * d, Math.sin(angle[i]) * d]);
|
|
55
51
|
}
|
|
56
52
|
// Convert position array to position matrix for rescaling
|
|
57
53
|
const posArray = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spiral.js","sourceRoot":"","sources":["../../../../src/layouts/geometric/spiral.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"spiral.js","sourceRoot":"","sources":["../../../../src/layouts/geometric/spiral.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CACxB,CAAQ,EACR,QAAgB,CAAC,EACjB,SAA0B,IAAI,EAC9B,MAAc,CAAC,EACf,aAAqB,IAAI,EACzB,cAAuB,KAAK;IAE5B,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAE1B,MAAM,GAAG,GAAgB,EAAE,CAAC;IAE5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,M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AAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,0DAA0D;IAC1D,MAAM,QAAQ,GAAe,EAAE,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,0CAA0C;IAC1C,MAAM,eAAe,GAAG,aAAa,CAAC,QAAe,EAAE,KAAK,CAAQ,CAAC;IACrE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;QACnC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,6BAA6B;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Graph, Node, PositionMap } from
|
|
1
|
+
import type { Graph, Node, PositionMap } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Position nodes according to breadth-first search algorithm.
|
|
4
|
-
*
|
|
5
4
|
* @param G - Graph
|
|
6
5
|
* @param start - Starting node for bfs
|
|
7
6
|
* @param align - The alignment of layers: 'vertical' or 'horizontal'
|
|
@@ -9,4 +8,4 @@ import type { Graph, Node, PositionMap } from '../../types';
|
|
|
9
8
|
* @param center - Coordinate pair around which to center the layout
|
|
10
9
|
* @returns Positions dictionary keyed by node
|
|
11
10
|
*/
|
|
12
|
-
export declare function bfsLayout(G: Graph, start: Node, align?:
|
|
11
|
+
export declare function bfsLayout(G: Graph, start: Node, align?: "vertical" | "horizontal", scale?: number, center?: number[] | null): PositionMap;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _processParams } from
|
|
3
|
-
import { multipartiteLayout } from
|
|
1
|
+
import { getNeighbors, getNodesFromGraph } from "../../utils/graph";
|
|
2
|
+
import { _processParams } from "../../utils/params";
|
|
3
|
+
import { multipartiteLayout } from "./multipartite";
|
|
4
4
|
/**
|
|
5
5
|
* Position nodes according to breadth-first search algorithm.
|
|
6
|
-
*
|
|
7
6
|
* @param G - Graph
|
|
8
7
|
* @param start - Starting node for bfs
|
|
9
8
|
* @param align - The alignment of layers: 'vertical' or 'horizontal'
|
|
@@ -11,11 +10,11 @@ import { multipartiteLayout } from './multipartite';
|
|
|
11
10
|
* @param center - Coordinate pair around which to center the layout
|
|
12
11
|
* @returns Positions dictionary keyed by node
|
|
13
12
|
*/
|
|
14
|
-
export function bfsLayout(G, start, align =
|
|
13
|
+
export function bfsLayout(G, start, align = "vertical", scale = 1, center = null) {
|
|
15
14
|
const processed = _processParams(G, center || [0, 0], 2);
|
|
16
15
|
// BFS layout requires a proper Graph, not just a list of nodes
|
|
17
16
|
if (Array.isArray(processed.G)) {
|
|
18
|
-
throw new Error(
|
|
17
|
+
throw new Error("BFS layout requires a Graph with edges, not just a list of nodes");
|
|
19
18
|
}
|
|
20
19
|
const graph = processed.G;
|
|
21
20
|
center = processed.center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bfs.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/bfs.ts"],"names":[],"mapp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|
|
4
|
+
import { Graph, Node, PositionMap } from "../../types";
|
|
5
5
|
/**
|
|
6
6
|
* Position nodes in two straight lines (bipartite layout).
|
|
7
|
-
*
|
|
8
7
|
* @param G - Graph or list of nodes
|
|
9
8
|
* @param nodes - Nodes in one node set of the graph
|
|
10
9
|
* @param align - The alignment of nodes: 'vertical' or 'horizontal'
|
|
@@ -13,4 +12,4 @@ import { Graph, Node, PositionMap } from '../../types';
|
|
|
13
12
|
* @param aspectRatio - The ratio of the width to the height of the layout
|
|
14
13
|
* @returns Positions dictionary keyed by node
|
|
15
14
|
*/
|
|
16
|
-
export declare function bipartiteLayout(G: Graph, nodes?: Node[] | null, align?:
|
|
15
|
+
export declare function bipartiteLayout(G: Graph, nodes?: Node[] | null, align?: "vertical" | "horizontal", scale?: number, center?: number[] | null, aspectRatio?: number): PositionMap;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bipartite layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { rescaleLayout } from
|
|
4
|
+
import { getNodesFromGraph } from "../../utils/graph";
|
|
5
|
+
import { _processParams } from "../../utils/params";
|
|
6
|
+
import { rescaleLayout } from "../../utils/rescale";
|
|
7
7
|
/**
|
|
8
8
|
* Position nodes in two straight lines (bipartite layout).
|
|
9
|
-
*
|
|
10
9
|
* @param G - Graph or list of nodes
|
|
11
10
|
* @param nodes - Nodes in one node set of the graph
|
|
12
11
|
* @param align - The alignment of nodes: 'vertical' or 'horizontal'
|
|
@@ -15,8 +14,8 @@ import { rescaleLayout } from '../../utils/rescale';
|
|
|
15
14
|
* @param aspectRatio - The ratio of the width to the height of the layout
|
|
16
15
|
* @returns Positions dictionary keyed by node
|
|
17
16
|
*/
|
|
18
|
-
export function bipartiteLayout(G, nodes = null, align =
|
|
19
|
-
if (align !==
|
|
17
|
+
export function bipartiteLayout(G, nodes = null, align = "vertical", scale = 1, center = null, aspectRatio = 4 / 3) {
|
|
18
|
+
if (align !== "vertical" && align !== "horizontal") {
|
|
20
19
|
throw new Error("align must be either vertical or horizontal");
|
|
21
20
|
}
|
|
22
21
|
const processed = _processParams(G, center || [0, 0], 2);
|
|
@@ -42,14 +41,14 @@ export function bipartiteLayout(G, nodes = null, align = 'vertical', scale = 1,
|
|
|
42
41
|
const leftNodes = [...left];
|
|
43
42
|
leftNodes.forEach((node, i) => {
|
|
44
43
|
const x = 0;
|
|
45
|
-
const y = i * height / (leftNodes.length || 1);
|
|
44
|
+
const y = (i * height) / (leftNodes.length || 1);
|
|
46
45
|
pos[node] = [x, y];
|
|
47
46
|
});
|
|
48
47
|
// Position nodes in the right set
|
|
49
48
|
const rightNodes = [...right];
|
|
50
49
|
rightNodes.forEach((node, i) => {
|
|
51
50
|
const x = width;
|
|
52
|
-
const y = i * height / (rightNodes.length || 1);
|
|
51
|
+
const y = (i * height) / (rightNodes.length || 1);
|
|
53
52
|
pos[node] = [x, y];
|
|
54
53
|
});
|
|
55
54
|
// Center positions around the origin and apply offset
|
|
@@ -60,7 +59,7 @@ export function bipartiteLayout(G, nodes = null, align = 'vertical', scale = 1,
|
|
|
60
59
|
// Rescale positions
|
|
61
60
|
const scaledPos = rescaleLayout(pos, scale, center);
|
|
62
61
|
// Handle horizontal alignment
|
|
63
|
-
if (align ===
|
|
62
|
+
if (align === "horizontal") {
|
|
64
63
|
for (const node in scaledPos) {
|
|
65
64
|
const temp = scaledPos[node][0];
|
|
66
65
|
scaledPos[node][0] = scaledPos[node][1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bipartite.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/bipartite.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bipartite.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/bipartite.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAA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AG,EAAE,KAAK,EAAE,MAAM,CAAgB,CAAC;IAEnE,8BAA8B;IAC9B,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hierarchical layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { bfsLayout } from "./bfs";
|
|
5
|
+
export { bipartiteLayout } from "./bipartite";
|
|
6
|
+
export { multipartiteLayout } from "./multipartite";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hierarchical layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { bfsLayout } from "./bfs";
|
|
5
|
+
export { bipartiteLayout } from "./bipartite";
|
|
6
|
+
export { multipartiteLayout } from "./multipartite";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Graph, Node, PositionMap } from
|
|
1
|
+
import type { Graph, Node, PositionMap } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Position nodes in layers of straight lines (multipartite layout).
|
|
4
|
-
*
|
|
5
4
|
* @param G - Graph or list of nodes
|
|
6
5
|
* @param subsetKey - Object mapping layers to node sets, or node attribute name
|
|
7
6
|
* @param align - The alignment of nodes: 'vertical' or 'horizontal'
|
|
@@ -9,4 +8,4 @@ import type { Graph, Node, PositionMap } from '../../types';
|
|
|
9
8
|
* @param center - Coordinate pair around which to center the layout
|
|
10
9
|
* @returns Positions dictionary keyed by node
|
|
11
10
|
*/
|
|
12
|
-
export declare function multipartiteLayout(G: Graph, subsetKey?: Record<number | string, Node | Node[]> | string, align?:
|
|
11
|
+
export declare function multipartiteLayout(G: Graph, subsetKey?: Record<number | string, Node | Node[]> | string, align?: "vertical" | "horizontal", scale?: number, center?: number[] | null): PositionMap;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { getNodesFromGraph } from
|
|
2
|
-
import { _processParams } from
|
|
3
|
-
import { rescaleLayout } from
|
|
1
|
+
import { getNodesFromGraph } from "../../utils/graph";
|
|
2
|
+
import { _processParams } from "../../utils/params";
|
|
3
|
+
import { rescaleLayout } from "../../utils/rescale";
|
|
4
4
|
/**
|
|
5
5
|
* Position nodes in layers of straight lines (multipartite layout).
|
|
6
|
-
*
|
|
7
6
|
* @param G - Graph or list of nodes
|
|
8
7
|
* @param subsetKey - Object mapping layers to node sets, or node attribute name
|
|
9
8
|
* @param align - The alignment of nodes: 'vertical' or 'horizontal'
|
|
@@ -11,8 +10,8 @@ import { rescaleLayout } from '../../utils/rescale';
|
|
|
11
10
|
* @param center - Coordinate pair around which to center the layout
|
|
12
11
|
* @returns Positions dictionary keyed by node
|
|
13
12
|
*/
|
|
14
|
-
export function multipartiteLayout(G, subsetKey =
|
|
15
|
-
if (align !==
|
|
13
|
+
export function multipartiteLayout(G, subsetKey = "subset", align = "vertical", scale = 1, center = null) {
|
|
14
|
+
if (align !== "vertical" && align !== "horizontal") {
|
|
16
15
|
throw new Error("align must be either vertical or horizontal");
|
|
17
16
|
}
|
|
18
17
|
const processed = _processParams(G, center || [0, 0], 2);
|
|
@@ -24,7 +23,7 @@ export function multipartiteLayout(G, subsetKey = 'subset', align = 'vertical',
|
|
|
24
23
|
}
|
|
25
24
|
// Convert subsetKey to a layer mapping if it's a string
|
|
26
25
|
let layers = {};
|
|
27
|
-
if (typeof subsetKey ===
|
|
26
|
+
if (typeof subsetKey === "string") {
|
|
28
27
|
// In JS we don't have access to node attributes directly
|
|
29
28
|
// This is a simplification - in a real implementation we would need
|
|
30
29
|
// to access node attributes from the graph
|
|
@@ -61,7 +60,7 @@ export function multipartiteLayout(G, subsetKey = 'subset', align = 'vertical',
|
|
|
61
60
|
// Rescale positions
|
|
62
61
|
pos = rescaleLayout(pos, scale, center);
|
|
63
62
|
// Handle horizontal alignment
|
|
64
|
-
if (align ===
|
|
63
|
+
if (align === "horizontal") {
|
|
65
64
|
for (const node in pos) {
|
|
66
65
|
const temp = pos[node][0];
|
|
67
66
|
pos[node][0] = pos[node][1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipartite.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/multipartite.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"multipartite.js","sourceRoot":"","sources":["../../../../src/layouts/hierarchical/multipartite.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;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,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Re-export all layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
4
|
+
export * from "./basic";
|
|
5
|
+
export * from "./force-directed";
|
|
6
|
+
export * from "./geometric";
|
|
7
|
+
export * from "./hierarchical";
|
|
8
|
+
export * from "./specialized";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Re-export all layout algorithms
|
|
3
3
|
*/
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
4
|
+
export * from "./basic";
|
|
5
|
+
export * from "./force-directed";
|
|
6
|
+
export * from "./geometric";
|
|
7
|
+
export * from "./hierarchical";
|
|
8
|
+
export * from "./specialized";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layouts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layouts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/layouts/specialized/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/layouts/specialized/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Planar layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import { Graph, PositionMap } from
|
|
4
|
+
import { Graph, PositionMap } from "../../types";
|
|
5
5
|
/**
|
|
6
6
|
* Position nodes without edge intersections (planar layout).
|
|
7
|
-
*
|
|
8
7
|
* @param G - Graph
|
|
9
8
|
* @param scale - Scale factor for positions
|
|
10
9
|
* @param center - Coordinate pair around which to center the layout
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Planar layout algorithm
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { checkPlanarity, combinatorialEmbeddingToPos } from "../../algorithms/planarity";
|
|
5
|
+
import { getEdgesFromGraph, getNodesFromGraph } from "../../utils/graph";
|
|
6
|
+
import { _processParams } from "../../utils/params";
|
|
7
|
+
import { rescaleLayout } from "../../utils/rescale";
|
|
8
8
|
/**
|
|
9
9
|
* Position nodes without edge intersections (planar layout).
|
|
10
|
-
*
|
|
11
10
|
* @param G - Graph
|
|
12
11
|
* @param scale - Scale factor for positions
|
|
13
12
|
* @param center - Coordinate pair around which to center the layout
|
|
@@ -22,7 +21,7 @@ export function planarLayout(G, scale = 1, center = null, dim = 2, seed = null)
|
|
|
22
21
|
const processed = _processParams(G, center || [0, 0], dim);
|
|
23
22
|
// Planar layout requires a proper Graph, not just a list of nodes
|
|
24
23
|
if (Array.isArray(processed.G)) {
|
|
25
|
-
throw new Error(
|
|
24
|
+
throw new Error("Planar layout requires a Graph with edges, not just a list of nodes");
|
|
26
25
|
}
|
|
27
26
|
const graph = processed.G;
|
|
28
27
|
center = processed.center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planar.js","sourceRoot":"","sources":["../../../../src/layouts/specialized/planar.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"planar.js","sourceRoot":"","sources":["../../../../src/layouts/specialized/planar.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAC,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CACxB,CAAQ,EACR,QAAgB,CAAC,EACjB,SAA0B,IAAI,EAC9B,MAAc,CAAC,EACf,OAAsB,IAAI;IAE1B,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE3D,kEAAkE;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;IAC1B,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAE1B,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAEvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAE1E,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC5D,CAAC;IAED,iCAAiC;IACjC,IAAI,GAAG,GAAG,2BAA2B,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAExD,wBAAwB;IACxB,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAgB,CAAC;IAEvD,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Spectral layout algorithm using eigenvectors of the graph Laplacian
|
|
3
3
|
*/
|
|
4
|
-
import { Graph, PositionMap } from
|
|
4
|
+
import { Graph, PositionMap } from "../../types";
|
|
5
5
|
/**
|
|
6
6
|
* Position nodes in a spectral layout using eigenvectors of the graph Laplacian.
|
|
7
|
-
*
|
|
8
7
|
* @param G - Graph
|
|
9
8
|
* @param scale - Scale factor for positions
|
|
10
9
|
* @param center - Coordinate pair around which to center the layout
|