egraph 6.0.0-beta.3 → 6.0.0-beta.4

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
@@ -13,19 +13,20 @@ npm install egraph
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
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`.
16
+ - **Target-Checked Cooperative Execution & TS Contracts**: TypeScript interfaces (`LayoutStorage`, `IterativeSolver`, `LayoutGenerator`, `LayoutTransform`), typed `#[wasm_bindgen]` enums (`TargetKind`, `WeightDtype`, `ManifoldKind`, `TsNetBackend`, `FieldRepulsionBackend`, `ForceBackend`, `MetricTarget`, `SolverStatus`, etc.), `step(layout)`, `runSteps(layout, k)`, `run(layout)`, and `runProgressive(solver, layout, onFrame, options?)`.
17
+ - **Strict `camelCase`, `BigInt` Seeds, `.code` Errors & `f32` CSR**: `number | bigint` 64-bit seeds, structured `Error` `.code` (`EgraphErrorCode`), and strict `WeightDtype.Float32` validation on `CsrGraph`.
18
+ - **Comprehensive Layout, 3D & Non-Euclidean Engines**: `SgdSolver` (`full`, `randomPair`, `ortmannSparseStress`, `omega`), `StressMajorizationSolver`, `KamadaKawaiSolver`, `MaxentStressSolver`, `TsNetSolver` (`fromKnn`, `fromProbabilities`, `fromGraphPartialBfs`), `TFdpSolver`, `IbUmapSolver`, `GuMapSolver`, `SnapTFdpSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `ForceAtlas2Solver`, `YifanHuSolver`, `LinLogSolver`, `FruchtermanReingoldSolver`, `GemSolver`, `GripSolver`, `Layout3d` + `ArenaOctree3d`, `DynamicKdTree`, `EdgePolylines` + `FdebSolver(polylines)`, `ManifoldLayout2d` (`ManifoldKind.HyperbolicLorentz`, `toPoincareLayout`, `metric()` (`ManifoldMetricRecord`), `torusAutoPan`, geodesic crossings), `LayoutGenerator`s (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `SfcLayout`), `LayoutTransform`s (`PfsPrimeOverlapRemoval`, `TwinDeclutterer` `.apply()`), `MetricReport` (`toRecord()`), `listDatasets` / synthetic generators, and `DijkstraWorkspace` (plus `egraph-rs` extensions; see [PAPER_MAPPING.md](https://github.com/likr/egraph-rs/blob/master/docs/PAPER_MAPPING.md)).
19
19
 
20
20
  ## Quick Start (Browser / Bundler ESM)
21
21
 
22
22
  ```js
23
23
  import init, {
24
24
  CsrGraph,
25
- Layout2d,
26
- TsNetSolver,
25
+ FieldRepulsionBackend,
26
+ MetricTarget,
27
+ PivotMds,
28
+ TFdpSolver,
27
29
  evaluateMetrics,
28
- pivotMdsInit,
29
30
  runProgressive,
30
31
  } from "egraph";
31
32
 
@@ -37,11 +38,12 @@ const indices = new Uint32Array([1, 3, 0, 2, 1, 3, 2, 0]);
37
38
  const graph = CsrGraph.fromCsr(indptr, indices);
38
39
 
39
40
  // Initialize with normalized PivotMDS (f32 Layout2d)
40
- const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
41
+ const layout = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
41
42
 
42
- // Run Track A Pure 1+2-Hop Adaptive tsNET progressively in requestAnimationFrame
43
- const solver = TsNetSolver.pure2Hop(graph, {
44
- backend: "auto2d",
43
+ // Run t-FDP (Zhong et al., 2023) progressively in requestAnimationFrame
44
+ const solver = new TFdpSolver(graph, {
45
+ backend: FieldRepulsionBackend.IbFft,
46
+ iterations: 200,
45
47
  seed: 42,
46
48
  });
47
49
 
@@ -56,7 +58,11 @@ await runProgressive(
56
58
  );
57
59
 
58
60
  // Selectively evaluate quality metrics -> MetricReport
59
- const report = evaluateMetrics(graph, layout, ["sns", "np2", "crossingNumber"]);
61
+ const report = evaluateMetrics(graph, layout, [
62
+ MetricTarget.ScaleNormalizedStress,
63
+ MetricTarget.NeighborhoodPreservation2Hop,
64
+ MetricTarget.CrossingNumber,
65
+ ]);
60
66
  console.log(report.toRecord());
61
67
  ```
62
68
 
@@ -65,13 +71,17 @@ console.log(report.toRecord());
65
71
  The same `"egraph"` import automatically resolves to the Node ESM loader via `"exports"`:
66
72
 
67
73
  ```js
68
- import init, { CsrGraph, TFdpSolver, pivotMdsInit } from "egraph";
74
+ import init, { CsrGraph, FieldRepulsionBackend, PivotMds, TFdpSolver } from "egraph";
69
75
 
70
76
  await init();
71
77
 
72
78
  const graph = CsrGraph.fromEdgeList(4, new Uint32Array([0, 1, 1, 2, 2, 3, 3, 0]));
73
- const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
74
- const solver = new TFdpSolver(graph, { backend: "ibFft", iterations: 200, seed: 42 });
79
+ const layout = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
80
+ const solver = new TFdpSolver(graph, {
81
+ backend: FieldRepulsionBackend.IbFft,
82
+ iterations: 200,
83
+ seed: 42,
84
+ });
75
85
  solver.run(layout);
76
86
 
77
87
  const xy = layout.coordsView();
@@ -80,70 +90,49 @@ console.log(Array.from(xy));
80
90
 
81
91
  ## Solver & Engine Examples
82
92
 
83
- ### Track A: `TsNetSolver.pure2Hop` & `fromGraphRowNormalized`
84
-
85
- ```js
86
- const solver = TsNetSolver.pure2Hop(graph, {
87
- backend: "auto2d", // "auto2d", "fitFft", "linearFft", "barnesHut", "exact"
88
- perplexityC: 0.9,
89
- seed: 42,
90
- });
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);
100
- ```
101
-
102
- ### Track B, Separated Embedding & Force Models
93
+ ### Published Neighborhood, Force & Embedding Models
103
94
 
104
95
  ```js
105
96
  import {
97
+ FieldRepulsionBackend,
106
98
  ForceAtlas2Solver,
107
- GuMapSolver,
108
- PacmapGraphSolver,
99
+ ForceBackend,
109
100
  SgdSolver,
110
101
  SnapTFdpSolver,
111
102
  TFdpSolver,
103
+ TsNetBackend,
104
+ TsNetSolver,
112
105
  } from "egraph";
113
106
 
114
- // t-FDP with ibFFT repulsion
107
+ // tsNET from Partial BFS k-NN (Kruiger et al., 2017; Meidiana, Hong, & Ma, 2025, arXiv:2509.19785)
108
+ const tsnet = TsNetSolver.fromGraphPartialBfs(graph, {
109
+ k: 4,
110
+ uniformPerplexity: 3.0,
111
+ backend: TsNetBackend.Auto2d,
112
+ seed: 42,
113
+ });
114
+ tsnet.run(layout);
115
+
116
+ // t-FDP with ibFFT repulsion (Zhong et al., 2023)
115
117
  const tfdp = new TFdpSolver(graph, {
116
- backend: "ibFft",
118
+ backend: FieldRepulsionBackend.IbFft,
117
119
  iterations: 200,
118
120
  seed: 42,
119
121
  });
120
122
  tfdp.run(layout);
121
123
 
122
- // ForceAtlas2 (Barnes-Hut)
124
+ // ForceAtlas2 with Barnes-Hut (Jacomy et al., 2014)
123
125
  const fa2 = new ForceAtlas2Solver(graph, {
124
- backend: "barnesHut",
126
+ backend: ForceBackend.BarnesHut,
125
127
  iterations: 200,
126
128
  theta: 0.5,
127
129
  seed: 42,
128
130
  });
129
131
  fa2.run(layout);
130
132
 
131
- // PaCMAP-Graph & SNAP-tFDP (standalone separated classes)
132
- new PacmapGraphSolver(graph, { phaseIterations: [20, 20, 40], seed: 42 }).run(layout);
133
+ // Full-stress SGD (Zheng et al., 2019) and SNAP-tFDP (Chen et al., 2026)
134
+ SgdSolver.full(graph, { iterations: 60, seed: 42 }).run(layout);
133
135
  new SnapTFdpSolver(graph, { iterations: 100, seed: 42 }).run(layout);
134
-
135
- // GuMap from regularized Chebyshev DoG landmarks
136
- const gumap = GuMapSolver.fromGraphDog(graph, {
137
- iterations: 200,
138
- minDist: 0.1,
139
- spread: 1.0,
140
- seed: 42,
141
- });
142
- gumap.run(layout);
143
-
144
- // Regularized DoG 3-tier Sparse Barrier SGD
145
- const barrierSgd = SgdSolver.sparseBarrierDog(graph, { seed: 42 });
146
- barrierSgd.run(layout);
147
136
  ```
148
137
 
149
138
  ### `Layout3d`, `EdgePolylines` (`FdebSolver`), `BigInt` Seeds & Non-Euclidean Manifolds
@@ -154,19 +143,23 @@ import {
154
143
  EdgePolylines,
155
144
  FdebSolver,
156
145
  ForceAtlas2Solver,
146
+ ForceBackend,
157
147
  Layout3d,
148
+ ManifoldKind,
158
149
  ManifoldLayout2d,
159
150
  SgdSolver,
151
+ TargetKind,
152
+ TsNetBackend,
160
153
  TsNetSolver,
161
154
  geodesicDistortion,
162
155
  runProgressive,
163
156
  } from "egraph";
164
157
 
165
- // 3D Layout3d with 64-bit BigInt seed, target: "layout3d", and ArenaOctree3d
158
+ // 3D Layout3d with 64-bit BigInt seed, target: TargetKind.Layout3d, and ArenaOctree3d
166
159
  const layout3d = Layout3d.init(graph.numNodes(), { seed: 42n });
167
160
  new ForceAtlas2Solver(graph, {
168
- target: "layout3d",
169
- backend: "barnesHut",
161
+ target: TargetKind.Layout3d,
162
+ backend: ForceBackend.BarnesHut,
170
163
  iterations: 100,
171
164
  seed: 42n,
172
165
  }).run(layout3d);
@@ -181,35 +174,38 @@ const fdeb = new FdebSolver(polylines, { cycles: 3, stepsPerCycle: 15 });
181
174
  fdeb.run(polylines);
182
175
  console.log("bundled points:", polylines.edgeOffsetsView().length, polylines.pointsView().length);
183
176
 
184
- // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: "manifold2d"
185
- const lorentz = ManifoldLayout2d.init("hyperbolicLorentz", graph.numNodes(), { seed: 42 });
177
+ // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: TargetKind.Manifold2d
178
+ const lorentz = ManifoldLayout2d.init(ManifoldKind.HyperbolicLorentz, graph.numNodes(), { seed: 42 });
186
179
  await runProgressive(
187
- SgdSolver.full(graph, { target: "manifold2d", iterations: 60, seed: 42 }),
180
+ SgdSolver.full(graph, { target: TargetKind.Manifold2d, iterations: 60, seed: 42 }),
188
181
  lorentz,
189
182
  );
190
183
  const poincare = lorentz.toPoincareLayout();
191
184
  console.log("geodesicDistortion:", geodesicDistortion(graph, poincare));
192
185
 
193
- // Torus spectral phase init & optimal boundary auto-pan
194
- const torus = ManifoldLayout2d.torusSpectralPhaseInit(graph, 42);
186
+ // Torus layout + optimal boundary auto-pan (Chen et al., 2021)
187
+ const torus = ManifoldLayout2d.init(ManifoldKind.Torus2d, graph.numNodes(), { seed: 42 });
188
+ SgdSolver.full(graph, { target: TargetKind.Manifold2d, iterations: 60, seed: 42 }).run(torus);
195
189
  const panned = torus.torusAutoPan(graph);
196
190
  console.log(panned.coordsView().length);
197
191
 
198
192
  // Structured error codes (.code: EgraphErrorCode) on invalid (target, backend) pairs
199
193
  try {
200
- TsNetSolver.pure2Hop(graph, { target: "layout3d", backend: "fitFft" });
194
+ TsNetSolver.fromGraphPartialBfs(graph, {
195
+ target: TargetKind.Layout3d,
196
+ backend: TsNetBackend.FitFft,
197
+ });
201
198
  } catch (err) {
202
199
  console.error("Error code:", err.code); // "UnsupportedOperation"
203
200
  }
204
201
  ```
205
202
 
206
- ### Clustering (`labelsView()`), Overlap Removal, `LayoutTransform` & Datasets
203
+ ### Clustering (`labelsView()`), Overlap Removal & Datasets
207
204
 
208
205
  ```js
209
206
  import {
210
207
  Layout2d,
211
208
  PrismOverlapRemoval,
212
- TwinDeclutterer,
213
209
  generateSbmGraph,
214
210
  leidenCommunities,
215
211
  listDatasets,
@@ -225,7 +221,7 @@ const leiden = leidenCommunities(sbmGraph, { seed: 42 });
225
221
  const labels = leiden.labelsView();
226
222
  console.log("datasets:", listDatasets().length, "communities:", leiden.numCommunities, labels.length, groundTruth.length);
227
223
 
228
- // Overlap removal (PRISM) + TwinDeclutterer LayoutTransform (.apply)
224
+ // Overlap removal (PRISM)
229
225
  const original = Layout2d.fromCoords(layout.coordsView());
230
226
  const radii = new Float32Array(graph.numNodes()).fill(0.25);
231
227
  const prism = PrismOverlapRemoval.fromRadii(radii, {
@@ -234,45 +230,40 @@ const prism = PrismOverlapRemoval.fromRadii(radii, {
234
230
  seed: 42,
235
231
  });
236
232
  prism.run(layout);
237
- new TwinDeclutterer({ iterations: 4 }).apply(layout);
238
233
 
239
234
  const distortion = prismDistortion(original, layout);
240
235
  console.log(prism.lastOverlapCount, distortion.sigmaDist, distortion.sigmaDisp);
241
236
  ```
242
237
 
243
- ### Linalg, `LayoutGenerator`s, Chebyshev & Shortest Paths
238
+ ### Linalg, `LayoutGenerator`s & Shortest Paths
244
239
 
245
240
  ```js
246
241
  import {
247
- ChebyshevDogKernel,
248
242
  ClassicalMds,
249
243
  DijkstraWorkspace,
244
+ LaplacianKind,
250
245
  PivotMds,
246
+ TargetKind,
251
247
  classicalMds,
252
248
  combinatorialLaplacian,
249
+ laplacian,
253
250
  pivotMds,
254
251
  } from "egraph";
255
252
 
256
253
  const ws = new DijkstraWorkspace(graph.numNodes());
257
254
  const dists = ws.dijkstraFrom(graph, 0);
258
255
  const mdsNd = classicalMds(graph, 3);
259
- const mds3d = new ClassicalMds({ target: "layout3d" }).generate(graph);
256
+ const mds3d = new ClassicalMds({ target: TargetKind.Layout3d }).generate(graph);
260
257
  const mds2d = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
261
258
  const mds2dFn = pivotMds(graph, { numPivots: 4, seed: 42 });
262
259
  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);
260
+ const normLap = laplacian(graph, LaplacianKind.SymmetricNormalized);
261
+ console.log(dists.length, mdsNd.dims, mds3d.len(), mds2d.numNodes, mds2dFn.numNodes, lap.nnz, normLap.nnz);
265
262
  ```
266
263
 
267
- ## Migration from v5 / Legacy Alpha
268
-
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:
264
+ ## Migration & Literature Attribution
270
265
 
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
266
+ See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for upgrading from v5, earlier v6 prereleases, and string-based modes to typed enums, and [docs/PAPER_MAPPING.md](https://github.com/likr/egraph-rs/blob/master/docs/PAPER_MAPPING.md) for the complete algorithm-to-literature mapping table.
276
267
 
277
268
  ## License
278
269
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egraph",
3
- "version": "6.0.0-beta.3",
3
+ "version": "6.0.0-beta.4",
4
4
  "collaborators": [
5
5
  "Yosuke Onoue <onoue@likr-lab.com>"
6
6
  ],
package/pkg/README.md CHANGED
@@ -13,19 +13,20 @@ npm install egraph
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
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`.
16
+ - **Target-Checked Cooperative Execution & TS Contracts**: TypeScript interfaces (`LayoutStorage`, `IterativeSolver`, `LayoutGenerator`, `LayoutTransform`), typed `#[wasm_bindgen]` enums (`TargetKind`, `WeightDtype`, `ManifoldKind`, `TsNetBackend`, `FieldRepulsionBackend`, `ForceBackend`, `MetricTarget`, `SolverStatus`, etc.), `step(layout)`, `runSteps(layout, k)`, `run(layout)`, and `runProgressive(solver, layout, onFrame, options?)`.
17
+ - **Strict `camelCase`, `BigInt` Seeds, `.code` Errors & `f32` CSR**: `number | bigint` 64-bit seeds, structured `Error` `.code` (`EgraphErrorCode`), and strict `WeightDtype.Float32` validation on `CsrGraph`.
18
+ - **Comprehensive Layout, 3D & Non-Euclidean Engines**: `SgdSolver` (`full`, `randomPair`, `ortmannSparseStress`, `omega`), `StressMajorizationSolver`, `KamadaKawaiSolver`, `MaxentStressSolver`, `TsNetSolver` (`fromKnn`, `fromProbabilities`, `fromGraphPartialBfs`), `TFdpSolver`, `IbUmapSolver`, `GuMapSolver`, `SnapTFdpSolver`, `LargeVisSolver`, `DrGraphSolver`, `GraphCneSolver`, `ForceAtlas2Solver`, `YifanHuSolver`, `LinLogSolver`, `FruchtermanReingoldSolver`, `GemSolver`, `GripSolver`, `Layout3d` + `ArenaOctree3d`, `DynamicKdTree`, `EdgePolylines` + `FdebSolver(polylines)`, `ManifoldLayout2d` (`ManifoldKind.HyperbolicLorentz`, `toPoincareLayout`, `metric()` (`ManifoldMetricRecord`), `torusAutoPan`, geodesic crossings), `LayoutGenerator`s (`ClassicalMds`, `PivotMds`, `Hde`, `RdMds`, `KorenSpectral`, `SfcLayout`), `LayoutTransform`s (`PfsPrimeOverlapRemoval`, `TwinDeclutterer` `.apply()`), `MetricReport` (`toRecord()`), `listDatasets` / synthetic generators, and `DijkstraWorkspace` (plus `egraph-rs` extensions; see [PAPER_MAPPING.md](https://github.com/likr/egraph-rs/blob/master/docs/PAPER_MAPPING.md)).
19
19
 
20
20
  ## Quick Start (Browser / Bundler ESM)
21
21
 
22
22
  ```js
23
23
  import init, {
24
24
  CsrGraph,
25
- Layout2d,
26
- TsNetSolver,
25
+ FieldRepulsionBackend,
26
+ MetricTarget,
27
+ PivotMds,
28
+ TFdpSolver,
27
29
  evaluateMetrics,
28
- pivotMdsInit,
29
30
  runProgressive,
30
31
  } from "egraph";
31
32
 
@@ -37,11 +38,12 @@ const indices = new Uint32Array([1, 3, 0, 2, 1, 3, 2, 0]);
37
38
  const graph = CsrGraph.fromCsr(indptr, indices);
38
39
 
39
40
  // Initialize with normalized PivotMDS (f32 Layout2d)
40
- const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
41
+ const layout = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
41
42
 
42
- // Run Track A Pure 1+2-Hop Adaptive tsNET progressively in requestAnimationFrame
43
- const solver = TsNetSolver.pure2Hop(graph, {
44
- backend: "auto2d",
43
+ // Run t-FDP (Zhong et al., 2023) progressively in requestAnimationFrame
44
+ const solver = new TFdpSolver(graph, {
45
+ backend: FieldRepulsionBackend.IbFft,
46
+ iterations: 200,
45
47
  seed: 42,
46
48
  });
47
49
 
@@ -56,7 +58,11 @@ await runProgressive(
56
58
  );
57
59
 
58
60
  // Selectively evaluate quality metrics -> MetricReport
59
- const report = evaluateMetrics(graph, layout, ["sns", "np2", "crossingNumber"]);
61
+ const report = evaluateMetrics(graph, layout, [
62
+ MetricTarget.ScaleNormalizedStress,
63
+ MetricTarget.NeighborhoodPreservation2Hop,
64
+ MetricTarget.CrossingNumber,
65
+ ]);
60
66
  console.log(report.toRecord());
61
67
  ```
62
68
 
@@ -65,13 +71,17 @@ console.log(report.toRecord());
65
71
  The same `"egraph"` import automatically resolves to the Node ESM loader via `"exports"`:
66
72
 
67
73
  ```js
68
- import init, { CsrGraph, TFdpSolver, pivotMdsInit } from "egraph";
74
+ import init, { CsrGraph, FieldRepulsionBackend, PivotMds, TFdpSolver } from "egraph";
69
75
 
70
76
  await init();
71
77
 
72
78
  const graph = CsrGraph.fromEdgeList(4, new Uint32Array([0, 1, 1, 2, 2, 3, 3, 0]));
73
- const layout = pivotMdsInit(graph, { numPivots: 4, seed: 42 });
74
- const solver = new TFdpSolver(graph, { backend: "ibFft", iterations: 200, seed: 42 });
79
+ const layout = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
80
+ const solver = new TFdpSolver(graph, {
81
+ backend: FieldRepulsionBackend.IbFft,
82
+ iterations: 200,
83
+ seed: 42,
84
+ });
75
85
  solver.run(layout);
76
86
 
77
87
  const xy = layout.coordsView();
@@ -80,70 +90,49 @@ console.log(Array.from(xy));
80
90
 
81
91
  ## Solver & Engine Examples
82
92
 
83
- ### Track A: `TsNetSolver.pure2Hop` & `fromGraphRowNormalized`
84
-
85
- ```js
86
- const solver = TsNetSolver.pure2Hop(graph, {
87
- backend: "auto2d", // "auto2d", "fitFft", "linearFft", "barnesHut", "exact"
88
- perplexityC: 0.9,
89
- seed: 42,
90
- });
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);
100
- ```
101
-
102
- ### Track B, Separated Embedding & Force Models
93
+ ### Published Neighborhood, Force & Embedding Models
103
94
 
104
95
  ```js
105
96
  import {
97
+ FieldRepulsionBackend,
106
98
  ForceAtlas2Solver,
107
- GuMapSolver,
108
- PacmapGraphSolver,
99
+ ForceBackend,
109
100
  SgdSolver,
110
101
  SnapTFdpSolver,
111
102
  TFdpSolver,
103
+ TsNetBackend,
104
+ TsNetSolver,
112
105
  } from "egraph";
113
106
 
114
- // t-FDP with ibFFT repulsion
107
+ // tsNET from Partial BFS k-NN (Kruiger et al., 2017; Meidiana, Hong, & Ma, 2025, arXiv:2509.19785)
108
+ const tsnet = TsNetSolver.fromGraphPartialBfs(graph, {
109
+ k: 4,
110
+ uniformPerplexity: 3.0,
111
+ backend: TsNetBackend.Auto2d,
112
+ seed: 42,
113
+ });
114
+ tsnet.run(layout);
115
+
116
+ // t-FDP with ibFFT repulsion (Zhong et al., 2023)
115
117
  const tfdp = new TFdpSolver(graph, {
116
- backend: "ibFft",
118
+ backend: FieldRepulsionBackend.IbFft,
117
119
  iterations: 200,
118
120
  seed: 42,
119
121
  });
120
122
  tfdp.run(layout);
121
123
 
122
- // ForceAtlas2 (Barnes-Hut)
124
+ // ForceAtlas2 with Barnes-Hut (Jacomy et al., 2014)
123
125
  const fa2 = new ForceAtlas2Solver(graph, {
124
- backend: "barnesHut",
126
+ backend: ForceBackend.BarnesHut,
125
127
  iterations: 200,
126
128
  theta: 0.5,
127
129
  seed: 42,
128
130
  });
129
131
  fa2.run(layout);
130
132
 
131
- // PaCMAP-Graph & SNAP-tFDP (standalone separated classes)
132
- new PacmapGraphSolver(graph, { phaseIterations: [20, 20, 40], seed: 42 }).run(layout);
133
+ // Full-stress SGD (Zheng et al., 2019) and SNAP-tFDP (Chen et al., 2026)
134
+ SgdSolver.full(graph, { iterations: 60, seed: 42 }).run(layout);
133
135
  new SnapTFdpSolver(graph, { iterations: 100, seed: 42 }).run(layout);
134
-
135
- // GuMap from regularized Chebyshev DoG landmarks
136
- const gumap = GuMapSolver.fromGraphDog(graph, {
137
- iterations: 200,
138
- minDist: 0.1,
139
- spread: 1.0,
140
- seed: 42,
141
- });
142
- gumap.run(layout);
143
-
144
- // Regularized DoG 3-tier Sparse Barrier SGD
145
- const barrierSgd = SgdSolver.sparseBarrierDog(graph, { seed: 42 });
146
- barrierSgd.run(layout);
147
136
  ```
148
137
 
149
138
  ### `Layout3d`, `EdgePolylines` (`FdebSolver`), `BigInt` Seeds & Non-Euclidean Manifolds
@@ -154,19 +143,23 @@ import {
154
143
  EdgePolylines,
155
144
  FdebSolver,
156
145
  ForceAtlas2Solver,
146
+ ForceBackend,
157
147
  Layout3d,
148
+ ManifoldKind,
158
149
  ManifoldLayout2d,
159
150
  SgdSolver,
151
+ TargetKind,
152
+ TsNetBackend,
160
153
  TsNetSolver,
161
154
  geodesicDistortion,
162
155
  runProgressive,
163
156
  } from "egraph";
164
157
 
165
- // 3D Layout3d with 64-bit BigInt seed, target: "layout3d", and ArenaOctree3d
158
+ // 3D Layout3d with 64-bit BigInt seed, target: TargetKind.Layout3d, and ArenaOctree3d
166
159
  const layout3d = Layout3d.init(graph.numNodes(), { seed: 42n });
167
160
  new ForceAtlas2Solver(graph, {
168
- target: "layout3d",
169
- backend: "barnesHut",
161
+ target: TargetKind.Layout3d,
162
+ backend: ForceBackend.BarnesHut,
170
163
  iterations: 100,
171
164
  seed: 42n,
172
165
  }).run(layout3d);
@@ -181,35 +174,38 @@ const fdeb = new FdebSolver(polylines, { cycles: 3, stepsPerCycle: 15 });
181
174
  fdeb.run(polylines);
182
175
  console.log("bundled points:", polylines.edgeOffsetsView().length, polylines.pointsView().length);
183
176
 
184
- // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: "manifold2d"
185
- const lorentz = ManifoldLayout2d.init("hyperbolicLorentz", graph.numNodes(), { seed: 42 });
177
+ // Hyperbolic Lorentz hyperboloid -> Poincaré disk + explicit target: TargetKind.Manifold2d
178
+ const lorentz = ManifoldLayout2d.init(ManifoldKind.HyperbolicLorentz, graph.numNodes(), { seed: 42 });
186
179
  await runProgressive(
187
- SgdSolver.full(graph, { target: "manifold2d", iterations: 60, seed: 42 }),
180
+ SgdSolver.full(graph, { target: TargetKind.Manifold2d, iterations: 60, seed: 42 }),
188
181
  lorentz,
189
182
  );
190
183
  const poincare = lorentz.toPoincareLayout();
191
184
  console.log("geodesicDistortion:", geodesicDistortion(graph, poincare));
192
185
 
193
- // Torus spectral phase init & optimal boundary auto-pan
194
- const torus = ManifoldLayout2d.torusSpectralPhaseInit(graph, 42);
186
+ // Torus layout + optimal boundary auto-pan (Chen et al., 2021)
187
+ const torus = ManifoldLayout2d.init(ManifoldKind.Torus2d, graph.numNodes(), { seed: 42 });
188
+ SgdSolver.full(graph, { target: TargetKind.Manifold2d, iterations: 60, seed: 42 }).run(torus);
195
189
  const panned = torus.torusAutoPan(graph);
196
190
  console.log(panned.coordsView().length);
197
191
 
198
192
  // Structured error codes (.code: EgraphErrorCode) on invalid (target, backend) pairs
199
193
  try {
200
- TsNetSolver.pure2Hop(graph, { target: "layout3d", backend: "fitFft" });
194
+ TsNetSolver.fromGraphPartialBfs(graph, {
195
+ target: TargetKind.Layout3d,
196
+ backend: TsNetBackend.FitFft,
197
+ });
201
198
  } catch (err) {
202
199
  console.error("Error code:", err.code); // "UnsupportedOperation"
203
200
  }
204
201
  ```
205
202
 
206
- ### Clustering (`labelsView()`), Overlap Removal, `LayoutTransform` & Datasets
203
+ ### Clustering (`labelsView()`), Overlap Removal & Datasets
207
204
 
208
205
  ```js
209
206
  import {
210
207
  Layout2d,
211
208
  PrismOverlapRemoval,
212
- TwinDeclutterer,
213
209
  generateSbmGraph,
214
210
  leidenCommunities,
215
211
  listDatasets,
@@ -225,7 +221,7 @@ const leiden = leidenCommunities(sbmGraph, { seed: 42 });
225
221
  const labels = leiden.labelsView();
226
222
  console.log("datasets:", listDatasets().length, "communities:", leiden.numCommunities, labels.length, groundTruth.length);
227
223
 
228
- // Overlap removal (PRISM) + TwinDeclutterer LayoutTransform (.apply)
224
+ // Overlap removal (PRISM)
229
225
  const original = Layout2d.fromCoords(layout.coordsView());
230
226
  const radii = new Float32Array(graph.numNodes()).fill(0.25);
231
227
  const prism = PrismOverlapRemoval.fromRadii(radii, {
@@ -234,45 +230,40 @@ const prism = PrismOverlapRemoval.fromRadii(radii, {
234
230
  seed: 42,
235
231
  });
236
232
  prism.run(layout);
237
- new TwinDeclutterer({ iterations: 4 }).apply(layout);
238
233
 
239
234
  const distortion = prismDistortion(original, layout);
240
235
  console.log(prism.lastOverlapCount, distortion.sigmaDist, distortion.sigmaDisp);
241
236
  ```
242
237
 
243
- ### Linalg, `LayoutGenerator`s, Chebyshev & Shortest Paths
238
+ ### Linalg, `LayoutGenerator`s & Shortest Paths
244
239
 
245
240
  ```js
246
241
  import {
247
- ChebyshevDogKernel,
248
242
  ClassicalMds,
249
243
  DijkstraWorkspace,
244
+ LaplacianKind,
250
245
  PivotMds,
246
+ TargetKind,
251
247
  classicalMds,
252
248
  combinatorialLaplacian,
249
+ laplacian,
253
250
  pivotMds,
254
251
  } from "egraph";
255
252
 
256
253
  const ws = new DijkstraWorkspace(graph.numNodes());
257
254
  const dists = ws.dijkstraFrom(graph, 0);
258
255
  const mdsNd = classicalMds(graph, 3);
259
- const mds3d = new ClassicalMds({ target: "layout3d" }).generate(graph);
256
+ const mds3d = new ClassicalMds({ target: TargetKind.Layout3d }).generate(graph);
260
257
  const mds2d = new PivotMds({ numPivots: 4, seed: 42 }).generate(graph);
261
258
  const mds2dFn = pivotMds(graph, { numPivots: 4, seed: 42 });
262
259
  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);
260
+ const normLap = laplacian(graph, LaplacianKind.SymmetricNormalized);
261
+ console.log(dists.length, mdsNd.dims, mds3d.len(), mds2d.numNodes, mds2dFn.numNodes, lap.nnz, normLap.nnz);
265
262
  ```
266
263
 
267
- ## Migration from v5 / Legacy Alpha
268
-
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:
264
+ ## Migration & Literature Attribution
270
265
 
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
266
+ See [docs/MIGRATION_V6.md](https://github.com/likr/egraph-rs/blob/master/docs/MIGRATION_V6.md) for upgrading from v5, earlier v6 prereleases, and string-based modes to typed enums, and [docs/PAPER_MAPPING.md](https://github.com/likr/egraph-rs/blob/master/docs/PAPER_MAPPING.md) for the complete algorithm-to-literature mapping table.
276
267
 
277
268
  ## License
278
269