egraph 6.0.0-alpha.8 → 6.0.0-beta.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 CHANGED
@@ -12,8 +12,10 @@ npm install egraph
12
12
 
13
13
  - **Pure ESM & Single `.wasm`**: Modern `"exports"` entrypoints for browsers/bundlers (`./pkg/index.js`) and Node.js 18+ (`./pkg/egraph_wasm.node.js`), sharing a single `wasm-opt -Oz` optimized `.wasm` binary.
14
14
  - **Strictly Single-Threaded**: Pure CPU Rust with deterministic seeded execution (`seed = 42` default), zero `rayon`, zero `std::thread`, zero Web Workers, and zero `SharedArrayBuffer`.
15
- - **Zero-Copy Linear Memory Views**: `Layout2d.coordsView()` returns a cached `Float32Array` view directly over WebAssembly linear memory and automatically refreshes when `memory.grow` detaches the underlying `ArrayBuffer`.
16
- - **Cooperative `requestAnimationFrame` Execution**: All iterative solvers implement `step()`, `runSteps(layout, k)`, and `run(layout)`, plus `runProgressive(solver, layout, onFrame, options?)` for responsive 60fps browser rendering.
15
+ - **Zero-Copy Linear Memory Views**: `coordsView()` on `Layout2d`, `Layout3d`, `LayoutNd`, and `ManifoldLayout2d` (plus `edgeOffsetsView()` / `pointsView()` on `EdgePolylines`, `labelsView()` on all 5 clustering result classes, and `centroidsView()` on `KMeansResult`) returns a cached typed-array view directly over WebAssembly linear memory and automatically refreshes if `memory.grow` detaches the `ArrayBuffer`.
16
+ - **Target-Checked Cooperative Execution & TS Contracts**: TypeScript interfaces (`LayoutStorage`, `IterativeSolver`, `LayoutGenerator`, `LayoutTransform`), explicit `target` (`"layout2d" | "layout3d" | "layoutNd" | "manifold2d"`), `step(layout)`, `runSteps(layout, k)`, `run(layout)`, and `runProgressive(solver, layout, onFrame, options?)` across `Layout2d`, `Layout3d`, `LayoutNd`, `ManifoldLayout2d`, and `EdgePolylines`.
17
+ - **Strict `camelCase`, `BigInt` Seeds, `.code` Errors & `f32` CSR**: Canonical `camelCase` option literals (`"barnesHut"`, `"fitFft"`, `"linearFft"`, `"ibFft"`, `"twoStepRandomWalk"`, `"hyperbolicLorentz"`), `number | bigint` 64-bit seeds, structured `Error` `.code` (`EgraphErrorCode`), and strict `weightDtype: "float32"` validation on `CsrGraph`.
18
+ - **Track A, Track B, Separated Solvers, 3D & Non-Euclidean Engines**: `TsNetSolver.pure2Hop({ backend: "auto2d" })` / `fromGraphRowNormalized`, `SgdSolver.sparseBarrierDog`, separated embedding classes (`Sgd2Solver`, `PacmapGraphSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `SnapTFdpSolver`), `TFdpSolver`, `IbUmapSolver`, `GuMapSolver`, `Layout3d` + `ArenaOctree3d`, `DynamicKdTree`, `EdgePolylines` + `FdebSolver(polylines)`, `ManifoldLayout2d` (`"hyperbolicLorentz"`, `toPoincareLayout`, `ManifoldMetric`, `torusSpectralPhaseInit`, `torusAutoPan`, `torusEdgeSegments`, geodesic crossings), `LayoutGenerator`s (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `CoarseBackbone`, `SfcLayout`), `LayoutTransform`s (`PfsPrimeOverlapRemoval`, `TwinDeclutterer` `.apply()`), `MetricReport` (`toRecord()`), `listDatasets` / synthetic generators, `DijkstraWorkspace`, Laplacian builders, and `ChebyshevDogKernel`.
17
19
 
18
20
  ## Quick Start (Browser / Bundler ESM)
19
21
 
@@ -35,11 +37,11 @@ const indices = new Uint32Array([1, 3, 0, 2, 1, 3, 2, 0]);
35
37
  const graph = CsrGraph.fromCsr(indptr, indices);
36
38
 
37
39
  // Initialize with normalized PivotMDS (f32 Layout2d)
38
- const layout = pivotMdsInit(graph, 4, 42);
40
+ const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
39
41
 
40
42
  // Run Track A Pure 1+2-Hop Adaptive tsNET progressively in requestAnimationFrame
41
43
  const solver = TsNetSolver.pure2Hop(graph, {
42
- backend: "fft",
44
+ backend: "auto2d",
43
45
  seed: 42,
44
46
  });
45
47
 
@@ -53,7 +55,7 @@ await runProgressive(
53
55
  { frameBudgetMs: 10 },
54
56
  );
55
57
 
56
- // Selectively evaluate quality metrics
58
+ // Selectively evaluate quality metrics -> MetricReport
57
59
  const report = evaluateMetrics(graph, layout, ["sns", "np2", "crossingNumber"]);
58
60
  console.log(report.toRecord());
59
61
  ```
@@ -68,57 +70,71 @@ import init, { CsrGraph, TFdpSolver, pivotMdsInit } from "egraph";
68
70
  await init();
69
71
 
70
72
  const graph = CsrGraph.fromEdgeList(4, new Uint32Array([0, 1, 1, 2, 2, 3, 3, 0]));
71
- const layout = pivotMdsInit(graph, 4, 42);
72
- const solver = new TFdpSolver(graph, { backend: "ibfft", totalIterations: 200, seed: 42 });
73
+ const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
74
+ const solver = new TFdpSolver(graph, { backend: "ibFft", iterations: 200, seed: 42 });
73
75
  solver.run(layout);
74
76
 
75
77
  const xy = layout.coordsView();
76
78
  console.log(Array.from(xy));
77
79
  ```
78
80
 
79
- ## Solver Examples
81
+ ## Solver & Engine Examples
80
82
 
81
- ### Track A: `TsNetSolver.pure2Hop`
83
+ ### Track A: `TsNetSolver.pure2Hop` & `fromGraphRowNormalized`
82
84
 
83
85
  ```js
84
86
  const solver = TsNetSolver.pure2Hop(graph, {
85
- backend: "fft",
87
+ backend: "auto2d", // "auto2d", "fitFft", "linearFft", "barnesHut", "exact"
86
88
  perplexityC: 0.9,
87
89
  seed: 42,
88
90
  });
89
91
  solver.run(layout);
92
+
93
+ const rnSolver = TsNetSolver.fromGraphRowNormalizedWithOptions(graph, {
94
+ w2: 0.5,
95
+ mode: "twoStepRandomWalk",
96
+ backend: "auto2d",
97
+ seed: 42,
98
+ });
99
+ rnSolver.run(layout);
90
100
  ```
91
101
 
92
- ### Track B & Unified Force Models: `TFdpSolver`, `ForceAtlas2Solver`, `GuMapSolver`
102
+ ### Track B, Separated Embedding & Force Models
93
103
 
94
104
  ```js
95
105
  import {
96
106
  ForceAtlas2Solver,
97
107
  GuMapSolver,
108
+ PacmapGraphSolver,
98
109
  SgdSolver,
110
+ SnapTFdpSolver,
99
111
  TFdpSolver,
100
112
  } from "egraph";
101
113
 
102
114
  // t-FDP with ibFFT repulsion
103
115
  const tfdp = new TFdpSolver(graph, {
104
- backend: "ibfft",
105
- totalIterations: 200,
116
+ backend: "ibFft",
117
+ iterations: 200,
106
118
  seed: 42,
107
119
  });
108
120
  tfdp.run(layout);
109
121
 
110
122
  // ForceAtlas2 (Barnes-Hut)
111
123
  const fa2 = new ForceAtlas2Solver(graph, {
124
+ backend: "barnesHut",
112
125
  iterations: 200,
113
- useBarnesHut: true,
114
126
  theta: 0.5,
115
127
  seed: 42,
116
128
  });
117
129
  fa2.run(layout);
118
130
 
131
+ // PaCMAP-Graph & SNAP-tFDP (standalone separated classes)
132
+ new PacmapGraphSolver(graph, { phaseIterations: [20, 20, 40], seed: 42 }).run(layout);
133
+ new SnapTFdpSolver(graph, { iterations: 100, seed: 42 }).run(layout);
134
+
119
135
  // GuMap from regularized Chebyshev DoG landmarks
120
136
  const gumap = GuMapSolver.fromGraphDog(graph, {
121
- nEpochs: 200,
137
+ iterations: 200,
122
138
  minDist: 0.1,
123
139
  spread: 1.0,
124
140
  seed: 42,
@@ -130,11 +146,86 @@ const barrierSgd = SgdSolver.sparseBarrierDog(graph, { seed: 42 });
130
146
  barrierSgd.run(layout);
131
147
  ```
132
148
 
133
- ### Overlap Removal (`PrismOverlapRemoval`)
149
+ ### `Layout3d`, `EdgePolylines` (`FdebSolver`), `BigInt` Seeds & Non-Euclidean Manifolds
134
150
 
135
151
  ```js
136
- import { PrismOverlapRemoval, prismDistortion } from "egraph";
152
+ import {
153
+ ArenaOctree3d,
154
+ EdgePolylines,
155
+ FdebSolver,
156
+ ForceAtlas2Solver,
157
+ Layout3d,
158
+ ManifoldLayout2d,
159
+ SgdSolver,
160
+ TsNetSolver,
161
+ geodesicDistortion,
162
+ runProgressive,
163
+ } from "egraph";
164
+
165
+ // 3D Layout3d with 64-bit BigInt seed, target: "layout3d", and ArenaOctree3d
166
+ const layout3d = Layout3d.init(graph.numNodes(), { seed: 42n });
167
+ new ForceAtlas2Solver(graph, {
168
+ target: "layout3d",
169
+ backend: "barnesHut",
170
+ iterations: 100,
171
+ seed: 42n,
172
+ }).run(layout3d);
173
+
174
+ const octree = new ArenaOctree3d();
175
+ octree.build(layout3d);
176
+ const repulsion = octree.computeCoulombRepulsion(0.5);
177
+
178
+ // Edge bundling via EdgePolylines + FdebSolver
179
+ const polylines = EdgePolylines.straightLineFromGraph(graph, layout);
180
+ const fdeb = new FdebSolver(polylines, { cycles: 3, stepsPerCycle: 15 });
181
+ fdeb.run(polylines);
182
+ console.log("bundled points:", polylines.edgeOffsetsView().length, polylines.pointsView().length);
183
+
184
+ // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: "manifold2d"
185
+ const lorentz = ManifoldLayout2d.init("hyperbolicLorentz", graph.numNodes(), { seed: 42 });
186
+ await runProgressive(
187
+ SgdSolver.full(graph, { target: "manifold2d", iterations: 60, seed: 42 }),
188
+ lorentz,
189
+ );
190
+ const poincare = lorentz.toPoincareLayout();
191
+ console.log("geodesicDistortion:", geodesicDistortion(graph, poincare));
192
+
193
+ // Torus spectral phase init & optimal boundary auto-pan
194
+ const torus = ManifoldLayout2d.torusSpectralPhaseInit(graph, 42);
195
+ const panned = torus.torusAutoPan(graph);
196
+ console.log(panned.coordsView().length);
197
+
198
+ // Structured error codes (.code: EgraphErrorCode) on invalid (target, backend) pairs
199
+ try {
200
+ TsNetSolver.pure2Hop(graph, { target: "layout3d", backend: "fitFft" });
201
+ } catch (err) {
202
+ console.error("Error code:", err.code); // "UnsupportedOperation"
203
+ }
204
+ ```
137
205
 
206
+ ### Clustering (`labelsView()`), Overlap Removal, `LayoutTransform` & Datasets
207
+
208
+ ```js
209
+ import {
210
+ Layout2d,
211
+ PrismOverlapRemoval,
212
+ TwinDeclutterer,
213
+ generateSbmGraph,
214
+ leidenCommunities,
215
+ listDatasets,
216
+ prismDistortion,
217
+ } from "egraph";
218
+
219
+ // Synthetic SBM graph ({ ...options }) + zero-copy LeidenResult.labelsView()
220
+ const { graph: sbmGraph, labels: groundTruth } = generateSbmGraph(
221
+ new Uint32Array([12, 12]),
222
+ { pIntra: 0.5, pInter: 0.05, seed: 42 },
223
+ );
224
+ const leiden = leidenCommunities(sbmGraph, { seed: 42 });
225
+ const labels = leiden.labelsView();
226
+ console.log("datasets:", listDatasets().length, "communities:", leiden.numCommunities, labels.length, groundTruth.length);
227
+
228
+ // Overlap removal (PRISM) + TwinDeclutterer LayoutTransform (.apply)
138
229
  const original = Layout2d.fromCoords(layout.coordsView());
139
230
  const radii = new Float32Array(graph.numNodes()).fill(0.25);
140
231
  const prism = PrismOverlapRemoval.fromRadii(radii, {
@@ -143,20 +234,45 @@ const prism = PrismOverlapRemoval.fromRadii(radii, {
143
234
  seed: 42,
144
235
  });
145
236
  prism.run(layout);
237
+ new TwinDeclutterer({ iterations: 4 }).apply(layout);
146
238
 
147
239
  const distortion = prismDistortion(original, layout);
148
240
  console.log(prism.lastOverlapCount, distortion.sigmaDist, distortion.sigmaDisp);
149
241
  ```
150
242
 
243
+ ### Linalg, `LayoutGenerator`s, Chebyshev & Shortest Paths
244
+
245
+ ```js
246
+ import {
247
+ ChebyshevDogKernel,
248
+ ClassicalMds,
249
+ DijkstraWorkspace,
250
+ PivotMds,
251
+ classicalMds,
252
+ combinatorialLaplacian,
253
+ pivotMds,
254
+ } from "egraph";
255
+
256
+ const ws = new DijkstraWorkspace(graph.numNodes());
257
+ const dists = ws.dijkstraFrom(graph, 0);
258
+ const mdsNd = classicalMds(graph, 3);
259
+ const mds3d = new ClassicalMds({ target: "layout3d" }).generate(graph);
260
+ const mds2d = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
261
+ const mds2dFn = pivotMds(graph, { numPivots: 4, seed: 42 });
262
+ const lap = combinatorialLaplacian(graph);
263
+ const dog = new ChebyshevDogKernel(graph, { seed: 42 });
264
+ console.log(dists.length, mdsNd.dims, mds3d.len(), mds2d.numNodes, mds2dFn.numNodes, lap.nnz, dog.degree);
265
+ ```
266
+
151
267
  ## Migration from v5 / Legacy Alpha
152
268
 
153
- See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for a complete v5/legacy-alpha to v6 migration guide, including:
269
+ See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for a complete v5, `alpha.8 -> alpha.9`, and v6 API freeze migration guide, including:
154
270
 
155
- 1. Replacing `Graph` host object weights with `CsrGraph.fromCsr` / `CsrGraph.fromEdgeList` and host-side arrays
156
- 2. Migrating `OverwrapRemoval` to `PrismOverlapRemoval`
157
- 3. Consolidating `TsNet` / `BhTsNet` / `FitTsNet` / `LTsNet` into `TsNetSolver.pure2Hop`
158
- 4. Replacing `stress` (`NS`) with Scale-Normalized Stress (`scaleNormalizedStress` / `evaluateMetrics`)
159
- 5. Migrating from `egraph/dist/web/egraph_wasm` to pure ESM, `coordsView()`, and `runProgressive`
271
+ 1. Replacing `Graph` host object weights with `CsrGraph.fromCsr` / `CsrGraph.fromEdgeList` (`weightDtype: "float32"`) and host-side arrays
272
+ 2. Migrating overlap removal and post-processing to `PrismOverlapRemoval` / `ForbidOverlapRemoval` and `LayoutTransform.apply()` (`PfsPrimeOverlapRemoval`, `TwinDeclutterer`)
273
+ 3. Consolidating `TsNet` / `BhTsNet` / `FitTsNet` / `LTsNet` into `TsNetSolver` (`pure2Hop`, `fromGraphRowNormalized`, `auto2d`/`auto3d`/`fitFft`/`linearFft`/`barnesHut`/`exact`) and `LayoutGenerator` structs (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `CoarseBackbone`, `SfcLayout`)
274
+ 4. Adopting `Layout3d`, `EdgePolylines` + `FdebSolver(polylines)`, separated SGD classes (`Sgd2Solver`, `PacmapGraphSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `SnapTFdpSolver`), and explicit `target` (`"layout2d" | "layout3d" | "layoutNd" | "manifold2d"`)
275
+ 5. Migrating from `egraph/dist/web/egraph_wasm` to pure ESM, `coordsView()`, `edgeOffsetsView()`, `pointsView()`, `labelsView()`, `runProgressive`, `{ ...options }`, `camelCase` literals, `number | bigint` seeds, and `.code` structured errors
160
276
 
161
277
  ## License
162
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egraph",
3
- "version": "6.0.0-alpha.8",
3
+ "version": "6.0.0-beta.1",
4
4
  "collaborators": [
5
5
  "Yosuke Onoue <onoue@likr-lab.com>"
6
6
  ],
package/pkg/README.md CHANGED
@@ -12,8 +12,10 @@ npm install egraph
12
12
 
13
13
  - **Pure ESM & Single `.wasm`**: Modern `"exports"` entrypoints for browsers/bundlers (`./pkg/index.js`) and Node.js 18+ (`./pkg/egraph_wasm.node.js`), sharing a single `wasm-opt -Oz` optimized `.wasm` binary.
14
14
  - **Strictly Single-Threaded**: Pure CPU Rust with deterministic seeded execution (`seed = 42` default), zero `rayon`, zero `std::thread`, zero Web Workers, and zero `SharedArrayBuffer`.
15
- - **Zero-Copy Linear Memory Views**: `Layout2d.coordsView()` returns a cached `Float32Array` view directly over WebAssembly linear memory and automatically refreshes when `memory.grow` detaches the underlying `ArrayBuffer`.
16
- - **Cooperative `requestAnimationFrame` Execution**: All iterative solvers implement `step()`, `runSteps(layout, k)`, and `run(layout)`, plus `runProgressive(solver, layout, onFrame, options?)` for responsive 60fps browser rendering.
15
+ - **Zero-Copy Linear Memory Views**: `coordsView()` on `Layout2d`, `Layout3d`, `LayoutNd`, and `ManifoldLayout2d` (plus `edgeOffsetsView()` / `pointsView()` on `EdgePolylines`, `labelsView()` on all 5 clustering result classes, and `centroidsView()` on `KMeansResult`) returns a cached typed-array view directly over WebAssembly linear memory and automatically refreshes if `memory.grow` detaches the `ArrayBuffer`.
16
+ - **Target-Checked Cooperative Execution & TS Contracts**: TypeScript interfaces (`LayoutStorage`, `IterativeSolver`, `LayoutGenerator`, `LayoutTransform`), explicit `target` (`"layout2d" | "layout3d" | "layoutNd" | "manifold2d"`), `step(layout)`, `runSteps(layout, k)`, `run(layout)`, and `runProgressive(solver, layout, onFrame, options?)` across `Layout2d`, `Layout3d`, `LayoutNd`, `ManifoldLayout2d`, and `EdgePolylines`.
17
+ - **Strict `camelCase`, `BigInt` Seeds, `.code` Errors & `f32` CSR**: Canonical `camelCase` option literals (`"barnesHut"`, `"fitFft"`, `"linearFft"`, `"ibFft"`, `"twoStepRandomWalk"`, `"hyperbolicLorentz"`), `number | bigint` 64-bit seeds, structured `Error` `.code` (`EgraphErrorCode`), and strict `weightDtype: "float32"` validation on `CsrGraph`.
18
+ - **Track A, Track B, Separated Solvers, 3D & Non-Euclidean Engines**: `TsNetSolver.pure2Hop({ backend: "auto2d" })` / `fromGraphRowNormalized`, `SgdSolver.sparseBarrierDog`, separated embedding classes (`Sgd2Solver`, `PacmapGraphSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `SnapTFdpSolver`), `TFdpSolver`, `IbUmapSolver`, `GuMapSolver`, `Layout3d` + `ArenaOctree3d`, `DynamicKdTree`, `EdgePolylines` + `FdebSolver(polylines)`, `ManifoldLayout2d` (`"hyperbolicLorentz"`, `toPoincareLayout`, `ManifoldMetric`, `torusSpectralPhaseInit`, `torusAutoPan`, `torusEdgeSegments`, geodesic crossings), `LayoutGenerator`s (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `CoarseBackbone`, `SfcLayout`), `LayoutTransform`s (`PfsPrimeOverlapRemoval`, `TwinDeclutterer` `.apply()`), `MetricReport` (`toRecord()`), `listDatasets` / synthetic generators, `DijkstraWorkspace`, Laplacian builders, and `ChebyshevDogKernel`.
17
19
 
18
20
  ## Quick Start (Browser / Bundler ESM)
19
21
 
@@ -35,11 +37,11 @@ const indices = new Uint32Array([1, 3, 0, 2, 1, 3, 2, 0]);
35
37
  const graph = CsrGraph.fromCsr(indptr, indices);
36
38
 
37
39
  // Initialize with normalized PivotMDS (f32 Layout2d)
38
- const layout = pivotMdsInit(graph, 4, 42);
40
+ const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
39
41
 
40
42
  // Run Track A Pure 1+2-Hop Adaptive tsNET progressively in requestAnimationFrame
41
43
  const solver = TsNetSolver.pure2Hop(graph, {
42
- backend: "fft",
44
+ backend: "auto2d",
43
45
  seed: 42,
44
46
  });
45
47
 
@@ -53,7 +55,7 @@ await runProgressive(
53
55
  { frameBudgetMs: 10 },
54
56
  );
55
57
 
56
- // Selectively evaluate quality metrics
58
+ // Selectively evaluate quality metrics -> MetricReport
57
59
  const report = evaluateMetrics(graph, layout, ["sns", "np2", "crossingNumber"]);
58
60
  console.log(report.toRecord());
59
61
  ```
@@ -68,57 +70,71 @@ import init, { CsrGraph, TFdpSolver, pivotMdsInit } from "egraph";
68
70
  await init();
69
71
 
70
72
  const graph = CsrGraph.fromEdgeList(4, new Uint32Array([0, 1, 1, 2, 2, 3, 3, 0]));
71
- const layout = pivotMdsInit(graph, 4, 42);
72
- const solver = new TFdpSolver(graph, { backend: "ibfft", totalIterations: 200, seed: 42 });
73
+ const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
74
+ const solver = new TFdpSolver(graph, { backend: "ibFft", iterations: 200, seed: 42 });
73
75
  solver.run(layout);
74
76
 
75
77
  const xy = layout.coordsView();
76
78
  console.log(Array.from(xy));
77
79
  ```
78
80
 
79
- ## Solver Examples
81
+ ## Solver & Engine Examples
80
82
 
81
- ### Track A: `TsNetSolver.pure2Hop`
83
+ ### Track A: `TsNetSolver.pure2Hop` & `fromGraphRowNormalized`
82
84
 
83
85
  ```js
84
86
  const solver = TsNetSolver.pure2Hop(graph, {
85
- backend: "fft",
87
+ backend: "auto2d", // "auto2d", "fitFft", "linearFft", "barnesHut", "exact"
86
88
  perplexityC: 0.9,
87
89
  seed: 42,
88
90
  });
89
91
  solver.run(layout);
92
+
93
+ const rnSolver = TsNetSolver.fromGraphRowNormalizedWithOptions(graph, {
94
+ w2: 0.5,
95
+ mode: "twoStepRandomWalk",
96
+ backend: "auto2d",
97
+ seed: 42,
98
+ });
99
+ rnSolver.run(layout);
90
100
  ```
91
101
 
92
- ### Track B & Unified Force Models: `TFdpSolver`, `ForceAtlas2Solver`, `GuMapSolver`
102
+ ### Track B, Separated Embedding & Force Models
93
103
 
94
104
  ```js
95
105
  import {
96
106
  ForceAtlas2Solver,
97
107
  GuMapSolver,
108
+ PacmapGraphSolver,
98
109
  SgdSolver,
110
+ SnapTFdpSolver,
99
111
  TFdpSolver,
100
112
  } from "egraph";
101
113
 
102
114
  // t-FDP with ibFFT repulsion
103
115
  const tfdp = new TFdpSolver(graph, {
104
- backend: "ibfft",
105
- totalIterations: 200,
116
+ backend: "ibFft",
117
+ iterations: 200,
106
118
  seed: 42,
107
119
  });
108
120
  tfdp.run(layout);
109
121
 
110
122
  // ForceAtlas2 (Barnes-Hut)
111
123
  const fa2 = new ForceAtlas2Solver(graph, {
124
+ backend: "barnesHut",
112
125
  iterations: 200,
113
- useBarnesHut: true,
114
126
  theta: 0.5,
115
127
  seed: 42,
116
128
  });
117
129
  fa2.run(layout);
118
130
 
131
+ // PaCMAP-Graph & SNAP-tFDP (standalone separated classes)
132
+ new PacmapGraphSolver(graph, { phaseIterations: [20, 20, 40], seed: 42 }).run(layout);
133
+ new SnapTFdpSolver(graph, { iterations: 100, seed: 42 }).run(layout);
134
+
119
135
  // GuMap from regularized Chebyshev DoG landmarks
120
136
  const gumap = GuMapSolver.fromGraphDog(graph, {
121
- nEpochs: 200,
137
+ iterations: 200,
122
138
  minDist: 0.1,
123
139
  spread: 1.0,
124
140
  seed: 42,
@@ -130,11 +146,86 @@ const barrierSgd = SgdSolver.sparseBarrierDog(graph, { seed: 42 });
130
146
  barrierSgd.run(layout);
131
147
  ```
132
148
 
133
- ### Overlap Removal (`PrismOverlapRemoval`)
149
+ ### `Layout3d`, `EdgePolylines` (`FdebSolver`), `BigInt` Seeds & Non-Euclidean Manifolds
134
150
 
135
151
  ```js
136
- import { PrismOverlapRemoval, prismDistortion } from "egraph";
152
+ import {
153
+ ArenaOctree3d,
154
+ EdgePolylines,
155
+ FdebSolver,
156
+ ForceAtlas2Solver,
157
+ Layout3d,
158
+ ManifoldLayout2d,
159
+ SgdSolver,
160
+ TsNetSolver,
161
+ geodesicDistortion,
162
+ runProgressive,
163
+ } from "egraph";
164
+
165
+ // 3D Layout3d with 64-bit BigInt seed, target: "layout3d", and ArenaOctree3d
166
+ const layout3d = Layout3d.init(graph.numNodes(), { seed: 42n });
167
+ new ForceAtlas2Solver(graph, {
168
+ target: "layout3d",
169
+ backend: "barnesHut",
170
+ iterations: 100,
171
+ seed: 42n,
172
+ }).run(layout3d);
173
+
174
+ const octree = new ArenaOctree3d();
175
+ octree.build(layout3d);
176
+ const repulsion = octree.computeCoulombRepulsion(0.5);
177
+
178
+ // Edge bundling via EdgePolylines + FdebSolver
179
+ const polylines = EdgePolylines.straightLineFromGraph(graph, layout);
180
+ const fdeb = new FdebSolver(polylines, { cycles: 3, stepsPerCycle: 15 });
181
+ fdeb.run(polylines);
182
+ console.log("bundled points:", polylines.edgeOffsetsView().length, polylines.pointsView().length);
183
+
184
+ // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: "manifold2d"
185
+ const lorentz = ManifoldLayout2d.init("hyperbolicLorentz", graph.numNodes(), { seed: 42 });
186
+ await runProgressive(
187
+ SgdSolver.full(graph, { target: "manifold2d", iterations: 60, seed: 42 }),
188
+ lorentz,
189
+ );
190
+ const poincare = lorentz.toPoincareLayout();
191
+ console.log("geodesicDistortion:", geodesicDistortion(graph, poincare));
192
+
193
+ // Torus spectral phase init & optimal boundary auto-pan
194
+ const torus = ManifoldLayout2d.torusSpectralPhaseInit(graph, 42);
195
+ const panned = torus.torusAutoPan(graph);
196
+ console.log(panned.coordsView().length);
197
+
198
+ // Structured error codes (.code: EgraphErrorCode) on invalid (target, backend) pairs
199
+ try {
200
+ TsNetSolver.pure2Hop(graph, { target: "layout3d", backend: "fitFft" });
201
+ } catch (err) {
202
+ console.error("Error code:", err.code); // "UnsupportedOperation"
203
+ }
204
+ ```
137
205
 
206
+ ### Clustering (`labelsView()`), Overlap Removal, `LayoutTransform` & Datasets
207
+
208
+ ```js
209
+ import {
210
+ Layout2d,
211
+ PrismOverlapRemoval,
212
+ TwinDeclutterer,
213
+ generateSbmGraph,
214
+ leidenCommunities,
215
+ listDatasets,
216
+ prismDistortion,
217
+ } from "egraph";
218
+
219
+ // Synthetic SBM graph ({ ...options }) + zero-copy LeidenResult.labelsView()
220
+ const { graph: sbmGraph, labels: groundTruth } = generateSbmGraph(
221
+ new Uint32Array([12, 12]),
222
+ { pIntra: 0.5, pInter: 0.05, seed: 42 },
223
+ );
224
+ const leiden = leidenCommunities(sbmGraph, { seed: 42 });
225
+ const labels = leiden.labelsView();
226
+ console.log("datasets:", listDatasets().length, "communities:", leiden.numCommunities, labels.length, groundTruth.length);
227
+
228
+ // Overlap removal (PRISM) + TwinDeclutterer LayoutTransform (.apply)
138
229
  const original = Layout2d.fromCoords(layout.coordsView());
139
230
  const radii = new Float32Array(graph.numNodes()).fill(0.25);
140
231
  const prism = PrismOverlapRemoval.fromRadii(radii, {
@@ -143,20 +234,45 @@ const prism = PrismOverlapRemoval.fromRadii(radii, {
143
234
  seed: 42,
144
235
  });
145
236
  prism.run(layout);
237
+ new TwinDeclutterer({ iterations: 4 }).apply(layout);
146
238
 
147
239
  const distortion = prismDistortion(original, layout);
148
240
  console.log(prism.lastOverlapCount, distortion.sigmaDist, distortion.sigmaDisp);
149
241
  ```
150
242
 
243
+ ### Linalg, `LayoutGenerator`s, Chebyshev & Shortest Paths
244
+
245
+ ```js
246
+ import {
247
+ ChebyshevDogKernel,
248
+ ClassicalMds,
249
+ DijkstraWorkspace,
250
+ PivotMds,
251
+ classicalMds,
252
+ combinatorialLaplacian,
253
+ pivotMds,
254
+ } from "egraph";
255
+
256
+ const ws = new DijkstraWorkspace(graph.numNodes());
257
+ const dists = ws.dijkstraFrom(graph, 0);
258
+ const mdsNd = classicalMds(graph, 3);
259
+ const mds3d = new ClassicalMds({ target: "layout3d" }).generate(graph);
260
+ const mds2d = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
261
+ const mds2dFn = pivotMds(graph, { numPivots: 4, seed: 42 });
262
+ const lap = combinatorialLaplacian(graph);
263
+ const dog = new ChebyshevDogKernel(graph, { seed: 42 });
264
+ console.log(dists.length, mdsNd.dims, mds3d.len(), mds2d.numNodes, mds2dFn.numNodes, lap.nnz, dog.degree);
265
+ ```
266
+
151
267
  ## Migration from v5 / Legacy Alpha
152
268
 
153
- See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for a complete v5/legacy-alpha to v6 migration guide, including:
269
+ See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for a complete v5, `alpha.8 -> alpha.9`, and v6 API freeze migration guide, including:
154
270
 
155
- 1. Replacing `Graph` host object weights with `CsrGraph.fromCsr` / `CsrGraph.fromEdgeList` and host-side arrays
156
- 2. Migrating `OverwrapRemoval` to `PrismOverlapRemoval`
157
- 3. Consolidating `TsNet` / `BhTsNet` / `FitTsNet` / `LTsNet` into `TsNetSolver.pure2Hop`
158
- 4. Replacing `stress` (`NS`) with Scale-Normalized Stress (`scaleNormalizedStress` / `evaluateMetrics`)
159
- 5. Migrating from `egraph/dist/web/egraph_wasm` to pure ESM, `coordsView()`, and `runProgressive`
271
+ 1. Replacing `Graph` host object weights with `CsrGraph.fromCsr` / `CsrGraph.fromEdgeList` (`weightDtype: "float32"`) and host-side arrays
272
+ 2. Migrating overlap removal and post-processing to `PrismOverlapRemoval` / `ForbidOverlapRemoval` and `LayoutTransform.apply()` (`PfsPrimeOverlapRemoval`, `TwinDeclutterer`)
273
+ 3. Consolidating `TsNet` / `BhTsNet` / `FitTsNet` / `LTsNet` into `TsNetSolver` (`pure2Hop`, `fromGraphRowNormalized`, `auto2d`/`auto3d`/`fitFft`/`linearFft`/`barnesHut`/`exact`) and `LayoutGenerator` structs (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `CoarseBackbone`, `SfcLayout`)
274
+ 4. Adopting `Layout3d`, `EdgePolylines` + `FdebSolver(polylines)`, separated SGD classes (`Sgd2Solver`, `PacmapGraphSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `SnapTFdpSolver`), and explicit `target` (`"layout2d" | "layout3d" | "layoutNd" | "manifold2d"`)
275
+ 5. Migrating from `egraph/dist/web/egraph_wasm` to pure ESM, `coordsView()`, `edgeOffsetsView()`, `pointsView()`, `labelsView()`, `runProgressive`, `{ ...options }`, `camelCase` literals, `number | bigint` seeds, and `.code` structured errors
160
276
 
161
277
  ## License
162
278