@graphty/layout 1.2.4 → 1.2.6
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 +57 -1
- package/dist/layout.js +1762 -0
- package/dist/layout.js.map +1 -0
- package/package.json +7 -4
- package/src/layouts/force-directed/forceatlas2.ts +23 -4
- package/src/utils/rescale.ts +90 -15
- package/dist/src/algorithms/index.d.ts +0 -5
- package/dist/src/algorithms/index.js +0 -6
- package/dist/src/algorithms/index.js.map +0 -1
- package/dist/src/algorithms/optimization/index.d.ts +0 -7
- package/dist/src/algorithms/optimization/index.js +0 -7
- package/dist/src/algorithms/optimization/index.js.map +0 -1
- package/dist/src/algorithms/optimization/kamada-kawai-solver.d.ts +0 -32
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js +0 -176
- package/dist/src/algorithms/optimization/kamada-kawai-solver.js.map +0 -1
- package/dist/src/algorithms/optimization/lbfgs.d.ts +0 -13
- package/dist/src/algorithms/optimization/lbfgs.js +0 -56
- package/dist/src/algorithms/optimization/lbfgs.js.map +0 -1
- package/dist/src/algorithms/optimization/line-search.d.ts +0 -15
- package/dist/src/algorithms/optimization/line-search.js +0 -37
- package/dist/src/algorithms/optimization/line-search.js.map +0 -1
- package/dist/src/algorithms/optimization/types.d.ts +0 -5
- package/dist/src/algorithms/optimization/types.js +0 -5
- package/dist/src/algorithms/optimization/types.js.map +0 -1
- package/dist/src/algorithms/planarity/check.d.ts +0 -17
- package/dist/src/algorithms/planarity/check.js +0 -30
- package/dist/src/algorithms/planarity/check.js.map +0 -1
- package/dist/src/algorithms/planarity/embedding.d.ts +0 -29
- package/dist/src/algorithms/planarity/embedding.js +0 -179
- package/dist/src/algorithms/planarity/embedding.js.map +0 -1
- package/dist/src/algorithms/planarity/index.d.ts +0 -7
- package/dist/src/algorithms/planarity/index.js +0 -8
- package/dist/src/algorithms/planarity/index.js.map +0 -1
- package/dist/src/algorithms/planarity/lr-test.d.ts +0 -15
- package/dist/src/algorithms/planarity/lr-test.js +0 -54
- package/dist/src/algorithms/planarity/lr-test.js.map +0 -1
- package/dist/src/algorithms/planarity/special-graphs.d.ts +0 -28
- package/dist/src/algorithms/planarity/special-graphs.js +0 -108
- package/dist/src/algorithms/planarity/special-graphs.js.map +0 -1
- package/dist/src/generators/basic.d.ts +0 -28
- package/dist/src/generators/basic.js +0 -79
- package/dist/src/generators/basic.js.map +0 -1
- package/dist/src/generators/bipartite.d.ts +0 -16
- package/dist/src/generators/bipartite.js +0 -40
- package/dist/src/generators/bipartite.js.map +0 -1
- package/dist/src/generators/grid.d.ts +0 -11
- package/dist/src/generators/grid.js +0 -37
- package/dist/src/generators/grid.js.map +0 -1
- package/dist/src/generators/index.d.ts +0 -8
- package/dist/src/generators/index.js +0 -9
- package/dist/src/generators/index.js.map +0 -1
- package/dist/src/generators/random.d.ts +0 -12
- package/dist/src/generators/random.js +0 -34
- package/dist/src/generators/random.js.map +0 -1
- package/dist/src/generators/scale-free.d.ts +0 -12
- package/dist/src/generators/scale-free.js +0 -62
- package/dist/src/generators/scale-free.js.map +0 -1
- package/dist/src/index.d.ts +0 -10
- package/dist/src/index.js +0 -15
- package/dist/src/index.js.map +0 -1
- package/dist/src/layouts/basic/index.d.ts +0 -4
- package/dist/src/layouts/basic/index.js +0 -5
- package/dist/src/layouts/basic/index.js.map +0 -1
- package/dist/src/layouts/basic/random.d.ts +0 -14
- package/dist/src/layouts/basic/random.js +0 -27
- package/dist/src/layouts/basic/random.js.map +0 -1
- package/dist/src/layouts/force-directed/arf.d.ts +0 -13
- package/dist/src/layouts/force-directed/arf.js +0 -103
- package/dist/src/layouts/force-directed/arf.js.map +0 -1
- package/dist/src/layouts/force-directed/forceatlas2.d.ts +0 -22
- package/dist/src/layouts/force-directed/forceatlas2.js +0 -322
- package/dist/src/layouts/force-directed/forceatlas2.js.map +0 -1
- package/dist/src/layouts/force-directed/fruchterman-reingold.d.ts +0 -19
- package/dist/src/layouts/force-directed/fruchterman-reingold.js +0 -131
- package/dist/src/layouts/force-directed/fruchterman-reingold.js.map +0 -1
- package/dist/src/layouts/force-directed/index.d.ts +0 -8
- package/dist/src/layouts/force-directed/index.js +0 -9
- package/dist/src/layouts/force-directed/index.js.map +0 -1
- package/dist/src/layouts/force-directed/kamada-kawai.d.ts +0 -15
- package/dist/src/layouts/force-directed/kamada-kawai.js +0 -87
- package/dist/src/layouts/force-directed/kamada-kawai.js.map +0 -1
- package/dist/src/layouts/force-directed/spring.d.ts +0 -19
- package/dist/src/layouts/force-directed/spring.js +0 -23
- package/dist/src/layouts/force-directed/spring.js.map +0 -1
- package/dist/src/layouts/geometric/circular.d.ts +0 -14
- package/dist/src/layouts/geometric/circular.js +0 -67
- package/dist/src/layouts/geometric/circular.js.map +0 -1
- package/dist/src/layouts/geometric/index.d.ts +0 -6
- package/dist/src/layouts/geometric/index.js +0 -7
- package/dist/src/layouts/geometric/index.js.map +0 -1
- package/dist/src/layouts/geometric/shell.d.ts +0 -15
- package/dist/src/layouts/geometric/shell.js +0 -67
- package/dist/src/layouts/geometric/shell.js.map +0 -1
- package/dist/src/layouts/geometric/spiral.d.ts +0 -16
- package/dist/src/layouts/geometric/spiral.js +0 -73
- package/dist/src/layouts/geometric/spiral.js.map +0 -1
- package/dist/src/layouts/hierarchical/bfs.d.ts +0 -12
- package/dist/src/layouts/hierarchical/bfs.js +0 -62
- package/dist/src/layouts/hierarchical/bfs.js.map +0 -1
- package/dist/src/layouts/hierarchical/bipartite.d.ts +0 -16
- package/dist/src/layouts/hierarchical/bipartite.js +0 -72
- package/dist/src/layouts/hierarchical/bipartite.js.map +0 -1
- package/dist/src/layouts/hierarchical/index.d.ts +0 -6
- package/dist/src/layouts/hierarchical/index.js +0 -7
- package/dist/src/layouts/hierarchical/index.js.map +0 -1
- package/dist/src/layouts/hierarchical/multipartite.d.ts +0 -12
- package/dist/src/layouts/hierarchical/multipartite.js +0 -73
- package/dist/src/layouts/hierarchical/multipartite.js.map +0 -1
- package/dist/src/layouts/index.d.ts +0 -8
- package/dist/src/layouts/index.js +0 -9
- package/dist/src/layouts/index.js.map +0 -1
- package/dist/src/layouts/specialized/index.d.ts +0 -5
- package/dist/src/layouts/specialized/index.js +0 -6
- package/dist/src/layouts/specialized/index.js.map +0 -1
- package/dist/src/layouts/specialized/planar.d.ts +0 -14
- package/dist/src/layouts/specialized/planar.js +0 -47
- package/dist/src/layouts/specialized/planar.js.map +0 -1
- package/dist/src/layouts/specialized/spectral.d.ts +0 -14
- package/dist/src/layouts/specialized/spectral.js +0 -106
- package/dist/src/layouts/specialized/spectral.js.map +0 -1
- package/dist/src/types/embedding.d.ts +0 -9
- package/dist/src/types/embedding.js +0 -5
- package/dist/src/types/embedding.js.map +0 -1
- package/dist/src/types/graph.d.ts +0 -10
- package/dist/src/types/graph.js +0 -5
- package/dist/src/types/graph.js.map +0 -1
- package/dist/src/types/index.d.ts +0 -6
- package/dist/src/types/index.js +0 -7
- package/dist/src/types/index.js.map +0 -1
- package/dist/src/types/layout.d.ts +0 -6
- package/dist/src/types/layout.js +0 -5
- package/dist/src/types/layout.js.map +0 -1
- package/dist/src/utils/graph.d.ts +0 -34
- package/dist/src/utils/graph.js +0 -69
- package/dist/src/utils/graph.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -8
- package/dist/src/utils/index.js +0 -9
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/numpy.d.ts +0 -17
- package/dist/src/utils/numpy.js +0 -101
- package/dist/src/utils/numpy.js.map +0 -1
- package/dist/src/utils/params.d.ts +0 -17
- package/dist/src/utils/params.js +0 -22
- package/dist/src/utils/params.js.map +0 -1
- package/dist/src/utils/random.d.ts +0 -14
- package/dist/src/utils/random.js +0 -42
- package/dist/src/utils/random.js.map +0 -1
- package/dist/src/utils/rescale.d.ts +0 -21
- package/dist/src/utils/rescale.js +0 -119
- package/dist/src/utils/rescale.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -30
- package/dist/vitest.config.js.map +0 -1
package/dist/src/utils/graph.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graph utility functions
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Extract nodes from a graph object
|
|
6
|
-
*
|
|
7
|
-
* @param G - Graph or list of nodes
|
|
8
|
-
* @returns Array of nodes
|
|
9
|
-
*/
|
|
10
|
-
export function getNodesFromGraph(G) {
|
|
11
|
-
if (Array.isArray(G)) {
|
|
12
|
-
return G;
|
|
13
|
-
}
|
|
14
|
-
return G.nodes();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Extract edges from a graph object
|
|
18
|
-
*
|
|
19
|
-
* @param G - Graph or list of nodes
|
|
20
|
-
* @returns Array of edges
|
|
21
|
-
*/
|
|
22
|
-
export function getEdgesFromGraph(G) {
|
|
23
|
-
if (Array.isArray(G)) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
return G.edges();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get the degree of a node in the graph
|
|
30
|
-
*
|
|
31
|
-
* @param graph - Graph object
|
|
32
|
-
* @param node - Node to get degree for
|
|
33
|
-
* @returns Degree of the node
|
|
34
|
-
*/
|
|
35
|
-
export function getNodeDegree(graph, node) {
|
|
36
|
-
if (!graph.edges)
|
|
37
|
-
return 0;
|
|
38
|
-
const edges = graph.edges();
|
|
39
|
-
let degree = 0;
|
|
40
|
-
for (const [source, target] of edges) {
|
|
41
|
-
if (source === node || target === node) {
|
|
42
|
-
degree++;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return degree;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the neighbors of a node in the graph
|
|
49
|
-
*
|
|
50
|
-
* @param graph - Graph object
|
|
51
|
-
* @param node - Node to get neighbors for
|
|
52
|
-
* @returns Array of neighbor nodes
|
|
53
|
-
*/
|
|
54
|
-
export function getNeighbors(graph, node) {
|
|
55
|
-
if (!graph.edges)
|
|
56
|
-
return [];
|
|
57
|
-
const neighbors = new Set();
|
|
58
|
-
const edges = graph.edges();
|
|
59
|
-
for (const [source, target] of edges) {
|
|
60
|
-
if (source === node) {
|
|
61
|
-
neighbors.add(target);
|
|
62
|
-
}
|
|
63
|
-
else if (target === node) {
|
|
64
|
-
neighbors.add(source);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return Array.from(neighbors);
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../../src/utils/graph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAiB;IACjD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAiB;IACjD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,IAAU;IACpD,IAAI,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,CAAC,CAAC;IAE3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACrC,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACvC,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY,EAAE,IAAU;IACnD,IAAI,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IAE5B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAE5B,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;aAAM,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAC3B,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/src/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NumPy-like array manipulation functions
|
|
3
|
-
* Maintains exact same functionality as original implementation
|
|
4
|
-
*/
|
|
5
|
-
export declare const np: {
|
|
6
|
-
zeros: (shape: number | number[]) => number | number[] | number[][] | any[];
|
|
7
|
-
ones: (shape: number | number[]) => number | any[];
|
|
8
|
-
linspace: (start: number, stop: number, num: number) => number[];
|
|
9
|
-
array: (arr: any) => any[];
|
|
10
|
-
repeat: (a: any, repeats: number) => any[];
|
|
11
|
-
mean: (arr: number[] | number[][], axis?: number | null) => number | number[];
|
|
12
|
-
add: (a: number | number[], b: number | number[]) => number | number[];
|
|
13
|
-
subtract: (a: number | number[], b: number | number[]) => number | number[];
|
|
14
|
-
max: (arr: number | number[]) => number;
|
|
15
|
-
min: (arr: number | number[]) => number;
|
|
16
|
-
norm: (arr: number[]) => number;
|
|
17
|
-
};
|
package/dist/src/utils/numpy.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NumPy-like array manipulation functions
|
|
3
|
-
* Maintains exact same functionality as original implementation
|
|
4
|
-
*/
|
|
5
|
-
export const np = {
|
|
6
|
-
zeros: function (shape) {
|
|
7
|
-
if (typeof shape === 'number') {
|
|
8
|
-
return Array(shape).fill(0);
|
|
9
|
-
}
|
|
10
|
-
if (shape.length === 1) {
|
|
11
|
-
return Array(shape[0]).fill(0);
|
|
12
|
-
}
|
|
13
|
-
return Array(shape[0]).fill(0).map(() => this.zeros(shape.slice(1)));
|
|
14
|
-
},
|
|
15
|
-
ones: function (shape) {
|
|
16
|
-
if (typeof shape === 'number') {
|
|
17
|
-
return Array(shape).fill(1);
|
|
18
|
-
}
|
|
19
|
-
if (shape.length === 1) {
|
|
20
|
-
return Array(shape[0]).fill(1);
|
|
21
|
-
}
|
|
22
|
-
return Array(shape[0]).fill(1).map(() => this.ones(shape.slice(1)));
|
|
23
|
-
},
|
|
24
|
-
linspace: function (start, stop, num) {
|
|
25
|
-
if (num === 1) {
|
|
26
|
-
return [start];
|
|
27
|
-
}
|
|
28
|
-
const step = (stop - start) / (num - 1);
|
|
29
|
-
return Array.from({ length: num }, (_, i) => start + i * step);
|
|
30
|
-
},
|
|
31
|
-
array: function (arr) {
|
|
32
|
-
return Array.isArray(arr) ? [...arr] : [arr];
|
|
33
|
-
},
|
|
34
|
-
repeat: function (a, repeats) {
|
|
35
|
-
const result = [];
|
|
36
|
-
for (let i = 0; i < repeats; i++) {
|
|
37
|
-
result.push(...np.array(a));
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
},
|
|
41
|
-
mean: function (arr, axis = null) {
|
|
42
|
-
if (axis === null) {
|
|
43
|
-
const flatArr = Array.isArray(arr[0])
|
|
44
|
-
? arr.flat(Infinity)
|
|
45
|
-
: arr;
|
|
46
|
-
const sum = flatArr.reduce((a, b) => a + b, 0);
|
|
47
|
-
return sum / flatArr.length;
|
|
48
|
-
}
|
|
49
|
-
if (axis === 0) {
|
|
50
|
-
const result = [];
|
|
51
|
-
const matrix = arr;
|
|
52
|
-
for (let i = 0; i < matrix[0].length; i++) {
|
|
53
|
-
let sum = 0;
|
|
54
|
-
for (let j = 0; j < matrix.length; j++) {
|
|
55
|
-
sum += matrix[j][i];
|
|
56
|
-
}
|
|
57
|
-
result.push(sum / matrix.length);
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
return arr.map(row => np.mean(row));
|
|
62
|
-
},
|
|
63
|
-
add: function (a, b) {
|
|
64
|
-
if (!Array.isArray(a) && !Array.isArray(b)) {
|
|
65
|
-
return a + b;
|
|
66
|
-
}
|
|
67
|
-
if (!Array.isArray(a)) {
|
|
68
|
-
return b.map(val => a + val);
|
|
69
|
-
}
|
|
70
|
-
if (!Array.isArray(b)) {
|
|
71
|
-
return a.map(val => val + b);
|
|
72
|
-
}
|
|
73
|
-
return a.map((val, i) => val + b[i]);
|
|
74
|
-
},
|
|
75
|
-
subtract: function (a, b) {
|
|
76
|
-
if (!Array.isArray(a) && !Array.isArray(b)) {
|
|
77
|
-
return a - b;
|
|
78
|
-
}
|
|
79
|
-
if (!Array.isArray(a)) {
|
|
80
|
-
return b.map(val => a - val);
|
|
81
|
-
}
|
|
82
|
-
if (!Array.isArray(b)) {
|
|
83
|
-
return a.map(val => val - b);
|
|
84
|
-
}
|
|
85
|
-
return a.map((val, i) => val - b[i]);
|
|
86
|
-
},
|
|
87
|
-
max: function (arr) {
|
|
88
|
-
if (!Array.isArray(arr))
|
|
89
|
-
return arr;
|
|
90
|
-
return Math.max(...arr.flat(Infinity));
|
|
91
|
-
},
|
|
92
|
-
min: function (arr) {
|
|
93
|
-
if (!Array.isArray(arr))
|
|
94
|
-
return arr;
|
|
95
|
-
return Math.min(...arr.flat(Infinity));
|
|
96
|
-
},
|
|
97
|
-
norm: function (arr) {
|
|
98
|
-
return Math.sqrt(arr.reduce((sum, val) => sum + val * val, 0));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=numpy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"numpy.js","sourceRoot":"","sources":["../../../src/utils/numpy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,KAAK,EAAE,UAAU,KAAwB;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,EAAE,UAAU,KAAwB;QACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,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,CAAC;IAED,GAAG,EAAE,UAAU,GAAsB;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAI,GAAgB,CAAC,IAAI,CAAC,QAAQ,CAAa,CAAC,CAAC;IACnE,CAAC;IAED,GAAG,EAAE,UAAU,GAAsB;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAI,GAAgB,CAAC,IAAI,CAAC,QAAQ,CAAa,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,EAAE,UAAU,GAAa;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;CACF,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parameter processing utilities
|
|
3
|
-
*/
|
|
4
|
-
import { Graph, Node } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Process and validate layout parameters
|
|
7
|
-
* Helper function similar to _process_params in Python version
|
|
8
|
-
*
|
|
9
|
-
* @param G - Graph object or array of nodes
|
|
10
|
-
* @param center - Center coordinates or null
|
|
11
|
-
* @param dim - Dimension of layout
|
|
12
|
-
* @returns Processed parameters
|
|
13
|
-
*/
|
|
14
|
-
export declare function _processParams(G: Graph | Node[], center: number[] | null, dim: number): {
|
|
15
|
-
G: Graph | Node[];
|
|
16
|
-
center: number[];
|
|
17
|
-
};
|
package/dist/src/utils/params.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parameter processing utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Process and validate layout parameters
|
|
6
|
-
* Helper function similar to _process_params in Python version
|
|
7
|
-
*
|
|
8
|
-
* @param G - Graph object or array of nodes
|
|
9
|
-
* @param center - Center coordinates or null
|
|
10
|
-
* @param dim - Dimension of layout
|
|
11
|
-
* @returns Processed parameters
|
|
12
|
-
*/
|
|
13
|
-
export function _processParams(G, center, dim) {
|
|
14
|
-
if (!center) {
|
|
15
|
-
center = Array(dim).fill(0);
|
|
16
|
-
}
|
|
17
|
-
if (center.length !== dim) {
|
|
18
|
-
throw new Error("length of center coordinates must match dimension of layout");
|
|
19
|
-
}
|
|
20
|
-
return { G, center };
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=params.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/utils/params.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,CAAiB,EAAE,MAAuB,EAAE,GAAW;IACpF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Random number generator for seed-based randomization
|
|
3
|
-
* Maintains exact same functionality as original implementation
|
|
4
|
-
*/
|
|
5
|
-
export declare class RandomNumberGenerator {
|
|
6
|
-
private seed;
|
|
7
|
-
private m;
|
|
8
|
-
private a;
|
|
9
|
-
private c;
|
|
10
|
-
private _state;
|
|
11
|
-
constructor(seed?: number);
|
|
12
|
-
_next(): number;
|
|
13
|
-
rand(shape?: number | number[] | null): number | number[] | number[][];
|
|
14
|
-
}
|
package/dist/src/utils/random.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Random number generator for seed-based randomization
|
|
3
|
-
* Maintains exact same functionality as original implementation
|
|
4
|
-
*/
|
|
5
|
-
export class RandomNumberGenerator {
|
|
6
|
-
constructor(seed) {
|
|
7
|
-
this.seed = seed || Math.floor(Math.random() * 1000000);
|
|
8
|
-
this.m = 2 ** 35 - 31;
|
|
9
|
-
this.a = 185852;
|
|
10
|
-
this.c = 1;
|
|
11
|
-
this._state = this.seed % this.m;
|
|
12
|
-
}
|
|
13
|
-
_next() {
|
|
14
|
-
this._state = (this.a * this._state + this.c) % this.m;
|
|
15
|
-
return this._state / this.m;
|
|
16
|
-
}
|
|
17
|
-
rand(shape = null) {
|
|
18
|
-
if (shape === null) {
|
|
19
|
-
return this._next();
|
|
20
|
-
}
|
|
21
|
-
if (typeof shape === 'number') {
|
|
22
|
-
const result = [];
|
|
23
|
-
for (let i = 0; i < shape; i++) {
|
|
24
|
-
result.push(this._next());
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
if (shape.length === 1) {
|
|
29
|
-
const result = [];
|
|
30
|
-
for (let i = 0; i < shape[0]; i++) {
|
|
31
|
-
result.push(this._next());
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
const result = [];
|
|
36
|
-
for (let i = 0; i < shape[0]; i++) {
|
|
37
|
-
result.push(this.rand(shape.slice(1)));
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=random.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/utils/random.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,qBAAqB;IAOhC,YAAY,IAAa;QACvB,IAAI,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AAE,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAU,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout rescaling utilities
|
|
3
|
-
*/
|
|
4
|
-
import { PositionMap } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Returns scaled position array/dict to (-scale, scale) in all axes.
|
|
7
|
-
*
|
|
8
|
-
* @param pos - Position dictionary or array
|
|
9
|
-
* @param scale - Scale factor for positions
|
|
10
|
-
* @param center - Coordinate pair around which to center the layout
|
|
11
|
-
* @returns Rescaled positions dictionary
|
|
12
|
-
*/
|
|
13
|
-
export declare function rescaleLayout(pos: PositionMap | number[][], scale?: number, center?: number[]): PositionMap | number[][];
|
|
14
|
-
/**
|
|
15
|
-
* Return a dictionary of scaled positions centered at (0, 0).
|
|
16
|
-
*
|
|
17
|
-
* @param pos - Dictionary of positions
|
|
18
|
-
* @param scale - Scale factor for positions
|
|
19
|
-
* @returns Dictionary of scaled positions
|
|
20
|
-
*/
|
|
21
|
-
export declare function rescaleLayoutDict(pos: PositionMap, scale?: number): PositionMap;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout rescaling utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Returns scaled position array/dict to (-scale, scale) in all axes.
|
|
6
|
-
*
|
|
7
|
-
* @param pos - Position dictionary or array
|
|
8
|
-
* @param scale - Scale factor for positions
|
|
9
|
-
* @param center - Coordinate pair around which to center the layout
|
|
10
|
-
* @returns Rescaled positions dictionary
|
|
11
|
-
*/
|
|
12
|
-
export function rescaleLayout(pos, scale = 1, center = [0, 0]) {
|
|
13
|
-
// Check if pos is empty
|
|
14
|
-
if (Array.isArray(pos)) {
|
|
15
|
-
if (pos.length === 0)
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
if (Object.keys(pos).length === 0)
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
// Extract position values
|
|
23
|
-
const posValues = Array.isArray(pos) ? pos : Object.values(pos);
|
|
24
|
-
const dim = posValues[0].length;
|
|
25
|
-
// Calculate center of positions
|
|
26
|
-
const posCenter = Array(dim).fill(0);
|
|
27
|
-
for (const p of posValues) {
|
|
28
|
-
for (let i = 0; i < dim; i++) {
|
|
29
|
-
posCenter[i] += p[i] / posValues.length;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
// Center positions
|
|
33
|
-
let centeredPos = {};
|
|
34
|
-
if (Array.isArray(pos)) {
|
|
35
|
-
centeredPos = pos.map(p => p.map((val, i) => val - posCenter[i]));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
for (const [node, p] of Object.entries(pos)) {
|
|
39
|
-
centeredPos[node] = p.map((val, i) => val - posCenter[i]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Find maximum distance from center
|
|
43
|
-
let maxDistance = 0;
|
|
44
|
-
const centeredValues = Array.isArray(centeredPos) ? centeredPos : Object.values(centeredPos);
|
|
45
|
-
for (const p of centeredValues) {
|
|
46
|
-
const distance = Math.sqrt(p.reduce((sum, val) => sum + val * val, 0));
|
|
47
|
-
maxDistance = Math.max(maxDistance, distance);
|
|
48
|
-
}
|
|
49
|
-
// Rescale
|
|
50
|
-
let scaledPos = Array.isArray(pos) ? [] : {};
|
|
51
|
-
if (maxDistance > 0) {
|
|
52
|
-
const scaleFactor = scale / maxDistance;
|
|
53
|
-
if (Array.isArray(pos)) {
|
|
54
|
-
scaledPos = centeredPos.map(p => p.map((val, i) => val * scaleFactor + center[i]));
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
for (const [node, p] of Object.entries(centeredPos)) {
|
|
58
|
-
scaledPos[node] = p.map((val, i) => val * scaleFactor + center[i]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// All nodes at the same position
|
|
64
|
-
if (Array.isArray(pos)) {
|
|
65
|
-
scaledPos = Array(pos.length).fill(0).map(() => [...center]);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
for (const node of Object.keys(pos)) {
|
|
69
|
-
scaledPos[node] = [...center];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return scaledPos;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Return a dictionary of scaled positions centered at (0, 0).
|
|
77
|
-
*
|
|
78
|
-
* @param pos - Dictionary of positions
|
|
79
|
-
* @param scale - Scale factor for positions
|
|
80
|
-
* @returns Dictionary of scaled positions
|
|
81
|
-
*/
|
|
82
|
-
export function rescaleLayoutDict(pos, scale = 1) {
|
|
83
|
-
if (Object.keys(pos).length === 0) {
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
// Extract positions as array
|
|
87
|
-
const posArray = Object.values(pos);
|
|
88
|
-
// Find center of positions
|
|
89
|
-
const center = [];
|
|
90
|
-
for (let d = 0; d < posArray[0].length; d++) {
|
|
91
|
-
center[d] = posArray.reduce((sum, p) => sum + p[d], 0) / posArray.length;
|
|
92
|
-
}
|
|
93
|
-
// Center positions
|
|
94
|
-
const centeredPos = {};
|
|
95
|
-
for (const [node, p] of Object.entries(pos)) {
|
|
96
|
-
centeredPos[node] = p.map((val, d) => val - center[d]);
|
|
97
|
-
}
|
|
98
|
-
// Find maximum distance from center
|
|
99
|
-
let maxDist = 0;
|
|
100
|
-
for (const p of Object.values(centeredPos)) {
|
|
101
|
-
const dist = Math.sqrt(p.reduce((sum, val) => sum + val * val, 0));
|
|
102
|
-
maxDist = Math.max(maxDist, dist);
|
|
103
|
-
}
|
|
104
|
-
// Scale positions
|
|
105
|
-
const scaledPos = {};
|
|
106
|
-
if (maxDist > 0) {
|
|
107
|
-
for (const [node, p] of Object.entries(centeredPos)) {
|
|
108
|
-
scaledPos[node] = p.map(val => val * scale / maxDist);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// All points at the center
|
|
113
|
-
for (const node of Object.keys(centeredPos)) {
|
|
114
|
-
scaledPos[node] = Array(centeredPos[node].length).fill(0);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return scaledPos;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=rescale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rescale.js","sourceRoot":"","sources":["../../../src/utils/rescale.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,GAA6B,EAC7B,QAAgB,CAAC,EACjB,SAAmB,CAAC,CAAC,EAAE,CAAC,CAAC;IAEzB,wBAAwB;IACxB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;IAC/C,CAAC;IAED,0BAA0B;IAC1B,MAAM,SAAS,GAAe,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,SAAS,CAAC,CA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AAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,oCAAoC;IACpC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACnE,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,kBAAkB;IAClB,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YACpD,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,KAAK,GAAG,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,2BAA2B;QAC3B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/vitest.config.d.ts
DELETED
package/dist/vitest.config.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
export default defineConfig({
|
|
3
|
-
test: {
|
|
4
|
-
globals: true,
|
|
5
|
-
environment: 'happy-dom',
|
|
6
|
-
pool: 'forks',
|
|
7
|
-
testTimeout: 30000,
|
|
8
|
-
coverage: {
|
|
9
|
-
provider: 'v8',
|
|
10
|
-
reporter: ['text', 'json', 'html', 'lcov'],
|
|
11
|
-
include: ['src/**/*.ts'],
|
|
12
|
-
exclude: ['**/*.d.ts', '**/*.test.ts'],
|
|
13
|
-
all: true,
|
|
14
|
-
thresholds: {
|
|
15
|
-
lines: 65,
|
|
16
|
-
functions: 60,
|
|
17
|
-
branches: 85,
|
|
18
|
-
statements: 65
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
include: ['test/**/*.test.ts', 'test/**/*.test.js'],
|
|
22
|
-
reporters: ['verbose']
|
|
23
|
-
},
|
|
24
|
-
resolve: {
|
|
25
|
-
alias: {
|
|
26
|
-
'@': '/src'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=vitest.config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE;YACR,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC1C,OAAO,EAAE,CAAC,aAAa,CAAC;YACxB,OAAO,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;YACtC,GAAG,EAAE,IAAI;YACT,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,EAAE;gBACb,QAAQ,EAAE,EAAE;gBACZ,UAAU,EAAE,EAAE;aACf;SACF;QACD,OAAO,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;QACnD,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB;IACD,OAAO,EAAE;QACP,KAAK,EAAE;YACL,GAAG,EAAE,MAAM;SACZ;KACF;CACF,CAAC,CAAC"}
|