graphwise 1.0.0 → 1.1.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/README.md +41 -0
- package/dist/expansion/base.d.ts +12 -0
- package/dist/expansion/base.d.ts.map +1 -0
- package/dist/expansion/base.unit.test.d.ts +2 -0
- package/dist/expansion/base.unit.test.d.ts.map +1 -0
- package/dist/expansion/dome.d.ts +16 -0
- package/dist/expansion/dome.d.ts.map +1 -0
- package/dist/expansion/dome.unit.test.d.ts +2 -0
- package/dist/expansion/dome.unit.test.d.ts.map +1 -0
- package/dist/expansion/edge.d.ts +15 -0
- package/dist/expansion/edge.d.ts.map +1 -0
- package/dist/expansion/edge.unit.test.d.ts +2 -0
- package/dist/expansion/edge.unit.test.d.ts.map +1 -0
- package/dist/expansion/hae.d.ts +22 -0
- package/dist/expansion/hae.d.ts.map +1 -0
- package/dist/expansion/hae.unit.test.d.ts +2 -0
- package/dist/expansion/hae.unit.test.d.ts.map +1 -0
- package/dist/expansion/index.d.ts +22 -0
- package/dist/expansion/index.d.ts.map +1 -0
- package/dist/expansion/maze.d.ts +25 -0
- package/dist/expansion/maze.d.ts.map +1 -0
- package/dist/expansion/maze.unit.test.d.ts +2 -0
- package/dist/expansion/maze.unit.test.d.ts.map +1 -0
- package/dist/expansion/pipe.d.ts +15 -0
- package/dist/expansion/pipe.d.ts.map +1 -0
- package/dist/expansion/pipe.unit.test.d.ts +2 -0
- package/dist/expansion/pipe.unit.test.d.ts.map +1 -0
- package/dist/expansion/reach.d.ts +26 -0
- package/dist/expansion/reach.d.ts.map +1 -0
- package/dist/expansion/reach.unit.test.d.ts +2 -0
- package/dist/expansion/reach.unit.test.d.ts.map +1 -0
- package/dist/expansion/sage.d.ts +24 -0
- package/dist/expansion/sage.d.ts.map +1 -0
- package/dist/expansion/sage.unit.test.d.ts +2 -0
- package/dist/expansion/sage.unit.test.d.ts.map +1 -0
- package/dist/expansion/types.d.ts +105 -0
- package/dist/expansion/types.d.ts.map +1 -0
- package/dist/extraction/ego-network.d.ts +32 -0
- package/dist/extraction/ego-network.d.ts.map +1 -0
- package/dist/extraction/ego-network.unit.test.d.ts +5 -0
- package/dist/extraction/ego-network.unit.test.d.ts.map +1 -0
- package/dist/extraction/index.d.ts +20 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/induced-subgraph.d.ts +19 -0
- package/dist/extraction/induced-subgraph.d.ts.map +1 -0
- package/dist/extraction/induced-subgraph.unit.test.d.ts +5 -0
- package/dist/extraction/induced-subgraph.unit.test.d.ts.map +1 -0
- package/dist/extraction/k-core.d.ts +24 -0
- package/dist/extraction/k-core.d.ts.map +1 -0
- package/dist/extraction/k-core.unit.test.d.ts +5 -0
- package/dist/extraction/k-core.unit.test.d.ts.map +1 -0
- package/dist/extraction/motif.d.ts +50 -0
- package/dist/extraction/motif.d.ts.map +1 -0
- package/dist/extraction/motif.unit.test.d.ts +5 -0
- package/dist/extraction/motif.unit.test.d.ts.map +1 -0
- package/dist/extraction/node-filter.d.ts +35 -0
- package/dist/extraction/node-filter.d.ts.map +1 -0
- package/dist/extraction/node-filter.unit.test.d.ts +5 -0
- package/dist/extraction/node-filter.unit.test.d.ts.map +1 -0
- package/dist/extraction/truss.d.ts +41 -0
- package/dist/extraction/truss.d.ts.map +1 -0
- package/dist/extraction/truss.unit.test.d.ts +5 -0
- package/dist/extraction/truss.unit.test.d.ts.map +1 -0
- package/dist/gpu/context.d.ts +118 -0
- package/dist/gpu/context.d.ts.map +1 -0
- package/dist/gpu/context.unit.test.d.ts +2 -0
- package/dist/gpu/context.unit.test.d.ts.map +1 -0
- package/dist/gpu/csr.d.ts +97 -0
- package/dist/gpu/csr.d.ts.map +1 -0
- package/dist/gpu/csr.unit.test.d.ts +2 -0
- package/dist/gpu/csr.unit.test.d.ts.map +1 -0
- package/dist/gpu/detect.d.ts +25 -0
- package/dist/gpu/detect.d.ts.map +1 -0
- package/dist/gpu/detect.unit.test.d.ts +2 -0
- package/dist/gpu/detect.unit.test.d.ts.map +1 -0
- package/dist/gpu/index.cjs +6 -0
- package/dist/gpu/index.d.ts +11 -0
- package/dist/gpu/index.d.ts.map +1 -0
- package/dist/gpu/index.js +2 -0
- package/dist/gpu/types.d.ts +50 -0
- package/dist/gpu/types.d.ts.map +1 -0
- package/dist/gpu-BJRVYBjx.cjs +338 -0
- package/dist/gpu-BJRVYBjx.cjs.map +1 -0
- package/dist/gpu-BveuXugy.js +315 -0
- package/dist/gpu-BveuXugy.js.map +1 -0
- package/dist/graph/adjacency-map.d.ts +95 -0
- package/dist/graph/adjacency-map.d.ts.map +1 -0
- package/dist/graph/adjacency-map.unit.test.d.ts +2 -0
- package/dist/graph/adjacency-map.unit.test.d.ts.map +1 -0
- package/dist/graph/index.cjs +3 -0
- package/dist/graph/index.d.ts +9 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +2 -0
- package/dist/graph/interfaces.d.ts +125 -0
- package/dist/graph/interfaces.d.ts.map +1 -0
- package/dist/graph/types.d.ts +72 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph-DLWiziLB.js +222 -0
- package/dist/graph-DLWiziLB.js.map +1 -0
- package/dist/graph-az06J1YV.cjs +227 -0
- package/dist/graph-az06J1YV.cjs.map +1 -0
- package/dist/index/index.cjs +1404 -0
- package/dist/index/index.cjs.map +1 -0
- package/dist/index/index.js +1356 -0
- package/dist/index/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/kmeans-B0HEOU6k.cjs +234 -0
- package/dist/kmeans-B0HEOU6k.cjs.map +1 -0
- package/dist/kmeans-DgbsOznU.js +223 -0
- package/dist/kmeans-DgbsOznU.js.map +1 -0
- package/dist/ranking/baselines/shortest.d.ts +15 -0
- package/dist/ranking/baselines/shortest.d.ts.map +1 -0
- package/dist/ranking/baselines/shortest.unit.test.d.ts +2 -0
- package/dist/ranking/baselines/shortest.unit.test.d.ts.map +1 -0
- package/dist/ranking/baselines/types.d.ts +30 -0
- package/dist/ranking/baselines/types.d.ts.map +1 -0
- package/dist/ranking/index.d.ts +15 -0
- package/dist/ranking/index.d.ts.map +1 -0
- package/dist/ranking/mi/adamic-adar.d.ts +13 -0
- package/dist/ranking/mi/adamic-adar.d.ts.map +1 -0
- package/dist/ranking/mi/adaptive.d.ts +16 -0
- package/dist/ranking/mi/adaptive.d.ts.map +1 -0
- package/dist/ranking/mi/etch.d.ts +7 -0
- package/dist/ranking/mi/etch.d.ts.map +1 -0
- package/dist/ranking/mi/index.d.ts +18 -0
- package/dist/ranking/mi/index.d.ts.map +1 -0
- package/dist/ranking/mi/jaccard.d.ts +13 -0
- package/dist/ranking/mi/jaccard.d.ts.map +1 -0
- package/dist/ranking/mi/mi-variants.unit.test.d.ts +2 -0
- package/dist/ranking/mi/mi-variants.unit.test.d.ts.map +1 -0
- package/dist/ranking/mi/notch.d.ts +7 -0
- package/dist/ranking/mi/notch.d.ts.map +1 -0
- package/dist/ranking/mi/scale.d.ts +7 -0
- package/dist/ranking/mi/scale.d.ts.map +1 -0
- package/dist/ranking/mi/skew.d.ts +7 -0
- package/dist/ranking/mi/skew.d.ts.map +1 -0
- package/dist/ranking/mi/span.d.ts +7 -0
- package/dist/ranking/mi/span.d.ts.map +1 -0
- package/dist/ranking/mi/types.d.ts +35 -0
- package/dist/ranking/mi/types.d.ts.map +1 -0
- package/dist/ranking/parse.d.ts +56 -0
- package/dist/ranking/parse.d.ts.map +1 -0
- package/dist/ranking/parse.unit.test.d.ts +2 -0
- package/dist/ranking/parse.unit.test.d.ts.map +1 -0
- package/dist/schemas/define.d.ts +18 -0
- package/dist/schemas/define.d.ts.map +1 -0
- package/dist/schemas/define.unit.test.d.ts +2 -0
- package/dist/schemas/define.unit.test.d.ts.map +1 -0
- package/dist/schemas/graph.d.ts +85 -0
- package/dist/schemas/graph.d.ts.map +1 -0
- package/dist/schemas/graph.unit.test.d.ts +2 -0
- package/dist/schemas/graph.unit.test.d.ts.map +1 -0
- package/dist/schemas/index.cjs +3791 -0
- package/dist/schemas/index.cjs.map +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +3782 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/seeds/grasp.d.ts +79 -0
- package/dist/seeds/grasp.d.ts.map +1 -0
- package/dist/seeds/grasp.unit.test.d.ts +2 -0
- package/dist/seeds/grasp.unit.test.d.ts.map +1 -0
- package/dist/seeds/index.cjs +4 -0
- package/dist/seeds/index.d.ts +10 -0
- package/dist/seeds/index.d.ts.map +1 -0
- package/dist/seeds/index.js +2 -0
- package/dist/seeds/stratified.d.ts +85 -0
- package/dist/seeds/stratified.d.ts.map +1 -0
- package/dist/seeds/stratified.unit.test.d.ts +2 -0
- package/dist/seeds/stratified.unit.test.d.ts.map +1 -0
- package/dist/seeds-B6J9oJfU.cjs +404 -0
- package/dist/seeds-B6J9oJfU.cjs.map +1 -0
- package/dist/seeds-UNZxqm_U.js +393 -0
- package/dist/seeds-UNZxqm_U.js.map +1 -0
- package/dist/structures/index.cjs +3 -0
- package/dist/structures/index.d.ts +3 -0
- package/dist/structures/index.d.ts.map +1 -0
- package/dist/structures/index.js +2 -0
- package/dist/structures/priority-queue.d.ts +59 -0
- package/dist/structures/priority-queue.d.ts.map +1 -0
- package/dist/structures/priority-queue.unit.test.d.ts +2 -0
- package/dist/structures/priority-queue.unit.test.d.ts.map +1 -0
- package/dist/structures-BPfhfqNP.js +133 -0
- package/dist/structures-BPfhfqNP.js.map +1 -0
- package/dist/structures-CJ_S_7fs.cjs +138 -0
- package/dist/structures-CJ_S_7fs.cjs.map +1 -0
- package/dist/traversal/bfs.d.ts +50 -0
- package/dist/traversal/bfs.d.ts.map +1 -0
- package/dist/traversal/bfs.unit.test.d.ts +2 -0
- package/dist/traversal/bfs.unit.test.d.ts.map +1 -0
- package/dist/traversal/dfs.d.ts +50 -0
- package/dist/traversal/dfs.d.ts.map +1 -0
- package/dist/traversal/dfs.unit.test.d.ts +2 -0
- package/dist/traversal/dfs.unit.test.d.ts.map +1 -0
- package/dist/traversal/index.cjs +6 -0
- package/dist/traversal/index.d.ts +11 -0
- package/dist/traversal/index.d.ts.map +1 -0
- package/dist/traversal/index.js +2 -0
- package/dist/traversal-CQCjUwUJ.js +149 -0
- package/dist/traversal-CQCjUwUJ.js.map +1 -0
- package/dist/traversal-QeHaNUWn.cjs +172 -0
- package/dist/traversal-QeHaNUWn.cjs.map +1 -0
- package/dist/utils/clustering-coefficient.d.ts +38 -0
- package/dist/utils/clustering-coefficient.d.ts.map +1 -0
- package/dist/utils/clustering-coefficient.unit.test.d.ts +2 -0
- package/dist/utils/clustering-coefficient.unit.test.d.ts.map +1 -0
- package/dist/utils/entropy.d.ts +58 -0
- package/dist/utils/entropy.d.ts.map +1 -0
- package/dist/utils/entropy.unit.test.d.ts +2 -0
- package/dist/utils/entropy.unit.test.d.ts.map +1 -0
- package/dist/utils/index.cjs +13 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/kmeans.d.ts +73 -0
- package/dist/utils/kmeans.d.ts.map +1 -0
- package/dist/utils/kmeans.unit.test.d.ts +2 -0
- package/dist/utils/kmeans.unit.test.d.ts.map +1 -0
- package/dist/utils-Q_akvlMn.js +164 -0
- package/dist/utils-Q_akvlMn.js.map +1 -0
- package/dist/utils-spZa1ZvS.cjs +205 -0
- package/dist/utils-spZa1ZvS.cjs.map +1 -0
- package/package.json +136 -8
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NodeId, NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
/**
|
|
3
|
+
* Result of a motif census operation.
|
|
4
|
+
*/
|
|
5
|
+
export interface MotifCensus {
|
|
6
|
+
/** Map from motif type identifier to count */
|
|
7
|
+
readonly counts: ReadonlyMap<string, number>;
|
|
8
|
+
/** Optional map from motif type to node instances */
|
|
9
|
+
readonly instances?: ReadonlyMap<string, readonly NodeId[][]>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Enumerate motifs of a given size in the graph.
|
|
13
|
+
*
|
|
14
|
+
* This function counts all occurrences of each distinct motif type
|
|
15
|
+
* (isomorphism class) in the graph. For graphs with many nodes,
|
|
16
|
+
* 4-motif enumeration can be expensive (O(n^4) worst case).
|
|
17
|
+
*
|
|
18
|
+
* @param graph - The source graph
|
|
19
|
+
* @param size - Motif size (3 or 4 nodes)
|
|
20
|
+
* @returns Motif census with counts per motif type
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Count all triangles and other 3-node patterns
|
|
25
|
+
* const census3 = enumerateMotifs(graph, 3);
|
|
26
|
+
* console.log(`Triangles: ${census3.counts.get('0-1,0-2,1-2')}`);
|
|
27
|
+
*
|
|
28
|
+
* // Count 4-node patterns
|
|
29
|
+
* const census4 = enumerateMotifs(graph, 4);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function enumerateMotifs<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, size: 3 | 4): MotifCensus;
|
|
33
|
+
/**
|
|
34
|
+
* Enumerate motifs with optional instance tracking.
|
|
35
|
+
*
|
|
36
|
+
* @param graph - The source graph
|
|
37
|
+
* @param size - Motif size (3 or 4 nodes)
|
|
38
|
+
* @param includeInstances - Whether to include node instances
|
|
39
|
+
* @returns Motif census with counts and optionally instances
|
|
40
|
+
*/
|
|
41
|
+
export declare function enumerateMotifsWithInstances<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, size: 3 | 4, includeInstances: boolean): MotifCensus;
|
|
42
|
+
/**
|
|
43
|
+
* Get a human-readable name for a motif pattern.
|
|
44
|
+
*
|
|
45
|
+
* @param pattern - The canonical pattern string
|
|
46
|
+
* @param size - Motif size (3 or 4 nodes)
|
|
47
|
+
* @returns A human-readable name, or the pattern itself if unknown
|
|
48
|
+
*/
|
|
49
|
+
export declare function getMotifName(pattern: string, size: 3 | 4): string;
|
|
50
|
+
//# sourceMappingURL=motif.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motif.d.ts","sourceRoot":"","sources":["../../src/extraction/motif.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,CAAC;CAC9D;AA6QD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACrE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,GAAG,CAAC,GACT,WAAW,CAKb;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC3C,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,QAAQ,EAElB,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,GAAG,CAAC,EACX,gBAAgB,EAAE,OAAO,GACvB,WAAW,CAIb;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAGjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motif.unit.test.d.ts","sourceRoot":"","sources":["../../src/extraction/motif.unit.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AdjacencyMapGraph } from '../graph/adjacency-map';
|
|
3
|
+
/**
|
|
4
|
+
* Options for filtering a subgraph.
|
|
5
|
+
*/
|
|
6
|
+
export interface FilterOptions<N extends NodeData, E extends EdgeData> {
|
|
7
|
+
/** Predicate to filter nodes. Return true to include the node. */
|
|
8
|
+
readonly nodePredicate?: (node: N) => boolean;
|
|
9
|
+
/** Predicate to filter edges. Return true to include the edge. */
|
|
10
|
+
readonly edgePredicate?: (edge: E) => boolean;
|
|
11
|
+
/** Whether to remove nodes that become isolated after edge filtering. Default: false. */
|
|
12
|
+
readonly removeIsolated?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extract a filtered subgraph based on node and edge predicates.
|
|
16
|
+
*
|
|
17
|
+
* Nodes are first filtered by the node predicate (if provided).
|
|
18
|
+
* Edges are then filtered by the edge predicate (if provided), and only
|
|
19
|
+
* retained if both endpoints pass the node predicate.
|
|
20
|
+
*
|
|
21
|
+
* @param graph - The source graph
|
|
22
|
+
* @param options - Filter options specifying node/edge predicates
|
|
23
|
+
* @returns A new graph containing only nodes and edges that pass the predicates
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* // Extract subgraph of high-weight nodes
|
|
28
|
+
* const filtered = filterSubgraph(graph, {
|
|
29
|
+
* nodePredicate: (node) => (node.weight ?? 0) > 0.5,
|
|
30
|
+
* removeIsolated: true
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function filterSubgraph<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, options?: FilterOptions<N, E>): AdjacencyMapGraph<N, E>;
|
|
35
|
+
//# sourceMappingURL=node-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-filter.d.ts","sourceRoot":"","sources":["../../src/extraction/node-filter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ;IACpE,kEAAkE;IAClE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC9C,kEAAkE;IAClE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IAC9C,yFAAyF;IACzF,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACpE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAC3B,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAiDzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-filter.unit.test.d.ts","sourceRoot":"","sources":["../../src/extraction/node-filter.unit.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AdjacencyMapGraph } from '../graph/adjacency-map';
|
|
3
|
+
/**
|
|
4
|
+
* Extract the k-truss of a graph.
|
|
5
|
+
*
|
|
6
|
+
* The k-truss is the maximal subgraph where every edge participates in
|
|
7
|
+
* at least k-2 triangles. This is computed by iteratively removing edges
|
|
8
|
+
* with fewer than k-2 triangles, then removing isolated nodes.
|
|
9
|
+
*
|
|
10
|
+
* Note: K-truss is typically defined for undirected graphs. For directed
|
|
11
|
+
* graphs, this treats the graph as undirected for triangle counting.
|
|
12
|
+
*
|
|
13
|
+
* @param graph - The source graph
|
|
14
|
+
* @param k - The minimum triangle count threshold (edge must be in >= k-2 triangles)
|
|
15
|
+
* @returns A new graph containing the k-truss (may be empty)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Extract the 3-truss (edges in at least 1 triangle)
|
|
20
|
+
* const truss3 = extractKTruss(graph, 3);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractKTruss<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, k: number): AdjacencyMapGraph<N, E>;
|
|
24
|
+
/**
|
|
25
|
+
* Compute the truss number for each edge.
|
|
26
|
+
*
|
|
27
|
+
* The truss number of an edge is the largest k such that the edge
|
|
28
|
+
* belongs to the k-truss.
|
|
29
|
+
*
|
|
30
|
+
* @param graph - The source graph
|
|
31
|
+
* @returns Map from edge key (canonical "u::v") to truss number
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const trussNumbers = computeTrussNumbers(graph);
|
|
36
|
+
* const edgeKey = 'A::B'; // where A < B lexicographically
|
|
37
|
+
* console.log(`Edge A-B is in the ${trussNumbers.get(edgeKey)}-truss`);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function computeTrussNumbers<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>): Map<string, number>;
|
|
41
|
+
//# sourceMappingURL=truss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truss.d.ts","sourceRoot":"","sources":["../../src/extraction/truss.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AA8B3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACnE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,CAAC,EAAE,MAAM,GACP,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAoIzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACzE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAyGrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truss.unit.test.d.ts","sourceRoot":"","sources":["../../src/extraction/truss.unit.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GPU context management for WebGPU compute operations.
|
|
3
|
+
*
|
|
4
|
+
* Provides device acquisition, buffer pooling, and shader compilation
|
|
5
|
+
* with caching for efficient GPU resource management.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a GPUContext.
|
|
9
|
+
*/
|
|
10
|
+
export interface GPUContextOptions {
|
|
11
|
+
/** Power preference for GPU adapter */
|
|
12
|
+
readonly powerPreference?: "low-power" | "high-performance";
|
|
13
|
+
/** Force create new context even if one exists */
|
|
14
|
+
readonly forceNew?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Manages GPU device, buffers, and compiled shaders.
|
|
18
|
+
*
|
|
19
|
+
* Use the singleton pattern via getGPUContext() for most use cases,
|
|
20
|
+
* or create separate contexts for isolated GPU resource pools.
|
|
21
|
+
*/
|
|
22
|
+
export declare class GPUContext {
|
|
23
|
+
private device;
|
|
24
|
+
private readonly shaderCache;
|
|
25
|
+
private readonly bufferPool;
|
|
26
|
+
private readonly destroyedBuffers;
|
|
27
|
+
/**
|
|
28
|
+
* Check if this context has an acquired GPU device.
|
|
29
|
+
*/
|
|
30
|
+
get isReady(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get the GPU device, throwing if not acquired.
|
|
33
|
+
*/
|
|
34
|
+
getDevice(): GPUDevice;
|
|
35
|
+
/**
|
|
36
|
+
* Acquire a GPU device from the adapter.
|
|
37
|
+
*
|
|
38
|
+
* @param options - Context creation options
|
|
39
|
+
* @returns true if device was acquired successfully
|
|
40
|
+
* @throws Error if WebGPU is unavailable or device request fails
|
|
41
|
+
*/
|
|
42
|
+
acquireDevice(options?: GPUContextOptions): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Compile a WGSL shader, using cache if available.
|
|
45
|
+
*
|
|
46
|
+
* @param code - WGSL shader code
|
|
47
|
+
* @param key - Optional cache key (defaults to code hash)
|
|
48
|
+
* @returns Compiled shader module
|
|
49
|
+
*/
|
|
50
|
+
compileShader(code: string, key?: string): GPUShaderModule;
|
|
51
|
+
/**
|
|
52
|
+
* Create a GPU buffer, optionally reusing from pool.
|
|
53
|
+
*
|
|
54
|
+
* @param size - Buffer size in bytes
|
|
55
|
+
* @param usage - Buffer usage flags
|
|
56
|
+
* @returns GPU buffer
|
|
57
|
+
*/
|
|
58
|
+
createBuffer(size: number, usage: GPUBufferUsageFlags): GPUBuffer;
|
|
59
|
+
/**
|
|
60
|
+
* Return a buffer to the pool for reuse.
|
|
61
|
+
*
|
|
62
|
+
* @param buffer - Buffer to recycle
|
|
63
|
+
*/
|
|
64
|
+
recycleBuffer(buffer: GPUBuffer): void;
|
|
65
|
+
/**
|
|
66
|
+
* Mark a buffer as destroyed (call before GPUBuffer.destroy()).
|
|
67
|
+
*
|
|
68
|
+
* @param buffer - Buffer to mark as destroyed
|
|
69
|
+
*/
|
|
70
|
+
markDestroyed(buffer: GPUBuffer): void;
|
|
71
|
+
/**
|
|
72
|
+
* Create a compute pipeline from shader code.
|
|
73
|
+
*
|
|
74
|
+
* @param code - WGSL compute shader code
|
|
75
|
+
* @param entryPoint - Entry point function name
|
|
76
|
+
* @returns Compute pipeline
|
|
77
|
+
*/
|
|
78
|
+
createComputePipeline(code: string, entryPoint?: string): GPUComputePipeline;
|
|
79
|
+
/**
|
|
80
|
+
* Create a compute pipeline asynchronously (preferred for performance).
|
|
81
|
+
*
|
|
82
|
+
* @param code - WGSL compute shader code
|
|
83
|
+
* @param entryPoint - Entry point function name
|
|
84
|
+
* @returns Promise resolving to compute pipeline
|
|
85
|
+
*/
|
|
86
|
+
createComputePipelineAsync(code: string, entryPoint?: string): Promise<GPUComputePipeline>;
|
|
87
|
+
/**
|
|
88
|
+
* Clear all cached resources.
|
|
89
|
+
*/
|
|
90
|
+
clearCache(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Destroy the context and release all resources.
|
|
93
|
+
*/
|
|
94
|
+
destroy(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Simple string hash for cache keys.
|
|
97
|
+
*/
|
|
98
|
+
private hashCode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get or create the default GPU context.
|
|
102
|
+
*
|
|
103
|
+
* This is a lazy singleton - the device is not acquired until
|
|
104
|
+
* acquireDevice() is called.
|
|
105
|
+
*
|
|
106
|
+
* @param options - Context creation options
|
|
107
|
+
* @returns GPU context instance
|
|
108
|
+
*/
|
|
109
|
+
export declare function getGPUContext(options?: GPUContextOptions): GPUContext;
|
|
110
|
+
/**
|
|
111
|
+
* Create a new isolated GPU context.
|
|
112
|
+
*
|
|
113
|
+
* Use this when you need separate resource pools or device management.
|
|
114
|
+
*
|
|
115
|
+
* @returns New GPU context instance
|
|
116
|
+
*/
|
|
117
|
+
export declare function createGPUContext(): GPUContext;
|
|
118
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/gpu/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uCAAuC;IACvC,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,GAAG,kBAAkB,CAAC;IAC5D,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD;;;;;GAKG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmC;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4B;IAE7D;;OAEG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;OAEG;IACI,SAAS,IAAI,SAAS;IAS7B;;;;;;OAMG;IACU,aAAa,CACzB,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,OAAO,CAAC;IAqDnB;;;;;;OAMG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,eAAe;IAejE;;;;;;OAMG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS;IAoBxE;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAO7C;;;;OAIG;IACI,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAI7C;;;;;;OAMG;IACI,qBAAqB,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,SAAS,GACjB,kBAAkB;IAarB;;;;;;OAMG;IACU,0BAA0B,CACtC,IAAI,EAAE,MAAM,EACZ,UAAU,SAAS,GACjB,OAAO,CAAC,kBAAkB,CAAC;IAa9B;;OAEG;IACI,UAAU,IAAI,IAAI;IAQzB;;OAEG;IACI,OAAO,IAAI,IAAI;IAQtB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAQhB;AAKD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAKrE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.unit.test.d.ts","sourceRoot":"","sources":["../../src/gpu/context.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { NodeId, Direction, NodeData, EdgeData } from '../graph/types';
|
|
2
|
+
import { ReadableGraph } from '../graph';
|
|
3
|
+
/**
|
|
4
|
+
* CSR matrix representation of a graph adjacency structure.
|
|
5
|
+
*
|
|
6
|
+
* The rowOffsets array has length nodeCount + 1, where rowOffsets[i]
|
|
7
|
+
* gives the start index in colIndices for node i's neighbours.
|
|
8
|
+
* The neighbours of node i are colIndices[rowOffsets[i] : rowOffsets[i+1]].
|
|
9
|
+
*/
|
|
10
|
+
export interface CSRMatrix {
|
|
11
|
+
/** Row offsets array (length: nodeCount + 1) */
|
|
12
|
+
readonly rowOffsets: Uint32Array;
|
|
13
|
+
/** Column indices array (length: edgeCount for directed, 2*edgeCount for undirected) */
|
|
14
|
+
readonly colIndices: Uint32Array;
|
|
15
|
+
/** Optional edge weights aligned with colIndices */
|
|
16
|
+
readonly values?: Float32Array;
|
|
17
|
+
/** Number of nodes in the graph */
|
|
18
|
+
readonly nodeCount: number;
|
|
19
|
+
/** Number of directed edges (undirected edges counted once) */
|
|
20
|
+
readonly edgeCount: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mapping from node IDs to CSR indices.
|
|
24
|
+
*
|
|
25
|
+
* Required because CSR uses dense integer indices while graphs
|
|
26
|
+
* may use arbitrary string identifiers.
|
|
27
|
+
*/
|
|
28
|
+
export interface CSRIndexMap {
|
|
29
|
+
/** Map from NodeId to CSR row index */
|
|
30
|
+
readonly nodeToIndex: ReadonlyMap<NodeId, number>;
|
|
31
|
+
/** Map from CSR row index to NodeId */
|
|
32
|
+
readonly indexToNode: readonly NodeId[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Combined CSR matrix with index mapping.
|
|
36
|
+
*/
|
|
37
|
+
export interface CSRGraph {
|
|
38
|
+
readonly csr: CSRMatrix;
|
|
39
|
+
readonly indexMap: CSRIndexMap;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Group of GPU buffers holding a CSR matrix.
|
|
43
|
+
*
|
|
44
|
+
* Each buffer is created with appropriate usage flags for compute operations.
|
|
45
|
+
*/
|
|
46
|
+
export interface GPUBufferGroup {
|
|
47
|
+
/** Buffer containing rowOffsets data */
|
|
48
|
+
readonly rowOffsets: GPUBuffer;
|
|
49
|
+
/** Buffer containing colIndices data */
|
|
50
|
+
readonly colIndices: GPUBuffer;
|
|
51
|
+
/** Buffer containing values data (optional) */
|
|
52
|
+
readonly values?: GPUBuffer;
|
|
53
|
+
/** Number of nodes */
|
|
54
|
+
readonly nodeCount: number;
|
|
55
|
+
/** Number of edges */
|
|
56
|
+
readonly edgeCount: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Convert a ReadableGraph to CSR format.
|
|
60
|
+
*
|
|
61
|
+
* For undirected graphs, each edge is stored twice (once in each direction).
|
|
62
|
+
* For directed graphs, edges are stored in the out-direction by default.
|
|
63
|
+
*
|
|
64
|
+
* @param graph - The graph to convert
|
|
65
|
+
* @param direction - Edge direction to include (default: 'out' for directed, 'both' for undirected)
|
|
66
|
+
* @returns CSR representation with index mapping
|
|
67
|
+
*/
|
|
68
|
+
export declare function graphToCSR<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, direction?: Direction): CSRGraph;
|
|
69
|
+
/**
|
|
70
|
+
* Create GPU buffers from a CSR matrix.
|
|
71
|
+
*
|
|
72
|
+
* Buffers are created with:
|
|
73
|
+
* - rowOffsets/colIndices: STORAGE | COPY_DST
|
|
74
|
+
* - values: STORAGE | COPY_DST (if present)
|
|
75
|
+
*
|
|
76
|
+
* @param device - GPU device to create buffers on
|
|
77
|
+
* @param csr - CSR matrix to upload
|
|
78
|
+
* @returns GPU buffer group
|
|
79
|
+
*/
|
|
80
|
+
export declare function csrToGPUBuffers(device: GPUDevice, csr: CSRMatrix): GPUBufferGroup;
|
|
81
|
+
/**
|
|
82
|
+
* Create a result buffer for reading compute output.
|
|
83
|
+
*
|
|
84
|
+
* @param device - GPU device
|
|
85
|
+
* @param byteLength - Size of the buffer in bytes
|
|
86
|
+
* @returns GPU buffer configured for map reading
|
|
87
|
+
*/
|
|
88
|
+
export declare function createResultBuffer(device: GPUDevice, byteLength: number): GPUBuffer;
|
|
89
|
+
/**
|
|
90
|
+
* Read data from a GPU buffer to CPU.
|
|
91
|
+
*
|
|
92
|
+
* @param device - GPU device
|
|
93
|
+
* @param buffer - Buffer to read from
|
|
94
|
+
* @returns ArrayBuffer containing the buffer data
|
|
95
|
+
*/
|
|
96
|
+
export declare function readBufferToCPU(device: GPUDevice, buffer: GPUBuffer): Promise<ArrayBuffer>;
|
|
97
|
+
//# sourceMappingURL=csr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csr.d.ts","sourceRoot":"","sources":["../../src/gpu/csr.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACzB,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAChE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,SAAS,GAAE,SAA2C,GACpD,QAAQ,CA0EV;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,SAAS,GACZ,cAAc,CAmChB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,GAChB,SAAS,CAQX;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,GACf,OAAO,CAAC,WAAW,CAAC,CAKtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csr.unit.test.d.ts","sourceRoot":"","sources":["../../src/gpu/csr.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GPUDetectionResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Detect WebGPU availability in the current environment.
|
|
4
|
+
*
|
|
5
|
+
* Checks for:
|
|
6
|
+
* - Browser: navigator.gpu
|
|
7
|
+
* - Node.js: global GPU constructor (Node.js 21+ with --experimental-webgpu)
|
|
8
|
+
* - Deno: global GPU constructor
|
|
9
|
+
*
|
|
10
|
+
* @returns Detection result with availability status and reason
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectWebGPU(): GPUDetectionResult;
|
|
13
|
+
/**
|
|
14
|
+
* Check if WebGPU is available (convenience function).
|
|
15
|
+
*
|
|
16
|
+
* @returns true if WebGPU is available, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function isWebGPUAvailable(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Assert that WebGPU is available, throwing an error if not.
|
|
21
|
+
*
|
|
22
|
+
* @throws Error if WebGPU is not available
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertWebGPUAvailable(): void;
|
|
25
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/gpu/detect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,kBAAkB,CA4BjD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAO5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.unit.test.d.ts","sourceRoot":"","sources":["../../src/gpu/detect.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_gpu = require("../gpu-BJRVYBjx.cjs");
|
|
3
|
+
exports.GPUContext = require_gpu.GPUContext;
|
|
4
|
+
exports.csrToGPUBuffers = require_gpu.csrToGPUBuffers;
|
|
5
|
+
exports.detectWebGPU = require_gpu.detectWebGPU;
|
|
6
|
+
exports.graphToCSR = require_gpu.graphToCSR;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGPU compute backend for graph algorithms.
|
|
3
|
+
*
|
|
4
|
+
* @module gpu - WebGPU compute utilities
|
|
5
|
+
*/
|
|
6
|
+
export type { ComputeBackend, GPUNotAvailableError, ComputeResult, GPUDetectionResult, } from './types';
|
|
7
|
+
export type { CSRMatrix, GPUBufferGroup } from './csr';
|
|
8
|
+
export { detectWebGPU } from './detect';
|
|
9
|
+
export { GPUContext } from './context';
|
|
10
|
+
export { graphToCSR, csrToGPUBuffers } from './csr';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gpu/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACX,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,kBAAkB,GAClB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the WebGPU compute backend.
|
|
3
|
+
*
|
|
4
|
+
* These types define the backend selection options and result types
|
|
5
|
+
* for GPU-accelerated graph operations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Backend selection for compute operations.
|
|
9
|
+
*
|
|
10
|
+
* - 'cpu': Synchronous CPU implementation (default, always available)
|
|
11
|
+
* - 'gpu': Async GPU implementation (throws if WebGPU unavailable)
|
|
12
|
+
* - 'auto': Async, detect WebGPU at runtime, fall back to CPU silently
|
|
13
|
+
*/
|
|
14
|
+
export type ComputeBackend = "auto" | "gpu" | "cpu";
|
|
15
|
+
/**
|
|
16
|
+
* Result of WebGPU availability detection.
|
|
17
|
+
*/
|
|
18
|
+
export interface GPUDetectionResult {
|
|
19
|
+
/** Whether WebGPU is available in the current environment */
|
|
20
|
+
readonly available: boolean;
|
|
21
|
+
/** Human-readable reason if unavailable */
|
|
22
|
+
readonly reason?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when GPU backend is requested but unavailable.
|
|
26
|
+
*/
|
|
27
|
+
export declare class GPUNotAvailableError extends Error {
|
|
28
|
+
constructor(reason: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result wrapper for GPU operations that may fall back to CPU.
|
|
32
|
+
*/
|
|
33
|
+
export interface ComputeResult<T> {
|
|
34
|
+
/** The computed result value */
|
|
35
|
+
readonly value: T;
|
|
36
|
+
/** Which backend was actually used */
|
|
37
|
+
readonly backend: "gpu" | "cpu";
|
|
38
|
+
/** Time taken in milliseconds (optional, for profiling) */
|
|
39
|
+
readonly elapsedMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Configuration options for GPU compute operations.
|
|
43
|
+
*/
|
|
44
|
+
export interface GPUComputeOptions {
|
|
45
|
+
/** Backend selection: 'auto', 'gpu', or 'cpu' */
|
|
46
|
+
readonly backend?: ComputeBackend;
|
|
47
|
+
/** Optional GPU device to reuse (avoids device acquisition overhead) */
|
|
48
|
+
readonly device?: GPUDevice;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gpu/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBAC3B,MAAM,EAAE,MAAM;CAIjC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC5B"}
|