@graphty/webgpu-graph-algorithms 0.6.26 → 0.6.28
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 +56 -6
- package/dist/acquire.d.ts +2 -0
- package/dist/browser.js +18 -1
- package/dist/browser.js.map +1 -1
- package/dist/chunks/accelerator-B-FjQwaA.js +19173 -0
- package/dist/chunks/accelerator-B-FjQwaA.js.map +1 -0
- package/dist/chunks/managed-D_GdQtnu.js +98 -0
- package/dist/chunks/managed-D_GdQtnu.js.map +1 -0
- package/dist/node.js +18 -1
- package/dist/node.js.map +1 -1
- package/dist/src/accelerator.d.ts.map +1 -1
- package/dist/src/accelerator.js +5 -3
- package/dist/src/accelerator.js.map +1 -1
- package/dist/src/algorithms/all-pairs.d.ts.map +1 -1
- package/dist/src/algorithms/all-pairs.js +72 -47
- package/dist/src/algorithms/all-pairs.js.map +1 -1
- package/dist/src/algorithms/betweenness.d.ts +1 -1
- package/dist/src/algorithms/betweenness.js +2 -2
- package/dist/src/algorithms/closeness.d.ts +45 -42
- package/dist/src/algorithms/closeness.d.ts.map +1 -1
- package/dist/src/algorithms/closeness.js +295 -226
- package/dist/src/algorithms/closeness.js.map +1 -1
- package/dist/src/browser/index.d.ts +10 -0
- package/dist/src/browser/index.d.ts.map +1 -1
- package/dist/src/browser/index.js +22 -0
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/constants.d.ts +13 -3
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +13 -3
- package/dist/src/constants.js.map +1 -1
- package/dist/src/kernels.d.ts +14 -4
- package/dist/src/kernels.d.ts.map +1 -1
- package/dist/src/kernels.js +62 -28
- package/dist/src/kernels.js.map +1 -1
- package/dist/src/layouts/force-simulation.d.ts.map +1 -1
- package/dist/src/layouts/force-simulation.js +0 -1
- package/dist/src/layouts/force-simulation.js.map +1 -1
- package/dist/src/layouts/forceatlas2.d.ts.map +1 -1
- package/dist/src/layouts/forceatlas2.js +0 -1
- package/dist/src/layouts/forceatlas2.js.map +1 -1
- package/dist/src/layouts/fruchterman-reingold.d.ts.map +1 -1
- package/dist/src/layouts/fruchterman-reingold.js +0 -1
- package/dist/src/layouts/fruchterman-reingold.js.map +1 -1
- package/dist/src/layouts/repulsion-grid.d.ts +1 -3
- package/dist/src/layouts/repulsion-grid.d.ts.map +1 -1
- package/dist/src/layouts/repulsion-grid.js +1 -6
- package/dist/src/layouts/repulsion-grid.js.map +1 -1
- package/dist/src/layouts/spring-electrical.d.ts.map +1 -1
- package/dist/src/layouts/spring-electrical.js +0 -1
- package/dist/src/layouts/spring-electrical.js.map +1 -1
- package/dist/src/managed.d.ts +11 -0
- package/dist/src/managed.d.ts.map +1 -0
- package/dist/src/managed.js +129 -0
- package/dist/src/managed.js.map +1 -0
- package/dist/src/node/index.d.ts +11 -0
- package/dist/src/node/index.d.ts.map +1 -1
- package/dist/src/node/index.js +21 -0
- package/dist/src/node/index.js.map +1 -1
- package/dist/src/primitives/grid-pyramid.d.ts +16 -15
- package/dist/src/primitives/grid-pyramid.d.ts.map +1 -1
- package/dist/src/primitives/grid-pyramid.js +20 -28
- package/dist/src/primitives/grid-pyramid.js.map +1 -1
- package/dist/src/types/accelerator.d.ts +2 -0
- package/dist/src/types/accelerator.d.ts.map +1 -1
- package/dist/src/types/managed.d.ts +81 -0
- package/dist/src/types/managed.d.ts.map +1 -0
- package/dist/src/types/managed.js +7 -0
- package/dist/src/types/managed.js.map +1 -0
- package/dist/src/wgsl/bc-forward.wgsl.d.ts +1 -1
- package/dist/src/wgsl/bc-forward.wgsl.js +1 -1
- package/dist/src/wgsl/closeness-level.wgsl.d.ts +37 -0
- package/dist/src/wgsl/closeness-level.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/closeness-level.wgsl.js +204 -0
- package/dist/src/wgsl/closeness-level.wgsl.js.map +1 -0
- package/dist/src/wgsl/closeness-rowsum.wgsl.d.ts +11 -0
- package/dist/src/wgsl/closeness-rowsum.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/closeness-rowsum.wgsl.js +42 -0
- package/dist/src/wgsl/closeness-rowsum.wgsl.js.map +1 -0
- package/dist/src/wgsl/grid-centroid-hub.wgsl.d.ts +2 -2
- package/dist/src/wgsl/grid-centroid-hub.wgsl.js +2 -2
- package/dist/webgpu-graph-algorithms.js +142 -15586
- package/dist/webgpu-graph-algorithms.js.map +1 -1
- package/package.json +10 -4
- package/src/accelerator.ts +5 -3
- package/src/algorithms/all-pairs.ts +86 -56
- package/src/algorithms/betweenness.ts +2 -2
- package/src/algorithms/closeness.ts +353 -256
- package/src/browser/index.ts +37 -0
- package/src/constants.ts +13 -3
- package/src/kernels.ts +65 -36
- package/src/layouts/force-simulation.ts +0 -1
- package/src/layouts/forceatlas2.ts +0 -1
- package/src/layouts/fruchterman-reingold.ts +0 -1
- package/src/layouts/repulsion-grid.ts +2 -7
- package/src/layouts/spring-electrical.ts +0 -1
- package/src/managed.ts +172 -0
- package/src/node/index.ts +36 -0
- package/src/primitives/grid-pyramid.ts +29 -41
- package/src/types/accelerator.ts +2 -0
- package/src/types/managed.ts +86 -0
- package/src/wgsl/bc-forward.wgsl.ts +1 -1
- package/src/wgsl/closeness-level.wgsl.ts +203 -0
- package/src/wgsl/closeness-rowsum.wgsl.ts +41 -0
- package/src/wgsl/grid-centroid-hub.wgsl.ts +2 -2
- package/dist/chunks/context-BZY6SMsM.js +0 -3615
- package/dist/chunks/context-BZY6SMsM.js.map +0 -1
- package/dist/src/wgsl/closeness-reduce.wgsl.d.ts +0 -20
- package/dist/src/wgsl/closeness-reduce.wgsl.d.ts.map +0 -1
- package/dist/src/wgsl/closeness-reduce.wgsl.js +0 -69
- package/dist/src/wgsl/closeness-reduce.wgsl.js.map +0 -1
- package/dist/src/wgsl/closeness-sweep.wgsl.d.ts +0 -22
- package/dist/src/wgsl/closeness-sweep.wgsl.d.ts.map +0 -1
- package/dist/src/wgsl/closeness-sweep.wgsl.js +0 -106
- package/dist/src/wgsl/closeness-sweep.wgsl.js.map +0 -1
- package/src/wgsl/closeness-reduce.wgsl.ts +0 -68
- package/src/wgsl/closeness-sweep.wgsl.ts +0 -105
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Closeness centrality on the device (design 8.4, 3.3 line 810, 9.7
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Wasserman-Faust scaling: this is EXACTLY the legacy default (`normalized:
|
|
6
|
-
* `@graphty/algorithms`, the number graphty-element's closeness panel shows
|
|
7
|
-
* number to match (the NetworkX form is 33x it on karate and could never have been substituted silently).
|
|
2
|
+
* Closeness centrality on the device (design 8.4, 3.3 line 810, 9.7): `score[s] = 1 / sumDist_s`, with `sumDist_s`
|
|
3
|
+
* the exact sum of the finite distances from `s` to every OTHER node -- an unreached node adds nothing -- and `0` when
|
|
4
|
+
* nothing is reached; or, with `harmonic`, `score[s] = sum of 1 / dist` over the same nodes (a zero distance adds
|
|
5
|
+
* nothing). No reached factor and no Wasserman-Faust scaling: this is EXACTLY the legacy default (`normalized:
|
|
6
|
+
* false`) of `closenessCentrality` in `@graphty/algorithms`, the number graphty-element's closeness panel shows.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
8
|
+
* Three routes, chosen from the inputs before any device work:
|
|
9
|
+
*
|
|
10
|
+
* - ALL-PAIRS (an exact run whose `n x n` f32 matrix fits one binding, weighted, or unweighted up to
|
|
11
|
+
* `ALL_PAIRS_MAX_NODES`): `allPairsShortestPath`'s blocked Floyd-Warshall sweep, then `closeness-rowsum` folds each row on
|
|
12
|
+
* the device -- hop counts as exact integers, weighted distances and harmonic reciprocals in f32 -- and only `n`
|
|
13
|
+
* words come back. Weighted scores agree with the one-search-per-source route up to f32 rounding of the sums.
|
|
14
|
+
* - LEVELS (unweighted, every other case): a bit-parallel multi-source breadth-first search, `32 x words` sources per
|
|
15
|
+
* batch (up to `MAX_WORDS` = 8 words, 256 sources), ONE `closeness-level` dispatch per level. Each level chooses on
|
|
16
|
+
* the device between pushing the frontier over the out-arcs (one invocation per arc) and pulling it over the
|
|
17
|
+
* in-arcs (one invocation per node, with an early exit once every source has reached the node), from the arcs the
|
|
18
|
+
* frontier would push against `pullAt`; a graph with a node of more than `PULL_MAX_DEGREE` in-arcs only pushes. The levels of a
|
|
19
|
+
* submit tally their claims per source into one count table, read back once per submit; the host folds the counts
|
|
20
|
+
* into exact sums in f64 (`count x distance`) and harmonic sums (`count / distance`). A level whose predecessor
|
|
21
|
+
* claimed nothing returns at once, so recording `MAX_LEVELS_PER_SUBMIT` levels costs little past a batch's depth.
|
|
22
|
+
* - ONE SEARCH PER SOURCE (weighted above the all-pairs ceiling, or a weighted sampled run): one `sssp` per source,
|
|
23
|
+
* the sums reduced on the host between calls.
|
|
24
|
+
*
|
|
25
|
+
* `weighted` defaults to the snapshot's `flags.weighted`; `weighted: false` on a weighted snapshot ignores the column;
|
|
26
|
+
* `weighted: true` over unit weights or no column is the unweighted problem. `maxIterations` and `tolerance` are the
|
|
23
27
|
* seam's placeholder keys and an exact traversal has neither, so a defined value is REFUSED before any device work
|
|
24
|
-
* (`E_UNSUPPORTED { option }
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* claim's distance into a per-node sum
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* (`E_UNSUPPORTED { option }`); `undefined` is legal. `iterations` reports the source batches run (the sources, on the
|
|
29
|
+
* one-search-per-source route; 1 on the all-pairs route), `converged` is always true.
|
|
30
|
+
*
|
|
31
|
+
* A SAMPLED run (`sources`, undirected snapshots only) seeds its batches from the listed sources and adds every
|
|
32
|
+
* claim's distance into a per-node sum, folded on the host into `1 / sum` per NODE: on an undirected graph the
|
|
33
|
+
* distance from a source to a node is the distance from the node to the source, which is what the CPU port's sampled
|
|
34
|
+
* closeness sums. A sampled harmonic run is refused (`E_UNSUPPORTED closenessCentrality.sampledHarmonic`): the
|
|
35
|
+
* per-node reciprocal sums would need a float atomic.
|
|
31
36
|
*
|
|
32
|
-
* Cost, stated so nobody is surprised: closeness is O(n x m) on any device -- at 1M nodes it is
|
|
33
|
-
* full multi-source traversal
|
|
34
|
-
*
|
|
35
|
-
* scope whose `scratch` hands the same buffer back for the same label and size: the dispatches of one pass run in
|
|
36
|
-
* order, a level's scan overwrites the previous level's, and the run holds one set instead of `levels x batches`.
|
|
37
|
-
* The sweep keeps DEP-P8-E's refusal of a windowed core (`assertWholeCore`): the bit-parallel claim needs the whole
|
|
38
|
-
* arc array bound. The tuning entry `closenessWithTuning` (PD-26's shape) is what the tests drive; nothing public
|
|
39
|
-
* exposes it.
|
|
37
|
+
* Cost, stated so nobody is surprised: closeness is O(n x m) on any device -- at 1M nodes it is 3,907 batches of a
|
|
38
|
+
* full multi-source traversal. The level kernel binds the whole arc array (`assertWholeCore`) and, on a directed
|
|
39
|
+
* snapshot, the whole reverse adjacency. `closenessWithTuning` is what the tests drive; nothing public exposes it.
|
|
40
40
|
*/
|
|
41
41
|
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
42
42
|
import { type GpuContext } from "../context.js";
|
|
@@ -46,17 +46,20 @@ import { type GpuRunOptions } from "../types/run.js";
|
|
|
46
46
|
/**
|
|
47
47
|
* Closeness centrality on the device (spec 3.3 line 810, design 8.4, 9.7): `scores[s] = 1 / sumDist_s` over the finite
|
|
48
48
|
* distances from `s` to every other node, `0` when nothing is reached -- the legacy default of `@graphty/algorithms`'
|
|
49
|
-
* `closenessCentrality`,
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* `closenessCentrality` -- or, with `harmonic`, the sum of `1 / dist` over the same nodes. Small and weighted
|
|
50
|
+
* graphs whose all-pairs matrix fits one binding run the all-pairs sweep and a row sum; other unweighted graphs run a
|
|
51
|
+
* bit-parallel multi-source search of up to 256 sources per batch; weighted graphs above the all-pairs ceiling run one
|
|
52
|
+
* `sssp` per source. `weighted` defaults to the snapshot's flag, `maxIterations` / `tolerance` are refused when
|
|
53
|
+
* defined. `iterations` is the source batches run and `converged` is always true.
|
|
52
54
|
*
|
|
53
55
|
* SAMPLED (`sources`, node indices, duplicates run twice; undirected snapshots only, E_UNSUPPORTED
|
|
54
|
-
* `closenessCentrality.directedSources` otherwise
|
|
55
|
-
*
|
|
56
|
-
*
|
|
56
|
+
* `closenessCentrality.directedSources` otherwise; not with `harmonic`, E_UNSUPPORTED
|
|
57
|
+
* `closenessCentrality.sampledHarmonic`): the batches seed the listed sources instead of every node, and each node's
|
|
58
|
+
* score is `1 / sum` of its distances to the sources that reach it (itself excluded), `0` when none does: the sampled
|
|
59
|
+
* score of the CPU port, unscaled. `sourcesUsed` is the list's length (`n` exact).
|
|
57
60
|
* @param ctx - the context whose device runs the kernels
|
|
58
61
|
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
59
|
-
* @param options - `weighted`, `sources`, plus dest (a Float32Array of length n for `scores`) / signal / onProgress
|
|
62
|
+
* @param options - `weighted`, `harmonic`, `sources`, plus dest (a Float32Array of length n for `scores`) / signal / onProgress
|
|
60
63
|
* @returns the scores, the batches run, `converged: true`, `precision: "f32"` and `sourcesUsed`
|
|
61
64
|
*/
|
|
62
65
|
export declare function closenessCentrality(ctx: GpuContext, s: GraphSnapshot, options?: ClosenessAcceleratorOptions & HitsOptionsLike & GpuRunOptions): Promise<GpuClosenessResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closeness.d.ts","sourceRoot":"","sources":["../../../src/algorithms/closeness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAY,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"closeness.d.ts","sourceRoot":"","sources":["../../../src/algorithms/closeness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAOhD,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyfrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAC/B,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,2BAA2B,GAAG,eAAe,GAAG,aAAa,GACxE,OAAO,CAAC,kBAAkB,CAAC,CAE7B"}
|