@graphty/webgpu-graph-algorithms 0.3.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphty/webgpu-graph-algorithms",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "WebGPU-accelerated graph algorithms and layouts over the @graphty/graph-format snapshot, for Node (Dawn) and browsers",
5
5
  "author": "Adam Powers <apowers@ato.ms>",
6
6
  "type": "module",
@@ -60,12 +60,12 @@
60
60
  "homepage": "https://github.com/graphty-org/graphty-monorepo/tree/master/webgpu-graph-algorithms#readme",
61
61
  "dependencies": {
62
62
  "@webgpu/types": "^0.1.72",
63
- "@graphty/graph-format": "^1.0.0"
63
+ "@graphty/graph-format": "^1.0.1"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@graphty/algorithms": "^1.0.0",
67
67
  "@graphty/graph-format": "^1.0.0",
68
- "@graphty/layout": "^1.0.0",
68
+ "@graphty/layout": "^1.6.2",
69
69
  "webgpu": ">=0.4.0 <1.0.0"
70
70
  },
71
71
  "peerDependenciesMeta": {
@@ -89,7 +89,8 @@
89
89
  "typescript": "^5.9.3",
90
90
  "vite": "^7.0.5",
91
91
  "vitest": "^3.2.4",
92
- "webgpu": "0.4.0"
92
+ "webgpu": "0.4.0",
93
+ "@graphty/layout": "^1.7.0"
93
94
  },
94
95
  "scripts": {
95
96
  "build": "tsc -p tsconfig.build.json",
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * createAccelerator (spec 3.3, 9; contract 3.14): the injectable object that satisfies the CPU packages'
3
- * AlgorithmAccelerator and LayoutAccelerator interfaces STRUCTURALLY (spec 9.2, 9.3; the mirrors of
4
- * src/types/accelerator.ts until W1, D27). It carries P3's `forceAtlas2`, `release` and `dispose` and P7's seven
3
+ * AlgorithmAccelerator and LayoutAccelerator interfaces (spec 9.2, 9.3; D27). Since W1b `LayoutAccelerator` is
4
+ * the REAL `@graphty/layout` declaration, `import type`d by src/types/accelerator.ts; the AlgorithmAccelerator half
5
+ * is still satisfied STRUCTURALLY against that file's mirror until M8a gives it something real. It carries P3's
6
+ * `forceAtlas2`, `release` and `dispose` and P7's seven
5
7
  * algorithm members (spec 8.2, 8.3; M8b-T8, PD-14) and nothing else: the CPU-side dispatchers (`accelerated()`,
6
8
  * `createSimulation()`) test `acc.betweennessCentrality !== undefined` and route to the CPU when the member is
7
9
  * absent (spec 2.4 row "method missing"), so a method the GPU does not implement must not exist here -- never a
package/src/index.ts CHANGED
@@ -50,7 +50,8 @@ export { createAccelerator } from "./accelerator.js";
50
50
  export { createForceAtlas2 } from "./layouts/forceatlas2.js";
51
51
  export { seedPositions } from "./layouts/seed.js";
52
52
 
53
- // ==================== types: the accelerator surface and the CPU-package mirrors (spec 9.2, 9.3; D27)
53
+ // ==================== types: the accelerator surface, layout's re-exported declarations (spec 9.3; W1b) and the
54
+ // @graphty/algorithms mirrors (spec 9.2; D27, until M8a)
54
55
  export type {
55
56
  AcceleratorOptions,
56
57
  AlgorithmAccelerator,
@@ -2,7 +2,9 @@
2
2
  * The CPU port's random number generator, bit for bit, and the NaN-row seeding both paths share (spec 7.2 "Initial
3
3
  * positions", 9.3 seedPositions, 7.14 `pos`, 7.19 topology change): a seed gives the same start on the CPU and the
4
4
  * GPU because both write the same f32 values in index order. The package carries its own copy of the LCG for its
5
- * whole life (D27: it cannot import @graphty/layout); W1 cross-tests it against the real RandomNumberGenerator.
5
+ * whole life (D27: it cannot import @graphty/layout at runtime). The CANONICAL copy is
6
+ * layout/src/simulation/seed.ts; this one is cross-tested against it, bit for bit, by
7
+ * test/layouts/seed-cross.test.ts (W1b, Task M5b-T3).
6
8
  */
7
9
 
8
10
  import type { F32, GraphSnapshot } from "@graphty/graph-format";
@@ -1,11 +1,13 @@
1
1
  /**
2
- * The structural mirrors of @graphty/layout's LayoutSimulation / LayoutAccelerator (spec 9.3) and of
3
- * the @graphty/algorithms AlgorithmAccelerator (spec 9.2), plus the package's own accelerator surface (spec 3.3).
4
- * Until W1 these ARE the mirrors (D27): from W1 the mirrors become `import type` of the real packages and
5
- * test/types/conformance.test-d.ts asserts mutual assignability. Types only.
2
+ * The layout half of spec 9.3 and the @graphty/algorithms AlgorithmAccelerator mirror (spec 9.2), plus the
3
+ * package's own accelerator surface (spec 3.3). D27's two halves are now on different footings: at W1b the LAYOUT
4
+ * mirrors became `import type` of the real `@graphty/layout` interfaces, re-exported here so this package's public
5
+ * surface is unchanged; the ALGORITHMS mirrors stay structural until A2/M8a gives them something real to point at.
6
+ * test/types/conformance.test-d.ts is the cross-compile that holds the layout half honest. Types only.
6
7
  */
7
8
 
8
- import type { F32, F64, GraphSnapshot, NodeMask, NumericVector, U32 } from "@graphty/graph-format";
9
+ import type { F32, F64, GraphSnapshot, NumericVector, U32 } from "@graphty/graph-format";
10
+ import type { LayoutAccelerator, LayoutSimulation } from "@graphty/layout";
9
11
 
10
12
  import type { GpuContext } from "../context.js";
11
13
  import type {
@@ -20,33 +22,13 @@ import type {
20
22
  PageRankOptions,
21
23
  } from "./algorithms.js";
22
24
  import type { ForceAtlas2Stats, GpuLayoutSimulation, GpuLayoutTuning } from "./layout.js";
23
- import type { ForceAtlas2Options, FruchtermanReingoldOptions, SpringElectricalOptions } from "./options.js";
25
+ import type { ForceAtlas2Options } from "./options.js";
24
26
 
25
- // ---- mirrors of @graphty/layout (spec 9.3)
27
+ // ---- the real @graphty/layout interfaces (spec 9.3, D27): imported at W1b, re-exported so the package's public
28
+ // surface is unchanged and src/types/layout.ts keeps resolving them from here. `export type`, never a bare
29
+ // `export { ... }`: isolatedModules makes the bare form TS1205.
26
30
 
27
- /** Design 14.3 LayoutSimulation, verbatim. */
28
- export interface LayoutSimulation {
29
- load(snapshot: GraphSnapshot, positions: F32): void;
30
- step(iterations?: number): void | Promise<void>;
31
- readonly settled: boolean;
32
- setFixed(mask: NodeMask): void;
33
- setPosition(index: number, x: number, y: number, z: number): void;
34
- dispose(): void;
35
- }
36
-
37
- /**
38
- * Spec 9.3 LayoutAccelerator, verbatim.
39
- * Exported: published mirror (spec 3.3, D27); re-exported from src/index.ts at P3-T3.
40
- * @public
41
- */
42
- export interface LayoutAccelerator {
43
- readonly kind: string;
44
- forceAtlas2?(options?: ForceAtlas2Options): LayoutSimulation;
45
- fruchtermanReingold?(options?: FruchtermanReingoldOptions): LayoutSimulation;
46
- springElectrical?(options?: SpringElectricalOptions): LayoutSimulation;
47
- release?(s: GraphSnapshot): void;
48
- dispose?(): void;
49
- }
31
+ export type { LayoutAccelerator, LayoutSimulation };
50
32
 
51
33
  // ---- mirrors of @graphty/algorithms (spec 9.2); the option types named there do not exist before A2, so they are
52
34
  // mirrored as empty-extensible records
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * The result and option records of the P7 algorithms (spec 3.3 lines 815-828, 9.7). The `Gpu*Result` shapes are the
3
3
  * design's verbatim; the option records are this package's own, spelled MEMBER FOR MEMBER as the CPU seam spells
4
- * them so one object literal satisfies both sides (the same D27 mirror rule src/types/options.ts follows for the
5
- * layout options). Types only: this file imports nothing at runtime.
4
+ * them so one object literal satisfies both sides (the D27 mirror rule src/types/options.ts followed for the
5
+ * layout options until W1b, when those became `import type` re-exports of `@graphty/layout`'s declarations).
6
+ * Types only: this file imports nothing at runtime.
6
7
  *
7
8
  * The CPU counterparts, when phase M8a lands them (plan 2026-09-19-webgpu-m8a-algorithms-seam, Task M8a-T8):
8
9
  * `PageRankOptions` here is `IndexedPageRankOptions` there (`{ dampingFactor?, maxIterations?, tolerance?,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The layout-facing public types (spec 3.3, 7.19): the stats records, the GPU simulation interface that extends the
3
- * design-14.3 LayoutSimulation mirror, the run options and the GPU-only tuning knobs. Types only.
3
+ * real `@graphty/layout` LayoutSimulation (design 14.3), the run options and the GPU-only tuning knobs. Types only.
4
4
  */
5
5
 
6
6
  import type { F32, GraphSnapshot, NodeMask } from "@graphty/graph-format";
@@ -50,7 +50,7 @@ export interface RunOptions {
50
50
  readonly signal?: AbortSignal | undefined;
51
51
  }
52
52
 
53
- /** Spec 3.3 GpuLayoutSimulation, verbatim (LayoutSimulation is the design-14.3 mirror of accelerator.ts). */
53
+ /** Spec 3.3 GpuLayoutSimulation, verbatim (LayoutSimulation is `@graphty/layout`'s, via accelerator.ts). */
54
54
  export interface GpuLayoutSimulation<Options, Stats extends LayoutStatsBase> extends LayoutSimulation {
55
55
  load(snapshot: GraphSnapshot, positions: F32): void;
56
56
  /**
@@ -1,60 +1,29 @@
1
1
  /**
2
- * The option records of the layouts (spec 9.3, 7.14): structural mirrors of @graphty/layout's option types (D27),
3
- * copied field for field so a `ForceAtlas2Options` object the element parses is accepted here without a cast. Types
4
- * only: this file imports nothing at runtime.
2
+ * The option records of the layouts (spec 9.3, 7.14). The five layout-owned records come from `@graphty/layout` by
3
+ * `import type` and are re-exported here, so a `ForceAtlas2Options` object the element parses is not merely
4
+ * shaped like the one this package takes -- it IS the same declaration (W1b; the D27 mirrors are gone).
5
+ * `ResolvedForceAtlas2Options` below is this package's own and stays local. Types only: nothing here is a runtime
6
+ * import.
5
7
  */
6
8
 
7
- import type { F32, NodeId, NodeMask } from "@graphty/graph-format";
9
+ import type { F32, NodeId } from "@graphty/graph-format";
10
+ import type {
11
+ CommonLayoutOptions,
12
+ ForceAtlas2Options,
13
+ FruchtermanReingoldOptions,
14
+ SimulationOptions,
15
+ SpringElectricalOptions,
16
+ } from "@graphty/layout";
8
17
 
9
- /** Design 14.3 CommonLayoutOptions, mirrored verbatim. */
10
- export interface CommonLayoutOptions {
11
- readonly dim?: 2 | 3 | undefined;
12
- readonly scale?: number | undefined;
13
- readonly center?: ArrayLike<number> | undefined;
14
- readonly seed?: number | null | undefined;
15
- }
16
-
17
- /** Spec 9.3 SimulationOptions, mirrored verbatim (layout-owned; the CPU simulations ignore maxInFlight). */
18
- export interface SimulationOptions {
19
- readonly settleThreshold?: number | undefined;
20
- readonly settleWindow?: number | undefined;
21
- readonly iterationsPerStep?: number | undefined;
22
- readonly maxInFlight?: number | undefined;
23
- }
24
-
25
- /**
26
- * Spec 9.3 ForceAtlas2Options, mirrored verbatim (same names and defaults as
27
- * layout/src/layouts/force-directed/forceatlas2.ts lines 26-42).
28
- */
29
- export interface ForceAtlas2Options extends CommonLayoutOptions, SimulationOptions {
30
- readonly maxIter?: number | undefined;
31
- readonly jitterTolerance?: number | undefined;
32
- readonly scalingRatio?: number | undefined;
33
- readonly gravity?: number | undefined;
34
- readonly strongGravity?: boolean | undefined;
35
- readonly distributedAction?: boolean | undefined;
36
- readonly linlog?: boolean | undefined;
37
- readonly nodeMass?: F32 | string | Readonly<Record<NodeId, number>> | null | undefined;
38
- readonly nodeSize?: F32 | string | Readonly<Record<NodeId, number>> | null | undefined;
39
- readonly weight?: boolean | string | null | undefined;
40
- readonly dissuadeHubs?: boolean | undefined;
41
- }
42
-
43
- /** Spec 9.3 FruchtermanReingoldOptions, mirrored for the LayoutAccelerator mirror's method signature (P5 implements it). */
44
- export interface FruchtermanReingoldOptions extends CommonLayoutOptions, SimulationOptions {
45
- readonly k?: number | null | undefined;
46
- readonly iterations?: number | undefined;
47
- readonly fixed?: NodeMask | string | null | undefined;
48
- }
49
-
50
- /** Spec 9.3 SpringElectricalOptions, mirrored for the LayoutAccelerator mirror's method signature (P5 implements it). */
51
- export interface SpringElectricalOptions extends CommonLayoutOptions, SimulationOptions {
52
- readonly springLength?: number | undefined;
53
- readonly springCoefficient?: number | undefined;
54
- readonly gravity?: number | undefined;
55
- readonly dragCoefficient?: number | undefined;
56
- readonly timeStep?: number | undefined;
57
- }
18
+ // The five layout-owned option records are @graphty/layout's declarations, re-exported so src/index.ts's barrel
19
+ // and the option type tests keep resolving them from here (W1b, Task M5b-T2).
20
+ export type {
21
+ CommonLayoutOptions,
22
+ ForceAtlas2Options,
23
+ FruchtermanReingoldOptions,
24
+ SimulationOptions,
25
+ SpringElectricalOptions,
26
+ };
58
27
 
59
28
  /**
60
29
  * The resolved (defaults applied) ForceAtlas2 option record the simulation keeps; every field present.