@graphty/layout 1.5.0 → 1.5.1
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 +2 -1
- package/dist/layout.js +3 -2
- package/dist/layout.js.map +1 -1
- package/dist/src/layouts/specialized/spectral.d.ts +2 -1
- package/dist/src/layouts/specialized/spectral.d.ts.map +1 -1
- package/dist/src/layouts/specialized/spectral.js +5 -2
- package/dist/src/layouts/specialized/spectral.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +30 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +27 -3
- package/src/layouts/specialized/spectral.ts +5 -1
package/README.md
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@graphty/layout)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
[](https://graphty.app/docs/layout/)
|
|
8
|
+
[](https://graphty.app/storybook/layout/)
|
|
8
9
|
[](https://graphty.app/layout/examples/index.html)
|
|
9
10
|
|
|
10
|
-
**[View Interactive Examples →](https://graphty.app/layout/examples/index.html)**
|
|
11
|
+
**[View Interactive Storybook →](https://graphty.app/storybook/layout/)** | **[Legacy Examples →](https://graphty.app/layout/examples/index.html)**
|
|
11
12
|
|
|
12
13
|
Layout is a TypeScript library for positioning nodes in graphs. It's a TypeScript port of the [layout algorithms](https://networkx.org/documentation/stable/reference/drawing.html) from the Python [NetworkX](https://networkx.org/documentation/stable/) library.
|
|
13
14
|
|
package/dist/layout.js
CHANGED
|
@@ -1561,7 +1561,7 @@ function planarLayout(G, scale = 1, center = null, dim = 2, seed = null) {
|
|
|
1561
1561
|
pos = rescaleLayout(pos, scale, center);
|
|
1562
1562
|
return pos;
|
|
1563
1563
|
}
|
|
1564
|
-
function spectralLayout(G, scale = 1, center = null, dim = 2) {
|
|
1564
|
+
function spectralLayout(G, scale = 1, center = null, dim = 2, seed = null) {
|
|
1565
1565
|
const processed = _processParams(G, center, dim);
|
|
1566
1566
|
const graph = processed.G;
|
|
1567
1567
|
({ center } = processed);
|
|
@@ -1598,8 +1598,9 @@ function spectralLayout(G, scale = 1, center = null, dim = 2) {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
}
|
|
1600
1600
|
const eigenvectors = [];
|
|
1601
|
+
const rng = new RandomNumberGenerator(seed ?? void 0);
|
|
1601
1602
|
for (let d = 0; d < dim; d++) {
|
|
1602
|
-
let vector = Array(N).fill(0).map(() =>
|
|
1603
|
+
let vector = Array(N).fill(0).map(() => rng.rand(null) - 0.5);
|
|
1603
1604
|
for (const ev of eigenvectors) {
|
|
1604
1605
|
const dot = vector.reduce((acc, val, idx) => acc + val * ev[idx], 0);
|
|
1605
1606
|
vector = vector.map((val, idx) => val - dot * ev[idx]);
|