@graphty/webgpu-graph-algorithms 0.4.1 → 0.5.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/dist/src/accelerator.d.ts +5 -4
- package/dist/src/accelerator.d.ts.map +1 -1
- package/dist/src/accelerator.js +5 -4
- package/dist/src/accelerator.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/accelerator.d.ts +7 -154
- package/dist/src/types/accelerator.d.ts.map +1 -1
- package/dist/src/types/accelerator.js +4 -5
- package/dist/src/types/accelerator.js.map +1 -1
- package/dist/src/types/algorithms.d.ts +1 -1
- package/dist/src/types/algorithms.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webgpu-graph-algorithms.js.map +1 -1
- package/package.json +3 -2
- package/src/accelerator.ts +5 -4
- package/src/index.ts +4 -3
- package/src/types/accelerator.ts +43 -171
- package/src/types/algorithms.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphty/webgpu-graph-algorithms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|
|
@@ -90,7 +90,8 @@
|
|
|
90
90
|
"vite": "^7.0.5",
|
|
91
91
|
"vitest": "^3.2.4",
|
|
92
92
|
"webgpu": "0.4.0",
|
|
93
|
-
"@graphty/layout": "^1.7.0"
|
|
93
|
+
"@graphty/layout": "^1.7.0",
|
|
94
|
+
"@graphty/algorithms": "^1.8.0"
|
|
94
95
|
},
|
|
95
96
|
"scripts": {
|
|
96
97
|
"build": "tsc -p tsconfig.build.json",
|
package/src/accelerator.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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 (spec 9.2, 9.3
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `forceAtlas2`, `release` and `dispose`
|
|
3
|
+
* AlgorithmAccelerator and LayoutAccelerator interfaces (spec 9.2, 9.3). Both are the REAL declarations,
|
|
4
|
+
* `LayoutAccelerator` from `@graphty/layout` (W1b, layout half) and `AlgorithmAccelerator` from
|
|
5
|
+
* `@graphty/algorithms` (W1b, algorithms half), `import type`d by src/types/accelerator.ts, so the object built
|
|
6
|
+
* here is checked against the CPU packages' own contracts. It carries P3's `forceAtlas2`, `release` and `dispose`
|
|
7
|
+
* and P7's seven
|
|
7
8
|
* algorithm members (spec 8.2, 8.3; M8b-T8, PD-14) and nothing else: the CPU-side dispatchers (`accelerated()`,
|
|
8
9
|
* `createSimulation()`) test `acc.betweennessCentrality !== undefined` and route to the CPU when the member is
|
|
9
10
|
* 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,19 +50,20 @@ 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
|
|
54
|
-
// @graphty/algorithms
|
|
53
|
+
// ==================== types: the accelerator surface and the re-exported declarations of @graphty/layout (spec 9.3)
|
|
54
|
+
// and @graphty/algorithms (spec 9.2), both `import type` since W1b (D27)
|
|
55
55
|
export type {
|
|
56
56
|
AcceleratorOptions,
|
|
57
57
|
AlgorithmAccelerator,
|
|
58
58
|
ApspResultLike,
|
|
59
59
|
BellmanFordResultLike,
|
|
60
|
+
BetweennessAcceleratorOptions,
|
|
60
61
|
BfsResultLike,
|
|
61
62
|
CommunityResultLike,
|
|
62
63
|
CorenessResultLike,
|
|
63
|
-
CpuAlgorithmOptions,
|
|
64
64
|
EdgeScoresResultLike,
|
|
65
65
|
GpuAccelerator,
|
|
66
|
+
HitsOptionsLike,
|
|
66
67
|
HitsResultLike,
|
|
67
68
|
LabelResultLike,
|
|
68
69
|
LayoutAccelerator,
|
package/src/types/accelerator.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The layout half of spec 9.3 and the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* test/types/conformance.test-d.ts is the cross-compile that holds the layout half honest. Types only.
|
|
2
|
+
* The layout half of spec 9.3 and the algorithms half of spec 9.2, plus the package's own accelerator surface
|
|
3
|
+
* (spec 3.3). D27's mirrors are gone: both halves are now `import type` of the real packages, re-exported here so
|
|
4
|
+
* this package's public surface is unchanged; `test/types/conformance.test-d.ts` is the cross-compile that holds
|
|
5
|
+
* them honest. Types only.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
AlgorithmAccelerator,
|
|
10
|
+
ApspResultLike,
|
|
11
|
+
BellmanFordResultLike,
|
|
12
|
+
BetweennessAcceleratorOptions,
|
|
13
|
+
BfsResultLike,
|
|
14
|
+
CommunityResultLike,
|
|
15
|
+
CorenessResultLike,
|
|
16
|
+
EdgeScoresResultLike,
|
|
17
|
+
HitsOptionsLike,
|
|
18
|
+
HitsResultLike,
|
|
19
|
+
LabelResultLike,
|
|
20
|
+
MstResultLike,
|
|
21
|
+
PageRankResultLike,
|
|
22
|
+
ScoresResultLike,
|
|
23
|
+
SsspResultLike,
|
|
24
|
+
} from "@graphty/algorithms";
|
|
25
|
+
import type { F32, F64, GraphSnapshot } from "@graphty/graph-format";
|
|
10
26
|
import type { LayoutAccelerator, LayoutSimulation } from "@graphty/layout";
|
|
11
27
|
|
|
12
28
|
import type { GpuContext } from "../context.js";
|
|
@@ -30,171 +46,27 @@ import type { ForceAtlas2Options } from "./options.js";
|
|
|
30
46
|
|
|
31
47
|
export type { LayoutAccelerator, LayoutSimulation };
|
|
32
48
|
|
|
33
|
-
// ----
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* PageRank result mirror.
|
|
57
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
export interface PageRankResultLike extends ScoresResultLike {
|
|
61
|
-
readonly danglingMass?: number | undefined;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* HITS result mirror.
|
|
66
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
67
|
-
* @public
|
|
68
|
-
*/
|
|
69
|
-
export interface HitsResultLike {
|
|
70
|
-
readonly hubs: NumericVector;
|
|
71
|
-
readonly authorities: NumericVector;
|
|
72
|
-
readonly iterations: number;
|
|
73
|
-
readonly converged: boolean;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Label result mirror (components, label propagation).
|
|
78
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
79
|
-
* @public
|
|
80
|
-
*/
|
|
81
|
-
export interface LabelResultLike {
|
|
82
|
-
readonly labels: U32;
|
|
83
|
-
readonly count: number;
|
|
84
|
-
groups(): U32[];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* BFS result mirror.
|
|
89
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
export interface BfsResultLike {
|
|
93
|
-
readonly depth: U32;
|
|
94
|
-
readonly parent: U32;
|
|
95
|
-
readonly order: U32;
|
|
96
|
-
readonly visitedCount: number;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* SSSP result mirror.
|
|
101
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
export interface SsspResultLike {
|
|
105
|
-
readonly dist: NumericVector;
|
|
106
|
-
readonly predArc: U32;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Bellman-Ford result mirror.
|
|
111
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
112
|
-
* @public
|
|
113
|
-
*/
|
|
114
|
-
export interface BellmanFordResultLike extends SsspResultLike {
|
|
115
|
-
readonly hasNegativeCycle: boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Edge-score result mirror.
|
|
120
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
121
|
-
* @public
|
|
122
|
-
*/
|
|
123
|
-
export interface EdgeScoresResultLike {
|
|
124
|
-
readonly scores: NumericVector;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* APSP result mirror.
|
|
129
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
130
|
-
* @public
|
|
131
|
-
*/
|
|
132
|
-
export interface ApspResultLike {
|
|
133
|
-
readonly dist: NumericVector;
|
|
134
|
-
readonly n: number;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* k-core result mirror.
|
|
139
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
140
|
-
* @public
|
|
141
|
-
*/
|
|
142
|
-
export interface CorenessResultLike {
|
|
143
|
-
readonly coreness: U32;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Minimum-spanning-tree result mirror.
|
|
148
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
149
|
-
* @public
|
|
150
|
-
*/
|
|
151
|
-
export interface MstResultLike {
|
|
152
|
-
readonly edges: U32;
|
|
153
|
-
readonly totalWeight: number;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Community result mirror (Louvain).
|
|
158
|
-
* Exported: published mirror; re-exported from src/index.ts at P3-T3.
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
export interface CommunityResultLike extends LabelResultLike {
|
|
162
|
-
readonly modularity: number;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Spec 9.2 AlgorithmAccelerator, verbatim (every member optional; option types are CpuAlgorithmOptions until A2).
|
|
167
|
-
* Exported: published mirror (spec 9.2, D27); re-exported from src/index.ts at P3-T3.
|
|
168
|
-
* @public
|
|
169
|
-
*/
|
|
170
|
-
export interface AlgorithmAccelerator {
|
|
171
|
-
readonly kind: string;
|
|
172
|
-
pageRank?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<PageRankResultLike>;
|
|
173
|
-
personalizedPageRank?(
|
|
174
|
-
s: GraphSnapshot,
|
|
175
|
-
personalization: F32 | F64,
|
|
176
|
-
options?: CpuAlgorithmOptions,
|
|
177
|
-
): Promise<PageRankResultLike>;
|
|
178
|
-
hits?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<HitsResultLike>;
|
|
179
|
-
eigenvectorCentrality?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<ScoresResultLike>;
|
|
180
|
-
katzCentrality?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<ScoresResultLike>;
|
|
181
|
-
connectedComponents?(s: GraphSnapshot): Promise<LabelResultLike>;
|
|
182
|
-
weaklyConnectedComponents?(s: GraphSnapshot): Promise<LabelResultLike>;
|
|
183
|
-
breadthFirstSearch?(s: GraphSnapshot, source: number, options?: CpuAlgorithmOptions): Promise<BfsResultLike>;
|
|
184
|
-
sssp?(s: GraphSnapshot, source: number, options?: CpuAlgorithmOptions): Promise<SsspResultLike>;
|
|
185
|
-
bellmanFord?(s: GraphSnapshot, source: number, options?: CpuAlgorithmOptions): Promise<BellmanFordResultLike>;
|
|
186
|
-
closenessCentrality?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<ScoresResultLike>;
|
|
187
|
-
betweennessCentrality?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<ScoresResultLike>;
|
|
188
|
-
edgeBetweennessCentrality?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<EdgeScoresResultLike>;
|
|
189
|
-
allPairsShortestPath?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<ApspResultLike>;
|
|
190
|
-
kCoreDecomposition?(s: GraphSnapshot): Promise<CorenessResultLike>;
|
|
191
|
-
triangleCount?(s: GraphSnapshot): Promise<{ readonly perNode: U32; readonly total: number }>;
|
|
192
|
-
labelPropagation?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<LabelResultLike>;
|
|
193
|
-
minimumSpanningTree?(s: GraphSnapshot): Promise<MstResultLike>;
|
|
194
|
-
louvain?(s: GraphSnapshot, options?: CpuAlgorithmOptions): Promise<CommunityResultLike>;
|
|
195
|
-
release?(s: GraphSnapshot): void;
|
|
196
|
-
dispose?(): void;
|
|
197
|
-
}
|
|
49
|
+
// ---- the real @graphty/algorithms interfaces (spec 9.2, D27): imported at W1b now that A2's first
|
|
50
|
+
// commit exists, re-exported so this package's public surface is unchanged. `export type`, never a
|
|
51
|
+
// bare `export { ... }`: isolatedModules makes the bare form TS1205.
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
AlgorithmAccelerator,
|
|
55
|
+
ApspResultLike,
|
|
56
|
+
BellmanFordResultLike,
|
|
57
|
+
BetweennessAcceleratorOptions,
|
|
58
|
+
BfsResultLike,
|
|
59
|
+
CommunityResultLike,
|
|
60
|
+
CorenessResultLike,
|
|
61
|
+
EdgeScoresResultLike,
|
|
62
|
+
HitsOptionsLike,
|
|
63
|
+
HitsResultLike,
|
|
64
|
+
LabelResultLike,
|
|
65
|
+
MstResultLike,
|
|
66
|
+
PageRankResultLike,
|
|
67
|
+
ScoresResultLike,
|
|
68
|
+
SsspResultLike,
|
|
69
|
+
};
|
|
198
70
|
|
|
199
71
|
// ---- the package's own accelerator surface (spec 3.3); grows one method per shipped algorithm from P7
|
|
200
72
|
|
package/src/types/algorithms.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* layout options until W1b, when those became `import type` re-exports of `@graphty/layout`'s declarations).
|
|
6
6
|
* Types only: this file imports nothing at runtime.
|
|
7
7
|
*
|
|
8
|
-
* The CPU counterparts,
|
|
8
|
+
* The CPU counterparts, in `@graphty/algorithms`' `indexed/accelerator.ts` since the seam landed:
|
|
9
9
|
* `PageRankOptions` here is `IndexedPageRankOptions` there (`{ dampingFactor?, maxIterations?, tolerance?,
|
|
10
10
|
* weighted? }`); `HitsOptions`, `EigenvectorOptions` and `KatzOptions` here all correspond to the ONE
|
|
11
11
|
* `HitsOptionsLike` there (`{ maxIterations?, tolerance?, weighted? }`), which is why every one of them carries
|