@graphty/layout 1.5.0 → 1.6.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/README.md CHANGED
@@ -5,9 +5,10 @@
5
5
  [![npm version](https://img.shields.io/npm/v/@graphty/layout.svg)](https://www.npmjs.com/package/@graphty/layout)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![Documentation](https://img.shields.io/badge/docs-vitepress-blue)](https://graphty.app/docs/layout/)
8
+ [![Storybook](https://img.shields.io/badge/storybook-interactive%20demos-ff4785)](https://graphty.app/storybook/layout/)
8
9
  [![Examples](https://img.shields.io/badge/demo-github%20pages-blue)](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(() => Math.random() - 0.5);
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]);