graphwise 1.9.0 → 1.10.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.
Files changed (135) hide show
  1. package/dist/async/index.cjs +98 -1
  2. package/dist/async/index.cjs.map +1 -0
  3. package/dist/async/index.d.ts +1 -0
  4. package/dist/async/index.d.ts.map +1 -1
  5. package/dist/async/index.js +96 -2
  6. package/dist/async/index.js.map +1 -0
  7. package/dist/async/ops.d.ts +2 -0
  8. package/dist/async/ops.d.ts.map +1 -1
  9. package/dist/async/protocol.d.ts +14 -0
  10. package/dist/async/protocol.d.ts.map +1 -1
  11. package/dist/async/runner-batched.d.ts +21 -0
  12. package/dist/async/runner-batched.d.ts.map +1 -0
  13. package/dist/async/runner-batched.unit.test.d.ts +2 -0
  14. package/dist/async/runner-batched.unit.test.d.ts.map +1 -0
  15. package/dist/async/runners.d.ts.map +1 -1
  16. package/dist/expansion/base-core.d.ts.map +1 -1
  17. package/dist/expansion/fuse.d.ts +24 -1
  18. package/dist/expansion/fuse.d.ts.map +1 -1
  19. package/dist/expansion/index.cjs +9 -1
  20. package/dist/expansion/index.js +2 -2
  21. package/dist/expansion/lace.d.ts +23 -2
  22. package/dist/expansion/lace.d.ts.map +1 -1
  23. package/dist/expansion/priority-helpers.d.ts +20 -1
  24. package/dist/expansion/priority-helpers.d.ts.map +1 -1
  25. package/dist/expansion/sift.d.ts +24 -1
  26. package/dist/expansion/sift.d.ts.map +1 -1
  27. package/dist/expansion/types.d.ts +30 -0
  28. package/dist/expansion/types.d.ts.map +1 -1
  29. package/dist/{expansion-DaTroIyv.cjs → expansion--UuRowv-.cjs} +267 -4
  30. package/dist/expansion--UuRowv-.cjs.map +1 -0
  31. package/dist/{expansion-ClDhlMK8.js → expansion-CZLNK6Pr.js} +220 -5
  32. package/dist/expansion-CZLNK6Pr.js.map +1 -0
  33. package/dist/gpu/csr-graph.d.ts +68 -0
  34. package/dist/gpu/csr-graph.d.ts.map +1 -0
  35. package/dist/gpu/csr-graph.unit.test.d.ts +2 -0
  36. package/dist/gpu/csr-graph.unit.test.d.ts.map +1 -0
  37. package/dist/gpu/index.cjs +220 -15
  38. package/dist/gpu/index.cjs.map +1 -0
  39. package/dist/gpu/index.d.ts +1 -0
  40. package/dist/gpu/index.d.ts.map +1 -1
  41. package/dist/gpu/index.js +204 -2
  42. package/dist/gpu/index.js.map +1 -0
  43. package/dist/gpu/kernels/adamic-adar/kernel.d.ts +39 -0
  44. package/dist/gpu/kernels/adamic-adar/kernel.d.ts.map +1 -0
  45. package/dist/gpu/kernels/intersection/kernel.d.ts +50 -0
  46. package/dist/gpu/kernels/intersection/kernel.d.ts.map +1 -0
  47. package/dist/gpu/kernels/intersection/logic.d.ts +87 -0
  48. package/dist/gpu/kernels/intersection/logic.d.ts.map +1 -0
  49. package/dist/gpu/kernels/intersection/logic.unit.test.d.ts +2 -0
  50. package/dist/gpu/kernels/intersection/logic.unit.test.d.ts.map +1 -0
  51. package/dist/gpu/kernels/kmeans/index.d.ts +6 -0
  52. package/dist/gpu/kernels/kmeans/index.d.ts.map +1 -0
  53. package/dist/gpu/kernels/kmeans/kernel.d.ts +34 -0
  54. package/dist/gpu/kernels/kmeans/kernel.d.ts.map +1 -0
  55. package/dist/gpu/kernels/kmeans/logic.d.ts +111 -0
  56. package/dist/gpu/kernels/kmeans/logic.d.ts.map +1 -0
  57. package/dist/gpu/kernels/kmeans/logic.unit.test.d.ts +5 -0
  58. package/dist/gpu/kernels/kmeans/logic.unit.test.d.ts.map +1 -0
  59. package/dist/gpu/operations.d.ts +52 -0
  60. package/dist/gpu/operations.d.ts.map +1 -1
  61. package/dist/index/index.cjs +38 -19
  62. package/dist/index/index.js +10 -8
  63. package/dist/{jaccard-Bys9_dGW.cjs → jaccard-Bdw4B0i4.cjs} +1 -1
  64. package/dist/{jaccard-Bys9_dGW.cjs.map → jaccard-Bdw4B0i4.cjs.map} +1 -1
  65. package/dist/{jaccard-3rCdilwm.js → jaccard-BwC_NuQu.js} +1 -1
  66. package/dist/{jaccard-3rCdilwm.js.map → jaccard-BwC_NuQu.js.map} +1 -1
  67. package/dist/kernel-2oH4Cn32.cjs +1001 -0
  68. package/dist/kernel-2oH4Cn32.cjs.map +1 -0
  69. package/dist/kernel-6deK9fh1.js +724 -0
  70. package/dist/kernel-6deK9fh1.js.map +1 -0
  71. package/dist/kernel-CXeGBH3s.cjs +467 -0
  72. package/dist/kernel-CXeGBH3s.cjs.map +1 -0
  73. package/dist/kernel-CigCjrts.js +467 -0
  74. package/dist/kernel-CigCjrts.js.map +1 -0
  75. package/dist/kernel-CvnRsF7E.js +1001 -0
  76. package/dist/kernel-CvnRsF7E.js.map +1 -0
  77. package/dist/kernel-DukrXtVb.cjs +724 -0
  78. package/dist/kernel-DukrXtVb.cjs.map +1 -0
  79. package/dist/{kmeans-B8x9D1kt.cjs → kmeans-CZ7tJFYw.cjs} +1 -1
  80. package/dist/{kmeans-B8x9D1kt.cjs.map → kmeans-CZ7tJFYw.cjs.map} +1 -1
  81. package/dist/{kmeans-DKkL9rAN.js → kmeans-DLrlrp6i.js} +1 -1
  82. package/dist/{kmeans-DKkL9rAN.js.map → kmeans-DLrlrp6i.js.map} +1 -1
  83. package/dist/logic-Dbyfb_-7.cjs +289 -0
  84. package/dist/logic-Dbyfb_-7.cjs.map +1 -0
  85. package/dist/logic-DyBzRg1A.js +242 -0
  86. package/dist/logic-DyBzRg1A.js.map +1 -0
  87. package/dist/operations-D-RB67WP.cjs +2269 -0
  88. package/dist/operations-D-RB67WP.cjs.map +1 -0
  89. package/dist/operations-D9otVlIH.js +2198 -0
  90. package/dist/operations-D9otVlIH.js.map +1 -0
  91. package/dist/{ops-upIi6JIi.js → ops-D5xZr4fV.js} +60 -2
  92. package/dist/ops-D5xZr4fV.js.map +1 -0
  93. package/dist/{ops-djAsQQSh.cjs → ops-paa1Nvlf.cjs} +71 -1
  94. package/dist/ops-paa1Nvlf.cjs.map +1 -0
  95. package/dist/ranking/baselines/communicability.d.ts +12 -0
  96. package/dist/ranking/baselines/communicability.d.ts.map +1 -1
  97. package/dist/ranking/baselines/katz.d.ts +12 -0
  98. package/dist/ranking/baselines/katz.d.ts.map +1 -1
  99. package/dist/ranking/baselines/pagerank.d.ts +15 -0
  100. package/dist/ranking/baselines/pagerank.d.ts.map +1 -1
  101. package/dist/ranking/baselines/types.d.ts +3 -0
  102. package/dist/ranking/baselines/types.d.ts.map +1 -1
  103. package/dist/ranking/index.cjs +5 -2
  104. package/dist/ranking/index.js +3 -3
  105. package/dist/ranking/mi/index.cjs +1 -1
  106. package/dist/ranking/mi/index.js +1 -1
  107. package/dist/ranking/parse-gpu.d.ts +31 -0
  108. package/dist/ranking/parse-gpu.d.ts.map +1 -0
  109. package/dist/ranking/parse-gpu.unit.test.d.ts +5 -0
  110. package/dist/ranking/parse-gpu.unit.test.d.ts.map +1 -0
  111. package/dist/ranking/parse.d.ts.map +1 -1
  112. package/dist/{ranking-3ez5m67U.js → ranking-DOKDBcIR.js} +237 -11
  113. package/dist/ranking-DOKDBcIR.js.map +1 -0
  114. package/dist/{ranking-DVvajgUZ.cjs → ranking-pe5UaxKg.cjs} +254 -10
  115. package/dist/ranking-pe5UaxKg.cjs.map +1 -0
  116. package/dist/schemas/graph.d.ts +1 -1
  117. package/dist/seeds/grasp-gpu.d.ts +40 -0
  118. package/dist/seeds/grasp-gpu.d.ts.map +1 -0
  119. package/dist/seeds/index.cjs +1 -1
  120. package/dist/seeds/index.js +1 -1
  121. package/dist/{gpu-CHiCN0wa.js → typegpu-Dq5FfUB8.cjs} +16 -2041
  122. package/dist/typegpu-Dq5FfUB8.cjs.map +1 -0
  123. package/dist/{gpu-Y6owRVMi.cjs → typegpu-DwnJf28i.js} +2 -2127
  124. package/dist/typegpu-DwnJf28i.js.map +1 -0
  125. package/dist/utils/index.cjs +1 -1
  126. package/dist/utils/index.js +1 -1
  127. package/package.json +1 -1
  128. package/dist/expansion-ClDhlMK8.js.map +0 -1
  129. package/dist/expansion-DaTroIyv.cjs.map +0 -1
  130. package/dist/gpu-CHiCN0wa.js.map +0 -1
  131. package/dist/gpu-Y6owRVMi.cjs.map +0 -1
  132. package/dist/ops-djAsQQSh.cjs.map +0 -1
  133. package/dist/ops-upIi6JIi.js.map +0 -1
  134. package/dist/ranking-3ez5m67U.js.map +0 -1
  135. package/dist/ranking-DVvajgUZ.cjs.map +0 -1
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Pure CPU implementation of batch neighbourhood intersection.
3
+ *
4
+ * Computes intersection size and neighbourhood sizes for multiple node pairs.
5
+ * This is the foundation for ALL Jaccard-family MI variants:
6
+ * J(A,B) = |A ∩ B| / |A ∪ B| = intersection / (sizeA + sizeB - intersection)
7
+ * Cosine(A,B) = |A ∩ B| / sqrt(|A| * |B|)
8
+ * Sorensen-Dice(A,B) = 2|A ∩ B| / (|A| + |B|)
9
+ * Overlap(A,B) = |A ∩ B| / min(|A|, |B|)
10
+ *
11
+ * Uses binary search optimisation: iterate smaller neighbourhood, search in larger.
12
+ *
13
+ * @module gpu/kernels/intersection/logic
14
+ */
15
+ /**
16
+ * Result of computing intersection for a single pair.
17
+ */
18
+ export interface IntersectionResult {
19
+ /** Size of the intersection |N(u) ∩ N(v)| */
20
+ readonly intersection: number;
21
+ /** Size of first neighbourhood |N(u)| */
22
+ readonly sizeU: number;
23
+ /** Size of second neighbourhood |N(v)| */
24
+ readonly sizeV: number;
25
+ }
26
+ /**
27
+ * Binary search in a sorted subarray of colIndices.
28
+ *
29
+ * @param colIndices - CSR column indices array (must be sorted per row)
30
+ * @param start - Start index (inclusive)
31
+ * @param end - End index (exclusive)
32
+ * @param target - Value to search for
33
+ * @returns true if target is found between colIndices[start] and colIndices[end-1]
34
+ */
35
+ export declare function binarySearch(colIndices: Uint32Array, start: number, end: number, target: number): boolean;
36
+ /**
37
+ * Compute intersection stats for a single pair of nodes in CSR format.
38
+ *
39
+ * Neighbours must be sorted (CSR guarantees this from graphToCSR).
40
+ *
41
+ * @param rowOffsets - CSR row offset array
42
+ * @param colIndices - CSR column indices array
43
+ * @param u - First node index
44
+ * @param v - Second node index
45
+ * @returns Intersection result with sizes
46
+ */
47
+ export declare function intersectionPair(rowOffsets: Uint32Array, colIndices: Uint32Array, u: number, v: number): IntersectionResult;
48
+ /**
49
+ * Batch intersection stats for multiple node pairs.
50
+ *
51
+ * @param rowOffsets - CSR row offset array
52
+ * @param colIndices - CSR column indices array
53
+ * @param pairs - Array of [u, v] node index pairs
54
+ * @returns Object with parallel arrays: intersections, sizeUs, sizeVs
55
+ */
56
+ export declare function intersectionBatch(rowOffsets: Uint32Array, colIndices: Uint32Array, pairs: readonly (readonly [number, number])[]): {
57
+ intersections: Uint32Array;
58
+ sizeUs: Uint32Array;
59
+ sizeVs: Uint32Array;
60
+ };
61
+ /**
62
+ * Compute Jaccard from intersection stats.
63
+ * J = intersection / (sizeU + sizeV - intersection)
64
+ */
65
+ export declare function jaccardFromIntersection(result: IntersectionResult): number;
66
+ /**
67
+ * Compute Cosine similarity from intersection stats.
68
+ * Cosine = intersection / sqrt(sizeU * sizeV)
69
+ */
70
+ export declare function cosineFromIntersection(result: IntersectionResult): number;
71
+ /**
72
+ * Compute Sorensen-Dice from intersection stats.
73
+ * SD = 2 * intersection / (sizeU + sizeV)
74
+ */
75
+ export declare function sorensenDiceFromIntersection(result: IntersectionResult): number;
76
+ /**
77
+ * Compute Overlap coefficient from intersection stats.
78
+ * Overlap = intersection / min(sizeU, sizeV)
79
+ */
80
+ export declare function overlapFromIntersection(result: IntersectionResult): number;
81
+ /**
82
+ * Compute Hub Promoted from intersection stats.
83
+ * HP = intersection / min(sizeU, sizeV)
84
+ * Note: Same formula as Overlap coefficient
85
+ */
86
+ export declare function hubPromotedFromIntersection(result: IntersectionResult): number;
87
+ //# sourceMappingURL=logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/intersection/logic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logic.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.unit.test.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/intersection/logic.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * K-means clustering GPU kernel.
3
+ *
4
+ * @module gpu/kernels/kmeans
5
+ */
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/kmeans/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,34 @@
1
+ import { GraphwiseGPURoot } from '../../root';
2
+ /**
3
+ * K-means assignment kernel buffers.
4
+ *
5
+ * Buffer types are complex TypeGPU types that are difficult to express in TypeScript.
6
+ * Using `any` here is intentional to avoid verbose generic constraints.
7
+ */
8
+ export interface KMeansAssignBuffers {
9
+ /** Points buffer (3D vectors) */
10
+ readonly pointsBuffer: any;
11
+ /** Centroids buffer (3D vectors) */
12
+ readonly centroidsBuffer: any;
13
+ /** Assignments output buffer (cluster indices) */
14
+ readonly assignmentsBuffer: any;
15
+ /** Distances output buffer (distances to assigned centroid) */
16
+ readonly distancesBuffer: any;
17
+ }
18
+ /**
19
+ * Dispatch K-means assignment on GPU.
20
+ *
21
+ * @param root - TypeGPU root
22
+ * @param pointsBuffer - Buffer of 3D points
23
+ * @param centroidsBuffer - Buffer of centroids
24
+ * @param assignmentsBuffer - Output buffer for assignments
25
+ * @param distancesBuffer - Output buffer for distances
26
+ * @param pointCount - Number of points
27
+ * @param k - Number of centroids
28
+ */
29
+ export declare function dispatchKMeansAssign(root: GraphwiseGPURoot, pointsBuffer: any, centroidsBuffer: any, assignmentsBuffer: any, distancesBuffer: any, pointCount: number, k: number): void;
30
+ /**
31
+ * Create buffers for K-means assignment.
32
+ */
33
+ export declare function createKMeansAssignBuffers(root: GraphwiseGPURoot, points: readonly (readonly [number, number, number])[], centroids: readonly (readonly [number, number, number])[]): KMeansAssignBuffers;
34
+ //# sourceMappingURL=kernel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/kmeans/kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,iCAAiC;IAEjC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC;IAC3B,oCAAoC;IAEpC,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC;IAC9B,kDAAkD;IAElD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC;IAChC,+DAA+D;IAE/D,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC;CAC9B;AAkED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,gBAAgB,EAGtB,YAAY,EAAE,GAAG,EAEjB,eAAe,EAAE,GAAG,EAEpB,iBAAiB,EAAE,GAAG,EAEtB,eAAe,EAAE,GAAG,EACpB,UAAU,EAAE,MAAM,EAClB,CAAC,EAAE,MAAM,GACP,IAAI,CAuBN;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EACtD,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GACvD,mBAAmB,CAqCrB"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * CPU reference implementation for K-means operations.
3
+ *
4
+ * K-means has two main operations:
5
+ * 1. Assignment: assign each point to nearest centroid
6
+ * 2. Update: compute new centroids from assigned points
7
+ *
8
+ * The assignment step is the most parallelizable - each point independently
9
+ * computes distances to all centroids and finds the minimum.
10
+ *
11
+ * @module gpu/kernels/kmeans/logic
12
+ */
13
+ /**
14
+ * Point in K-dimensional space.
15
+ */
16
+ export interface Point {
17
+ /** Feature coordinates */
18
+ readonly coords: readonly number[];
19
+ }
20
+ /**
21
+ * Centroid with accumulated sum and count for incremental update.
22
+ */
23
+ export interface CentroidAccumulator {
24
+ /** Sum of coordinates for each dimension */
25
+ readonly sums: number[];
26
+ /** Number of points assigned to this centroid */
27
+ count: number;
28
+ }
29
+ /**
30
+ * Result of K-means assignment step.
31
+ */
32
+ export interface KMeansAssignmentResult {
33
+ /** Assignment index for each point (0 to k-1) */
34
+ readonly assignments: Uint32Array;
35
+ /** Distance to assigned centroid for each point */
36
+ readonly distances: Float32Array;
37
+ }
38
+ /**
39
+ * Compute squared Euclidean distance between two points.
40
+ *
41
+ * @param a - First point coordinates
42
+ * @param b - Second point coordinates
43
+ * @returns Squared Euclidean distance
44
+ */
45
+ export declare function squaredEuclideanDistance(a: readonly number[], b: readonly number[]): number;
46
+ /**
47
+ * Compute Euclidean distance between two points.
48
+ *
49
+ * @param a - First point coordinates
50
+ * @param b - Second point coordinates
51
+ * @returns Euclidean distance
52
+ */
53
+ export declare function euclideanDistance(a: readonly number[], b: readonly number[]): number;
54
+ /**
55
+ * Assign each point to its nearest centroid.
56
+ *
57
+ * For each point, computes distance to all centroids and assigns to the nearest.
58
+ * This is the main parallelizable operation in K-means.
59
+ *
60
+ * @param points - Array of points to assign
61
+ * @param centroids - Array of centroid coordinates
62
+ * @returns Assignment result with indices and distances
63
+ */
64
+ export declare function assignPointsToCentroids(points: readonly (readonly number[])[], centroids: readonly (readonly number[])[]): KMeansAssignmentResult;
65
+ /**
66
+ * Update centroids based on point assignments.
67
+ *
68
+ * Computes new centroids as the mean of all assigned points.
69
+ *
70
+ * @param points - Array of points
71
+ * @param assignments - Assignment index for each point
72
+ * @param k - Number of clusters
73
+ * @param dimensions - Number of dimensions per point
74
+ * @returns New centroid coordinates
75
+ */
76
+ export declare function updateCentroids(points: readonly (readonly number[])[], assignments: Uint32Array, k: number, dimensions: number): number[][];
77
+ /**
78
+ * Initialize centroids using K-means++ algorithm.
79
+ *
80
+ * Selects initial centroids that are spread out, leading to faster convergence.
81
+ *
82
+ * @param points - Array of points
83
+ * @param k - Number of centroids to select
84
+ * @param rng - Random number generator (0 to 1)
85
+ * @returns Initial centroid coordinates
86
+ */
87
+ export declare function initializeCentroidsKMeansPlusPlus(points: readonly (readonly number[])[], k: number, rng: () => number): number[][];
88
+ /**
89
+ * Run full K-means clustering.
90
+ *
91
+ * @param points - Array of points to cluster
92
+ * @param k - Number of clusters
93
+ * @param options - Configuration options
94
+ * @returns Final assignments and centroids
95
+ */
96
+ export declare function kmeans(points: readonly (readonly number[])[], k: number, options?: {
97
+ /** Maximum iterations (default: 100) */
98
+ readonly maxIterations?: number;
99
+ /** Convergence threshold for centroid movement (default: 1e-6) */
100
+ readonly tolerance?: number;
101
+ /** Random number generator (default: Math.random) */
102
+ readonly rng?: () => number;
103
+ /** Initial centroids (optional, uses k-means++ if not provided) */
104
+ readonly initialCentroids?: readonly (readonly number[])[];
105
+ }): {
106
+ assignments: Uint32Array;
107
+ centroids: number[][];
108
+ iterations: number;
109
+ converged: boolean;
110
+ };
111
+ //# sourceMappingURL=logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/kmeans/logic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,KAAK;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;CACd;AAED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,CAAC,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;CAC3D,GACC;IACF,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACnB,CAmEA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Unit tests for K-means CPU reference implementation.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=logic.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.unit.test.d.ts","sourceRoot":"","sources":["../../../../src/gpu/kernels/kmeans/logic.unit.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -1,4 +1,5 @@
1
1
  import { NodeData, EdgeData, NodeId, ReadableGraph } from '../graph';
2
+ import { MIVariantName } from '../ranking/mi/types';
2
3
  import { ComputeResult, GPUComputeOptions } from './types';
3
4
  /**
4
5
  * Degree statistics from histogram computation.
@@ -73,4 +74,55 @@ export declare function gpuBfsLevels<N extends NodeData, E extends EdgeData>(gra
73
74
  export declare function gpuDegreeHistogram<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, options?: GPUComputeOptions & {
74
75
  signal?: AbortSignal;
75
76
  }): Promise<ComputeResult<DegreeStats>>;
77
+ /**
78
+ * Result of batch MI computation.
79
+ */
80
+ export interface MIBatchResult {
81
+ /** MI scores for each pair */
82
+ readonly scores: Float32Array;
83
+ /** Raw intersection counts for each pair */
84
+ readonly intersections: Uint32Array;
85
+ /** Size of first neighbourhood for each pair */
86
+ readonly sizeUs: Uint32Array;
87
+ /** Size of second neighbourhood for each pair */
88
+ readonly sizeVs: Uint32Array;
89
+ }
90
+ /**
91
+ * Batch MI computation for multiple node pairs on GPU.
92
+ *
93
+ * For Jaccard-family variants, uses the intersection kernel for raw counts
94
+ * then applies the variant-specific formula on CPU.
95
+ *
96
+ * @param graph - Input graph
97
+ * @param pairs - Array of [u, v] node ID pairs
98
+ * @param variant - MI variant to compute (default: jaccard)
99
+ * @param options - Compute options
100
+ * @returns MI scores and raw intersection data for each pair
101
+ */
102
+ export declare function gpuMIBatch<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, pairs: readonly (readonly [NodeId, NodeId])[], variant?: MIVariantName, options?: GPUComputeOptions & {
103
+ signal?: AbortSignal;
104
+ }): Promise<ComputeResult<MIBatchResult>>;
105
+ /**
106
+ * Result of K-means assignment step.
107
+ */
108
+ export interface KMeansAssignResult {
109
+ /** Assignment index for each point (0 to k-1) */
110
+ readonly assignments: Uint32Array;
111
+ /** Squared distance to assigned centroid for each point */
112
+ readonly distances: Float32Array;
113
+ }
114
+ /**
115
+ * Assign points to nearest centroids using GPU.
116
+ *
117
+ * For each point, computes distance to all centroids and assigns to nearest.
118
+ * This is the main parallelizable operation in K-means clustering.
119
+ *
120
+ * @param points - Array of 3D points to assign
121
+ * @param centroids - Array of 3D centroid coordinates
122
+ * @param options - Compute options
123
+ * @returns Assignment indices and distances
124
+ */
125
+ export declare function gpuKMeansAssign(points: readonly (readonly [number, number, number])[], centroids: readonly (readonly [number, number, number])[], options?: GPUComputeOptions & {
126
+ signal?: AbortSignal;
127
+ }): Promise<ComputeResult<KMeansAssignResult>>;
76
128
  //# sourceMappingURL=operations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/gpu/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAU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e,CACpC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EACtD,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EACzD,OAAO,CAAC,EAAE,iBAAiB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACpD,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAyG5C"}
@@ -1,23 +1,26 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gpu = require("../gpu-Y6owRVMi.cjs");
3
2
  const require_adjacency_map = require("../adjacency-map-JqBnMNkF.cjs");
4
3
  require("../graph/index.cjs");
5
4
  const require_traversal = require("../traversal/index.cjs");
6
5
  const require_priority_queue = require("../priority-queue-BIiD1L0k.cjs");
7
6
  require("../structures/index.cjs");
8
7
  const require_utils = require("../utils-CDtCcsyF.cjs");
9
- const require_ops = require("../ops-djAsQQSh.cjs");
10
- const require_expansion = require("../expansion-DaTroIyv.cjs");
11
- const require_kmeans = require("../kmeans-B8x9D1kt.cjs");
8
+ const require_ops = require("../ops-paa1Nvlf.cjs");
9
+ const require_expansion = require("../expansion--UuRowv-.cjs");
10
+ const require_logic = require("../logic-Dbyfb_-7.cjs");
11
+ const require_kmeans = require("../kmeans-CZ7tJFYw.cjs");
12
12
  const require_utils$1 = require("../utils/index.cjs");
13
- const require_jaccard = require("../jaccard-Bys9_dGW.cjs");
14
- const require_ranking = require("../ranking-DVvajgUZ.cjs");
13
+ const require_jaccard = require("../jaccard-Bdw4B0i4.cjs");
14
+ const require_ranking = require("../ranking-pe5UaxKg.cjs");
15
15
  const require_ranking_mi = require("../ranking/mi/index.cjs");
16
+ const require_operations = require("../operations-D-RB67WP.cjs");
16
17
  const require_seeds = require("../seeds/index.cjs");
17
18
  const require_extraction = require("../extraction/index.cjs");
18
- require("../async/index.cjs");
19
+ const require_gpu = require("../gpu/index.cjs");
20
+ const require_async = require("../async/index.cjs");
19
21
  exports.AdjacencyMapGraph = require_adjacency_map.AdjacencyMapGraph;
20
- exports.GPUNotAvailableError = require_gpu.GPUNotAvailableError;
22
+ exports.CSRReadableGraph = require_gpu.CSRReadableGraph;
23
+ exports.GPUNotAvailableError = require_operations.GPUNotAvailableError;
21
24
  exports.PriorityQueue = require_priority_queue.PriorityQueue;
22
25
  exports._computeMean = require_kmeans._computeMean;
23
26
  exports.adamicAdar = require_ranking_mi.adamicAdar;
@@ -25,7 +28,7 @@ exports.adamicAdarAsync = require_ranking_mi.adamicAdarAsync;
25
28
  exports.adaptive = require_ranking_mi.adaptive;
26
29
  exports.adaptiveAsync = require_ranking_mi.adaptiveAsync;
27
30
  exports.approximateClusteringCoefficient = require_utils$1.approximateClusteringCoefficient;
28
- exports.assertWebGPUAvailable = require_gpu.assertWebGPUAvailable;
31
+ exports.assertWebGPUAvailable = require_operations.assertWebGPUAvailable;
29
32
  exports.base = require_expansion.base;
30
33
  exports.baseAsync = require_expansion.baseAsync;
31
34
  exports.batchClusteringCoefficients = require_utils$1.batchClusteringCoefficients;
@@ -34,16 +37,19 @@ exports.bfs = require_traversal.bfs;
34
37
  exports.bfsWithPath = require_traversal.bfsWithPath;
35
38
  exports.collectAsyncIterable = require_utils.collectAsyncIterable;
36
39
  exports.communicability = require_ranking.communicability;
40
+ exports.communicabilityAsync = require_ranking.communicabilityAsync;
37
41
  exports.computeJaccard = require_utils$1.computeJaccard;
38
42
  exports.computeTrussNumbers = require_extraction.computeTrussNumbers;
39
43
  exports.cosine = require_ranking_mi.cosine;
40
44
  exports.cosineAsync = require_ranking_mi.cosineAsync;
41
45
  exports.countEdgesOfType = require_utils$1.countEdgesOfType;
42
46
  exports.countNodesOfType = require_utils$1.countNodesOfType;
43
- exports.csrToTypedBuffers = require_gpu.csrToTypedBuffers;
47
+ exports.createFuseBatchPriority = require_expansion.createFuseBatchPriority;
48
+ exports.createSiftBatchPriority = require_expansion.createSiftBatchPriority;
49
+ exports.csrToTypedBuffers = require_logic.csrToTypedBuffers;
44
50
  exports.defaultYieldStrategy = require_utils.defaultYieldStrategy;
45
51
  exports.degreeSum = require_ranking.degreeSum;
46
- exports.detectWebGPU = require_gpu.detectWebGPU;
52
+ exports.detectWebGPU = require_operations.detectWebGPU;
47
53
  exports.dfs = require_traversal.dfs;
48
54
  exports.dfsPriority = require_expansion.dfsPriority;
49
55
  exports.dfsPriorityAsync = require_expansion.dfsPriorityAsync;
@@ -71,13 +77,17 @@ exports.frontierBalanced = require_expansion.frontierBalanced;
71
77
  exports.frontierBalancedAsync = require_expansion.frontierBalancedAsync;
72
78
  exports.fuse = require_expansion.fuse;
73
79
  exports.fuseAsync = require_expansion.fuseAsync;
80
+ exports.fuseBatchPriority = require_expansion.fuseBatchPriority;
81
+ exports.fuseWithBatchPriority = require_expansion.fuseWithBatchPriority;
74
82
  exports.getMotifName = require_extraction.getMotifName;
75
- exports.gpuBfsLevels = require_gpu.gpuBfsLevels;
76
- exports.gpuDegreeHistogram = require_gpu.gpuDegreeHistogram;
77
- exports.gpuJaccardBatch = require_gpu.gpuJaccardBatch;
78
- exports.gpuPageRank = require_gpu.gpuPageRank;
79
- exports.gpuSpmv = require_gpu.gpuSpmv;
80
- exports.graphToCSR = require_gpu.graphToCSR;
83
+ exports.gpuBfsLevels = require_operations.gpuBfsLevels;
84
+ exports.gpuDegreeHistogram = require_operations.gpuDegreeHistogram;
85
+ exports.gpuJaccardBatch = require_operations.gpuJaccardBatch;
86
+ exports.gpuKMeansAssign = require_operations.gpuKMeansAssign;
87
+ exports.gpuMIBatch = require_operations.gpuMIBatch;
88
+ exports.gpuPageRank = require_operations.gpuPageRank;
89
+ exports.gpuSpmv = require_operations.gpuSpmv;
90
+ exports.graphToCSR = require_logic.graphToCSR;
81
91
  exports.grasp = require_seeds.grasp;
82
92
  exports.hae = require_expansion.hae;
83
93
  exports.haeAsync = require_expansion.haeAsync;
@@ -86,14 +96,17 @@ exports.hubPromoted = require_ranking_mi.hubPromoted;
86
96
  exports.hubPromotedAsync = require_ranking_mi.hubPromotedAsync;
87
97
  exports.initGPU = require_gpu.initGPU;
88
98
  exports.initGPUFromDevice = require_gpu.initGPUFromDevice;
89
- exports.isWebGPUAvailable = require_gpu.isWebGPUAvailable;
99
+ exports.isWebGPUAvailable = require_operations.isWebGPUAvailable;
90
100
  exports.jaccard = require_jaccard.jaccard;
91
101
  exports.jaccardArithmetic = require_ranking.jaccardArithmetic;
92
102
  exports.jaccardAsync = require_jaccard.jaccardAsync;
93
103
  exports.kHop = require_expansion.kHop;
94
104
  exports.katz = require_ranking.katz;
105
+ exports.katzAsync = require_ranking.katzAsync;
95
106
  exports.lace = require_expansion.lace;
96
107
  exports.laceAsync = require_expansion.laceAsync;
108
+ exports.laceBatchPriority = require_expansion.laceBatchPriority;
109
+ exports.laceWithBatchPriority = require_expansion.laceWithBatchPriority;
97
110
  exports.localClusteringCoefficient = require_utils$1.localClusteringCoefficient;
98
111
  exports.localTypeEntropy = require_utils$1.localTypeEntropy;
99
112
  exports.maze = require_expansion.maze;
@@ -107,6 +120,8 @@ exports.zScoreNormalise = require_kmeans.normaliseFeatures;
107
120
  exports.normalisedEntropy = require_utils$1.normalisedEntropy;
108
121
  exports.notch = require_ranking_mi.notch;
109
122
  exports.notchAsync = require_ranking_mi.notchAsync;
123
+ exports.opBatchDegree = require_ops.opBatchDegree;
124
+ exports.opBatchNeighbours = require_ops.opBatchNeighbours;
110
125
  exports.opDegree = require_ops.opDegree;
111
126
  exports.opGetEdge = require_ops.opGetEdge;
112
127
  exports.opGetNode = require_ops.opGetNode;
@@ -117,6 +132,7 @@ exports.opYield = require_ops.opYield;
117
132
  exports.overlapCoefficient = require_ranking_mi.overlapCoefficient;
118
133
  exports.overlapCoefficientAsync = require_ranking_mi.overlapCoefficientAsync;
119
134
  exports.pagerank = require_ranking.pagerank;
135
+ exports.pagerankAsync = require_ranking.pagerankAsync;
120
136
  exports.parse = require_ranking.parse;
121
137
  exports.parseAsync = require_ranking.parseAsync;
122
138
  exports.pipe = require_expansion.pipe;
@@ -133,6 +149,7 @@ exports.resolveSyncOp = require_ops.resolveSyncOp;
133
149
  exports.resourceAllocation = require_ranking_mi.resourceAllocation;
134
150
  exports.resourceAllocationAsync = require_ranking_mi.resourceAllocationAsync;
135
151
  exports.runAsync = require_ops.runAsync;
152
+ exports.runBatched = require_async.runBatched;
136
153
  exports.runSync = require_ops.runSync;
137
154
  exports.sage = require_expansion.sage;
138
155
  exports.sageAsync = require_expansion.sageAsync;
@@ -142,6 +159,8 @@ exports.shannonEntropy = require_utils$1.shannonEntropy;
142
159
  exports.shortest = require_ranking.shortest;
143
160
  exports.sift = require_expansion.sift;
144
161
  exports.siftAsync = require_expansion.siftAsync;
162
+ exports.siftBatchPriority = require_expansion.siftBatchPriority;
163
+ exports.siftWithBatchPriority = require_expansion.siftWithBatchPriority;
145
164
  exports.skew = require_ranking_mi.skew;
146
165
  exports.skewAsync = require_ranking_mi.skewAsync;
147
166
  exports.sorensen = require_ranking_mi.sorensen;
@@ -156,4 +175,4 @@ exports.tideAsync = require_expansion.tideAsync;
156
175
  exports.warp = require_expansion.warp;
157
176
  exports.warpAsync = require_expansion.warpAsync;
158
177
  exports.widestPath = require_ranking.widestPath;
159
- exports.withBackend = require_gpu.withBackend;
178
+ exports.withBackend = require_operations.withBackend;
@@ -1,18 +1,20 @@
1
- import { a as gpuSpmv, c as initGPUFromDevice, d as isWebGPUAvailable, f as csrToTypedBuffers, i as gpuPageRank, l as assertWebGPUAvailable, m as GPUNotAvailableError, n as gpuDegreeHistogram, o as withBackend, p as graphToCSR, r as gpuJaccardBatch, s as initGPU, t as gpuBfsLevels, u as detectWebGPU } from "../gpu-CHiCN0wa.js";
2
1
  import { t as AdjacencyMapGraph } from "../adjacency-map-BtKzcuJq.js";
3
2
  import "../graph/index.js";
4
3
  import { bfs, bfsWithPath, dfs, dfsWithPath } from "../traversal/index.js";
5
4
  import { t as PriorityQueue } from "../priority-queue-CFDd5cBg.js";
6
5
  import "../structures/index.js";
7
6
  import { n as defaultYieldStrategy, t as collectAsyncIterable } from "../utils-BodeE2Mo.js";
8
- import { a as opNeighbours, c as resolveAsyncOp, d as runSync, i as opHasNode, l as resolveSyncOp, n as opGetEdge, o as opProgress, r as opGetNode, s as opYield, t as opDegree, u as runAsync } from "../ops-upIi6JIi.js";
9
- import { A as pipe, B as base, C as tideAsync, D as reachAsync, E as reach, F as haeAsync, I as dome, L as domeAsync, M as edge, N as edgeAsync, O as sage, P as hae, R as domeHighDegree, S as tide, T as mazeAsync, V as baseAsync, _ as fuseAsync, a as dfsPriorityFn, b as lace, c as frontierBalanced, d as standardBfsAsync, f as flux, g as fuse, h as siftAsync, i as dfsPriorityAsync, j as pipeAsync, k as sageAsync, l as frontierBalancedAsync, m as sift, n as kHop, o as randomPriority, p as fluxAsync, r as dfsPriority, s as randomPriorityAsync, t as randomWalk, u as standardBfs, v as warp, w as maze, x as laceAsync, y as warpAsync, z as domeHighDegreeAsync } from "../expansion-ClDhlMK8.js";
10
- import { n as miniBatchKMeans, r as normaliseFeatures, t as _computeMean } from "../kmeans-DKkL9rAN.js";
7
+ import { a as opGetNode, c as opProgress, d as resolveSyncOp, f as runAsync, i as opGetEdge, l as opYield, n as opBatchNeighbours, o as opHasNode, p as runSync, r as opDegree, s as opNeighbours, t as opBatchDegree, u as resolveAsyncOp } from "../ops-D5xZr4fV.js";
8
+ import { A as tide, B as edge, C as fuseWithBatchPriority, D as laceAsync, E as lace, F as reachAsync, G as domeAsync, H as hae, I as sage, J as base, K as domeHighDegree, L as sageAsync, M as maze, N as mazeAsync, O as laceBatchPriority, P as reach, R as pipe, S as fuseBatchPriority, T as warpAsync, U as haeAsync, V as edgeAsync, W as dome, Y as baseAsync, _ as siftBatchPriority, a as dfsPriorityFn, b as fuse, c as frontierBalanced, d as standardBfsAsync, f as flux, g as siftAsync, h as sift, i as dfsPriorityAsync, j as tideAsync, k as laceWithBatchPriority, l as frontierBalancedAsync, m as createSiftBatchPriority, n as kHop, o as randomPriority, p as fluxAsync, q as domeHighDegreeAsync, r as dfsPriority, s as randomPriorityAsync, t as randomWalk, u as standardBfs, v as siftWithBatchPriority, w as warp, x as fuseAsync, y as createFuseBatchPriority, z as pipeAsync } from "../expansion-CZLNK6Pr.js";
9
+ import { c as graphToCSR, s as csrToTypedBuffers } from "../logic-DyBzRg1A.js";
10
+ import { n as miniBatchKMeans, r as normaliseFeatures, t as _computeMean } from "../kmeans-DLrlrp6i.js";
11
11
  import { approximateClusteringCoefficient, batchClusteringCoefficients, computeJaccard, countEdgesOfType, countNodesOfType, entropyFromCounts, localClusteringCoefficient, localTypeEntropy, neighbourIntersection, neighbourOverlap, neighbourSet, normalisedEntropy, shannonEntropy } from "../utils/index.js";
12
- import { n as jaccardAsync, t as jaccard } from "../jaccard-3rCdilwm.js";
13
- import { a as katz, c as jaccardArithmetic, d as shortest, f as parse, i as communicability, l as widestPath, n as randomRanking, o as betweenness, p as parseAsync, r as resistanceDistance, s as pagerank, t as hittingTime, u as degreeSum } from "../ranking-3ez5m67U.js";
12
+ import { n as jaccardAsync, t as jaccard } from "../jaccard-BwC_NuQu.js";
13
+ import { a as communicabilityAsync, c as betweenness, d as jaccardArithmetic, f as widestPath, g as parseAsync, h as parse, i as communicability, l as pagerank, m as shortest, n as randomRanking, o as katz, p as degreeSum, r as resistanceDistance, s as katzAsync, t as hittingTime, u as pagerankAsync } from "../ranking-DOKDBcIR.js";
14
14
  import { adamicAdar, adamicAdarAsync, adaptive, adaptiveAsync, cosine, cosineAsync, etch, etchAsync, hubPromoted, hubPromotedAsync, notch, notchAsync, overlapCoefficient, overlapCoefficientAsync, resourceAllocation, resourceAllocationAsync, scale, scaleAsync, skew, skewAsync, sorensen, sorensenAsync, span, spanAsync } from "../ranking/mi/index.js";
15
+ import { a as gpuMIBatch, c as withBackend, d as detectWebGPU, f as isWebGPUAvailable, i as gpuKMeansAssign, l as GPUNotAvailableError, n as gpuDegreeHistogram, o as gpuPageRank, r as gpuJaccardBatch, s as gpuSpmv, t as gpuBfsLevels, u as assertWebGPUAvailable } from "../operations-D9otVlIH.js";
15
16
  import { grasp, stratified } from "../seeds/index.js";
16
17
  import { computeTrussNumbers, enumerateMotifs, enumerateMotifsWithInstances, extractEgoNetwork, extractInducedSubgraph, extractKCore, extractKTruss, filterSubgraph, getMotifName } from "../extraction/index.js";
17
- import "../async/index.js";
18
- export { AdjacencyMapGraph, GPUNotAvailableError, PriorityQueue, _computeMean, adamicAdar, adamicAdarAsync, adaptive, adaptiveAsync, approximateClusteringCoefficient, assertWebGPUAvailable, base, baseAsync, batchClusteringCoefficients, betweenness, bfs, bfsWithPath, collectAsyncIterable, communicability, computeJaccard, computeTrussNumbers, cosine, cosineAsync, countEdgesOfType, countNodesOfType, csrToTypedBuffers, defaultYieldStrategy, degreeSum, detectWebGPU, dfs, dfsPriority, dfsPriorityAsync, dfsPriorityFn, dfsWithPath, dome, domeAsync, domeHighDegree, domeHighDegreeAsync, edge, edgeAsync, entropyFromCounts, enumerateMotifs, enumerateMotifsWithInstances, etch, etchAsync, extractEgoNetwork, extractInducedSubgraph, extractKCore, extractKTruss, filterSubgraph, flux, fluxAsync, frontierBalanced, frontierBalancedAsync, fuse, fuseAsync, getMotifName, gpuBfsLevels, gpuDegreeHistogram, gpuJaccardBatch, gpuPageRank, gpuSpmv, graphToCSR, grasp, hae, haeAsync, hittingTime, hubPromoted, hubPromotedAsync, initGPU, initGPUFromDevice, isWebGPUAvailable, jaccard, jaccardArithmetic, jaccardAsync, kHop, katz, lace, laceAsync, localClusteringCoefficient, localTypeEntropy, maze, mazeAsync, miniBatchKMeans, neighbourIntersection, neighbourOverlap, neighbourSet, normaliseFeatures, normaliseFeatures as zScoreNormalise, normalisedEntropy, notch, notchAsync, opDegree, opGetEdge, opGetNode, opHasNode, opNeighbours, opProgress, opYield, overlapCoefficient, overlapCoefficientAsync, pagerank, parse, parseAsync, pipe, pipeAsync, randomPriority, randomPriorityAsync, randomRanking, randomWalk, reach, reachAsync, resistanceDistance, resolveAsyncOp, resolveSyncOp, resourceAllocation, resourceAllocationAsync, runAsync, runSync, sage, sageAsync, scale, scaleAsync, shannonEntropy, shortest, sift, siftAsync, skew, skewAsync, sorensen, sorensenAsync, span, spanAsync, standardBfs, standardBfsAsync, stratified, tide, tideAsync, warp, warpAsync, widestPath, withBackend };
18
+ import { CSRReadableGraph, initGPU, initGPUFromDevice } from "../gpu/index.js";
19
+ import { runBatched } from "../async/index.js";
20
+ export { AdjacencyMapGraph, CSRReadableGraph, GPUNotAvailableError, PriorityQueue, _computeMean, adamicAdar, adamicAdarAsync, adaptive, adaptiveAsync, approximateClusteringCoefficient, assertWebGPUAvailable, base, baseAsync, batchClusteringCoefficients, betweenness, bfs, bfsWithPath, collectAsyncIterable, communicability, communicabilityAsync, computeJaccard, computeTrussNumbers, cosine, cosineAsync, countEdgesOfType, countNodesOfType, createFuseBatchPriority, createSiftBatchPriority, csrToTypedBuffers, defaultYieldStrategy, degreeSum, detectWebGPU, dfs, dfsPriority, dfsPriorityAsync, dfsPriorityFn, dfsWithPath, dome, domeAsync, domeHighDegree, domeHighDegreeAsync, edge, edgeAsync, entropyFromCounts, enumerateMotifs, enumerateMotifsWithInstances, etch, etchAsync, extractEgoNetwork, extractInducedSubgraph, extractKCore, extractKTruss, filterSubgraph, flux, fluxAsync, frontierBalanced, frontierBalancedAsync, fuse, fuseAsync, fuseBatchPriority, fuseWithBatchPriority, getMotifName, gpuBfsLevels, gpuDegreeHistogram, gpuJaccardBatch, gpuKMeansAssign, gpuMIBatch, gpuPageRank, gpuSpmv, graphToCSR, grasp, hae, haeAsync, hittingTime, hubPromoted, hubPromotedAsync, initGPU, initGPUFromDevice, isWebGPUAvailable, jaccard, jaccardArithmetic, jaccardAsync, kHop, katz, katzAsync, lace, laceAsync, laceBatchPriority, laceWithBatchPriority, localClusteringCoefficient, localTypeEntropy, maze, mazeAsync, miniBatchKMeans, neighbourIntersection, neighbourOverlap, neighbourSet, normaliseFeatures, normaliseFeatures as zScoreNormalise, normalisedEntropy, notch, notchAsync, opBatchDegree, opBatchNeighbours, opDegree, opGetEdge, opGetNode, opHasNode, opNeighbours, opProgress, opYield, overlapCoefficient, overlapCoefficientAsync, pagerank, pagerankAsync, parse, parseAsync, pipe, pipeAsync, randomPriority, randomPriorityAsync, randomRanking, randomWalk, reach, reachAsync, resistanceDistance, resolveAsyncOp, resolveSyncOp, resourceAllocation, resourceAllocationAsync, runAsync, runBatched, runSync, sage, sageAsync, scale, scaleAsync, shannonEntropy, shortest, sift, siftAsync, siftBatchPriority, siftWithBatchPriority, skew, skewAsync, sorensen, sorensenAsync, span, spanAsync, standardBfs, standardBfsAsync, stratified, tide, tideAsync, warp, warpAsync, widestPath, withBackend };
@@ -47,4 +47,4 @@ Object.defineProperty(exports, "jaccardAsync", {
47
47
  }
48
48
  });
49
49
 
50
- //# sourceMappingURL=jaccard-Bys9_dGW.cjs.map
50
+ //# sourceMappingURL=jaccard-Bdw4B0i4.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"jaccard-Bys9_dGW.cjs","names":[],"sources":["../src/ranking/mi/jaccard.ts"],"sourcesContent":["/**\n * Jaccard similarity coefficient for edge salience.\n *\n * Measures overlap between neighbourhoods of connected nodes:\n * MI(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)|\n *\n * Range: [0, 1]\n * - 0: No shared neighbours (low salience)\n * - 1: Identical neighbourhoods (high salience)\n */\n\nimport type { NodeId, NodeData, EdgeData, ReadableGraph } from \"../../graph\";\nimport type { AsyncReadableGraph } from \"../../graph/async-interfaces\";\nimport { computeJaccard } from \"../../utils\";\nimport { collectAsyncIterable } from \"../../async/utils\";\nimport type { MIConfig } from \"./types\";\n\n/**\n * Compute Jaccard similarity between neighbourhoods of two nodes.\n *\n * @param graph - Source graph\n * @param source - Source node ID\n * @param target - Target node ID\n * @param config - Optional configuration\n * @returns Jaccard coefficient in [0, 1]\n */\nexport function jaccard<N extends NodeData, E extends EdgeData>(\n\tgraph: ReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): number {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\tconst {\n\t\tjaccard: jaccardScore,\n\t\tsourceNeighbours,\n\t\ttargetNeighbours,\n\t} = computeJaccard(graph, source, target);\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (sourceNeighbours.size === 0 && targetNeighbours.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Apply epsilon floor for numerical stability\n\treturn Math.max(epsilon, jaccardScore);\n}\n\n/**\n * Async variant of Jaccard similarity for use with async graph data sources.\n *\n * Fetches both neighbourhoods concurrently, then applies the same formula.\n */\nexport async function jaccardAsync<N extends NodeData, E extends EdgeData>(\n\tgraph: AsyncReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): Promise<number> {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\t// Fetch both neighbourhoods in parallel\n\tconst [sourceNeighboursArr, targetNeighboursArr] = await Promise.all([\n\t\tcollectAsyncIterable(graph.neighbours(source)),\n\t\tcollectAsyncIterable(graph.neighbours(target)),\n\t]);\n\n\tconst srcSet = new Set(sourceNeighboursArr.filter((n) => n !== target));\n\tconst tgtSet = new Set(targetNeighboursArr.filter((n) => n !== source));\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (srcSet.size === 0 && tgtSet.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Compute intersection and union sizes\n\tlet intersection = 0;\n\tfor (const n of srcSet) {\n\t\tif (tgtSet.has(n)) intersection++;\n\t}\n\tconst union = srcSet.size + tgtSet.size - intersection;\n\n\tconst jaccardScore = union > 0 ? intersection / union : 0;\n\n\treturn Math.max(epsilon, jaccardScore);\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,QACf,OACA,QACA,QACA,QACS;CACT,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAExC,MAAM,EACL,SAAS,cACT,kBACA,qBACG,gBAAA,eAAe,OAAO,QAAQ,OAAO;AAGzC,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,EAC5D,QAAO;AAIR,QAAO,KAAK,IAAI,SAAS,aAAa;;;;;;;AAQvC,eAAsB,aACrB,OACA,QACA,QACA,QACkB;CAClB,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAGxC,MAAM,CAAC,qBAAqB,uBAAuB,MAAM,QAAQ,IAAI,CACpE,cAAA,qBAAqB,MAAM,WAAW,OAAO,CAAC,EAC9C,cAAA,qBAAqB,MAAM,WAAW,OAAO,CAAC,CAC9C,CAAC;CAEF,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;CACvE,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;AAGvE,KAAI,OAAO,SAAS,KAAK,OAAO,SAAS,EACxC,QAAO;CAIR,IAAI,eAAe;AACnB,MAAK,MAAM,KAAK,OACf,KAAI,OAAO,IAAI,EAAE,CAAE;CAEpB,MAAM,QAAQ,OAAO,OAAO,OAAO,OAAO;CAE1C,MAAM,eAAe,QAAQ,IAAI,eAAe,QAAQ;AAExD,QAAO,KAAK,IAAI,SAAS,aAAa"}
1
+ {"version":3,"file":"jaccard-Bdw4B0i4.cjs","names":[],"sources":["../src/ranking/mi/jaccard.ts"],"sourcesContent":["/**\n * Jaccard similarity coefficient for edge salience.\n *\n * Measures overlap between neighbourhoods of connected nodes:\n * MI(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)|\n *\n * Range: [0, 1]\n * - 0: No shared neighbours (low salience)\n * - 1: Identical neighbourhoods (high salience)\n */\n\nimport type { NodeId, NodeData, EdgeData, ReadableGraph } from \"../../graph\";\nimport type { AsyncReadableGraph } from \"../../graph/async-interfaces\";\nimport { computeJaccard } from \"../../utils\";\nimport { collectAsyncIterable } from \"../../async/utils\";\nimport type { MIConfig } from \"./types\";\n\n/**\n * Compute Jaccard similarity between neighbourhoods of two nodes.\n *\n * @param graph - Source graph\n * @param source - Source node ID\n * @param target - Target node ID\n * @param config - Optional configuration\n * @returns Jaccard coefficient in [0, 1]\n */\nexport function jaccard<N extends NodeData, E extends EdgeData>(\n\tgraph: ReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): number {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\tconst {\n\t\tjaccard: jaccardScore,\n\t\tsourceNeighbours,\n\t\ttargetNeighbours,\n\t} = computeJaccard(graph, source, target);\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (sourceNeighbours.size === 0 && targetNeighbours.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Apply epsilon floor for numerical stability\n\treturn Math.max(epsilon, jaccardScore);\n}\n\n/**\n * Async variant of Jaccard similarity for use with async graph data sources.\n *\n * Fetches both neighbourhoods concurrently, then applies the same formula.\n */\nexport async function jaccardAsync<N extends NodeData, E extends EdgeData>(\n\tgraph: AsyncReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): Promise<number> {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\t// Fetch both neighbourhoods in parallel\n\tconst [sourceNeighboursArr, targetNeighboursArr] = await Promise.all([\n\t\tcollectAsyncIterable(graph.neighbours(source)),\n\t\tcollectAsyncIterable(graph.neighbours(target)),\n\t]);\n\n\tconst srcSet = new Set(sourceNeighboursArr.filter((n) => n !== target));\n\tconst tgtSet = new Set(targetNeighboursArr.filter((n) => n !== source));\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (srcSet.size === 0 && tgtSet.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Compute intersection and union sizes\n\tlet intersection = 0;\n\tfor (const n of srcSet) {\n\t\tif (tgtSet.has(n)) intersection++;\n\t}\n\tconst union = srcSet.size + tgtSet.size - intersection;\n\n\tconst jaccardScore = union > 0 ? intersection / union : 0;\n\n\treturn Math.max(epsilon, jaccardScore);\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,QACf,OACA,QACA,QACA,QACS;CACT,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAExC,MAAM,EACL,SAAS,cACT,kBACA,qBACG,gBAAA,eAAe,OAAO,QAAQ,OAAO;AAGzC,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,EAC5D,QAAO;AAIR,QAAO,KAAK,IAAI,SAAS,aAAa;;;;;;;AAQvC,eAAsB,aACrB,OACA,QACA,QACA,QACkB;CAClB,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAGxC,MAAM,CAAC,qBAAqB,uBAAuB,MAAM,QAAQ,IAAI,CACpE,cAAA,qBAAqB,MAAM,WAAW,OAAO,CAAC,EAC9C,cAAA,qBAAqB,MAAM,WAAW,OAAO,CAAC,CAC9C,CAAC;CAEF,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;CACvE,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;AAGvE,KAAI,OAAO,SAAS,KAAK,OAAO,SAAS,EACxC,QAAO;CAIR,IAAI,eAAe;AACnB,MAAK,MAAM,KAAK,OACf,KAAI,OAAO,IAAI,EAAE,CAAE;CAEpB,MAAM,QAAQ,OAAO,OAAO,OAAO,OAAO;CAE1C,MAAM,eAAe,QAAQ,IAAI,eAAe,QAAQ;AAExD,QAAO,KAAK,IAAI,SAAS,aAAa"}
@@ -36,4 +36,4 @@ async function jaccardAsync(graph, source, target, config) {
36
36
  //#endregion
37
37
  export { jaccardAsync as n, jaccard as t };
38
38
 
39
- //# sourceMappingURL=jaccard-3rCdilwm.js.map
39
+ //# sourceMappingURL=jaccard-BwC_NuQu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jaccard-3rCdilwm.js","names":[],"sources":["../src/ranking/mi/jaccard.ts"],"sourcesContent":["/**\n * Jaccard similarity coefficient for edge salience.\n *\n * Measures overlap between neighbourhoods of connected nodes:\n * MI(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)|\n *\n * Range: [0, 1]\n * - 0: No shared neighbours (low salience)\n * - 1: Identical neighbourhoods (high salience)\n */\n\nimport type { NodeId, NodeData, EdgeData, ReadableGraph } from \"../../graph\";\nimport type { AsyncReadableGraph } from \"../../graph/async-interfaces\";\nimport { computeJaccard } from \"../../utils\";\nimport { collectAsyncIterable } from \"../../async/utils\";\nimport type { MIConfig } from \"./types\";\n\n/**\n * Compute Jaccard similarity between neighbourhoods of two nodes.\n *\n * @param graph - Source graph\n * @param source - Source node ID\n * @param target - Target node ID\n * @param config - Optional configuration\n * @returns Jaccard coefficient in [0, 1]\n */\nexport function jaccard<N extends NodeData, E extends EdgeData>(\n\tgraph: ReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): number {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\tconst {\n\t\tjaccard: jaccardScore,\n\t\tsourceNeighbours,\n\t\ttargetNeighbours,\n\t} = computeJaccard(graph, source, target);\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (sourceNeighbours.size === 0 && targetNeighbours.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Apply epsilon floor for numerical stability\n\treturn Math.max(epsilon, jaccardScore);\n}\n\n/**\n * Async variant of Jaccard similarity for use with async graph data sources.\n *\n * Fetches both neighbourhoods concurrently, then applies the same formula.\n */\nexport async function jaccardAsync<N extends NodeData, E extends EdgeData>(\n\tgraph: AsyncReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): Promise<number> {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\t// Fetch both neighbourhoods in parallel\n\tconst [sourceNeighboursArr, targetNeighboursArr] = await Promise.all([\n\t\tcollectAsyncIterable(graph.neighbours(source)),\n\t\tcollectAsyncIterable(graph.neighbours(target)),\n\t]);\n\n\tconst srcSet = new Set(sourceNeighboursArr.filter((n) => n !== target));\n\tconst tgtSet = new Set(targetNeighboursArr.filter((n) => n !== source));\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (srcSet.size === 0 && tgtSet.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Compute intersection and union sizes\n\tlet intersection = 0;\n\tfor (const n of srcSet) {\n\t\tif (tgtSet.has(n)) intersection++;\n\t}\n\tconst union = srcSet.size + tgtSet.size - intersection;\n\n\tconst jaccardScore = union > 0 ? intersection / union : 0;\n\n\treturn Math.max(epsilon, jaccardScore);\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,QACf,OACA,QACA,QACA,QACS;CACT,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAExC,MAAM,EACL,SAAS,cACT,kBACA,qBACG,eAAe,OAAO,QAAQ,OAAO;AAGzC,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,EAC5D,QAAO;AAIR,QAAO,KAAK,IAAI,SAAS,aAAa;;;;;;;AAQvC,eAAsB,aACrB,OACA,QACA,QACA,QACkB;CAClB,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAGxC,MAAM,CAAC,qBAAqB,uBAAuB,MAAM,QAAQ,IAAI,CACpE,qBAAqB,MAAM,WAAW,OAAO,CAAC,EAC9C,qBAAqB,MAAM,WAAW,OAAO,CAAC,CAC9C,CAAC;CAEF,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;CACvE,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;AAGvE,KAAI,OAAO,SAAS,KAAK,OAAO,SAAS,EACxC,QAAO;CAIR,IAAI,eAAe;AACnB,MAAK,MAAM,KAAK,OACf,KAAI,OAAO,IAAI,EAAE,CAAE;CAEpB,MAAM,QAAQ,OAAO,OAAO,OAAO,OAAO;CAE1C,MAAM,eAAe,QAAQ,IAAI,eAAe,QAAQ;AAExD,QAAO,KAAK,IAAI,SAAS,aAAa"}
1
+ {"version":3,"file":"jaccard-BwC_NuQu.js","names":[],"sources":["../src/ranking/mi/jaccard.ts"],"sourcesContent":["/**\n * Jaccard similarity coefficient for edge salience.\n *\n * Measures overlap between neighbourhoods of connected nodes:\n * MI(u,v) = |N(u) ∩ N(v)| / |N(u) ∪ N(v)|\n *\n * Range: [0, 1]\n * - 0: No shared neighbours (low salience)\n * - 1: Identical neighbourhoods (high salience)\n */\n\nimport type { NodeId, NodeData, EdgeData, ReadableGraph } from \"../../graph\";\nimport type { AsyncReadableGraph } from \"../../graph/async-interfaces\";\nimport { computeJaccard } from \"../../utils\";\nimport { collectAsyncIterable } from \"../../async/utils\";\nimport type { MIConfig } from \"./types\";\n\n/**\n * Compute Jaccard similarity between neighbourhoods of two nodes.\n *\n * @param graph - Source graph\n * @param source - Source node ID\n * @param target - Target node ID\n * @param config - Optional configuration\n * @returns Jaccard coefficient in [0, 1]\n */\nexport function jaccard<N extends NodeData, E extends EdgeData>(\n\tgraph: ReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): number {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\tconst {\n\t\tjaccard: jaccardScore,\n\t\tsourceNeighbours,\n\t\ttargetNeighbours,\n\t} = computeJaccard(graph, source, target);\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (sourceNeighbours.size === 0 && targetNeighbours.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Apply epsilon floor for numerical stability\n\treturn Math.max(epsilon, jaccardScore);\n}\n\n/**\n * Async variant of Jaccard similarity for use with async graph data sources.\n *\n * Fetches both neighbourhoods concurrently, then applies the same formula.\n */\nexport async function jaccardAsync<N extends NodeData, E extends EdgeData>(\n\tgraph: AsyncReadableGraph<N, E>,\n\tsource: NodeId,\n\ttarget: NodeId,\n\tconfig?: MIConfig,\n): Promise<number> {\n\tconst { epsilon = 1e-10 } = config ?? {};\n\n\t// Fetch both neighbourhoods in parallel\n\tconst [sourceNeighboursArr, targetNeighboursArr] = await Promise.all([\n\t\tcollectAsyncIterable(graph.neighbours(source)),\n\t\tcollectAsyncIterable(graph.neighbours(target)),\n\t]);\n\n\tconst srcSet = new Set(sourceNeighboursArr.filter((n) => n !== target));\n\tconst tgtSet = new Set(targetNeighboursArr.filter((n) => n !== source));\n\n\t// Return 0 only when the union is empty (no neighbours on either side)\n\tif (srcSet.size === 0 && tgtSet.size === 0) {\n\t\treturn 0;\n\t}\n\n\t// Compute intersection and union sizes\n\tlet intersection = 0;\n\tfor (const n of srcSet) {\n\t\tif (tgtSet.has(n)) intersection++;\n\t}\n\tconst union = srcSet.size + tgtSet.size - intersection;\n\n\tconst jaccardScore = union > 0 ? intersection / union : 0;\n\n\treturn Math.max(epsilon, jaccardScore);\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAgB,QACf,OACA,QACA,QACA,QACS;CACT,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAExC,MAAM,EACL,SAAS,cACT,kBACA,qBACG,eAAe,OAAO,QAAQ,OAAO;AAGzC,KAAI,iBAAiB,SAAS,KAAK,iBAAiB,SAAS,EAC5D,QAAO;AAIR,QAAO,KAAK,IAAI,SAAS,aAAa;;;;;;;AAQvC,eAAsB,aACrB,OACA,QACA,QACA,QACkB;CAClB,MAAM,EAAE,UAAU,UAAU,UAAU,EAAE;CAGxC,MAAM,CAAC,qBAAqB,uBAAuB,MAAM,QAAQ,IAAI,CACpE,qBAAqB,MAAM,WAAW,OAAO,CAAC,EAC9C,qBAAqB,MAAM,WAAW,OAAO,CAAC,CAC9C,CAAC;CAEF,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;CACvE,MAAM,SAAS,IAAI,IAAI,oBAAoB,QAAQ,MAAM,MAAM,OAAO,CAAC;AAGvE,KAAI,OAAO,SAAS,KAAK,OAAO,SAAS,EACxC,QAAO;CAIR,IAAI,eAAe;AACnB,MAAK,MAAM,KAAK,OACf,KAAI,OAAO,IAAI,EAAE,CAAE;CAEpB,MAAM,QAAQ,OAAO,OAAO,OAAO,OAAO;CAE1C,MAAM,eAAe,QAAQ,IAAI,eAAe,QAAQ;AAExD,QAAO,KAAK,IAAI,SAAS,aAAa"}