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
@@ -1,3 +1,5 @@
1
+ import { ComputeBackend } from '../gpu/types';
2
+ import { GraphwiseGPURoot } from '../gpu/root';
1
3
  import { NodeId, NodeData, EdgeData, ReadableGraph } from '../graph';
2
4
  /**
3
5
  * Role of a seed node in expansion.
@@ -38,6 +40,30 @@ export interface PriorityContext<N extends NodeData = NodeData, E extends EdgeDa
38
40
  * Lower values = higher priority (expanded first).
39
41
  */
40
42
  export type PriorityFunction<N extends NodeData = NodeData, E extends EdgeData = EdgeData> = (nodeId: NodeId, context: PriorityContext<N, E>) => number;
43
+ /**
44
+ * Context provided to batch priority functions for batch processing.
45
+ */
46
+ export interface BatchPriorityContext<N extends NodeData = NodeData, E extends EdgeData = EdgeData> {
47
+ /** The source graph */
48
+ readonly graph: ReadableGraph<N, E>;
49
+ /** Set of all visited nodes */
50
+ readonly visited: ReadonlySet<NodeId>;
51
+ /** Map of node ID to frontier index that visited it */
52
+ readonly visitedByFrontier: ReadonlyMap<NodeId, number>;
53
+ /** Frontier ID for the current batch */
54
+ readonly frontierId: number;
55
+ /** Paths discovered so far (for REACH-style algorithms) */
56
+ readonly discoveredPaths: readonly ExpansionPath[];
57
+ /** Optional GPU backend selection */
58
+ readonly backend?: ComputeBackend;
59
+ /** Optional TypeGPU root for GPU acceleration */
60
+ readonly root?: GraphwiseGPURoot;
61
+ }
62
+ /**
63
+ * Function that computes priorities for multiple nodes at once.
64
+ * Returns a Map of node ID to priority (lower values = higher priority).
65
+ */
66
+ export type BatchPriorityFunction<N extends NodeData = NodeData, E extends EdgeData = EdgeData> = (candidates: readonly NodeId[], context: BatchPriorityContext<N, E>) => ReadonlyMap<NodeId, number>;
41
67
  /**
42
68
  * A path discovered by bidirectional expansion.
43
69
  */
@@ -97,6 +123,10 @@ export interface ExpansionConfig<N extends NodeData = NodeData, E extends EdgeDa
97
123
  readonly maxPaths?: number;
98
124
  /** Custom priority function */
99
125
  readonly priority?: PriorityFunction<N, E>;
126
+ /** Custom batch priority function for batch processing */
127
+ readonly batchPriority?: BatchPriorityFunction<N, E>;
128
+ /** Batch priority function for GPU acceleration */
129
+ readonly batchPriorityGPU?: BatchPriorityFunction<N, E>;
100
130
  /** Random seed for reproducibility */
101
131
  readonly seed?: number;
102
132
  /** Enable debug logging */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/expansion/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,IAAI;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAC/B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAE7B,uBAAuB;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,C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QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,mDAAmD;IACnD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,sCAAsC;IACtC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -1,7 +1,8 @@
1
1
  const require_priority_queue = require("./priority-queue-BIiD1L0k.cjs");
2
- const require_ops = require("./ops-djAsQQSh.cjs");
2
+ const require_ops = require("./ops-paa1Nvlf.cjs");
3
+ const require_logic = require("./logic-Dbyfb_-7.cjs");
3
4
  const require_utils = require("./utils/index.cjs");
4
- const require_jaccard = require("./jaccard-Bys9_dGW.cjs");
5
+ const require_jaccard = require("./jaccard-Bdw4B0i4.cjs");
5
6
  //#region src/expansion/base-helpers.ts
6
7
  /**
7
8
  * Check whether expansion should continue given current progress.
@@ -130,7 +131,7 @@ function degreePriority(_nodeId, context) {
130
131
  */
131
132
  function* baseCore(graphMeta, seeds, config, graphRef) {
132
133
  const startTime = performance.now();
133
- const { maxNodes = 0, maxIterations = 0, maxPaths = 0, priority = degreePriority, debug = false } = config ?? {};
134
+ const { maxNodes = 0, maxIterations = 0, maxPaths = 0, priority = degreePriority, batchPriority, debug = false } = config ?? {};
134
135
  if (seeds.length === 0) return emptyResult$2("base", startTime);
135
136
  const numFrontiers = seeds.length;
136
137
  const allVisited = /* @__PURE__ */ new Set();
@@ -225,8 +226,30 @@ function* baseCore(graphMeta, seeds, config, graphRef) {
225
226
  sampledEdgeMap.set(s, targets);
226
227
  }
227
228
  targets.add(t);
229
+ }
230
+ const unvisitedNeighbours = [];
231
+ for (const neighbour of neighbours) {
228
232
  const fv = visitedByFrontier[activeFrontier];
229
233
  if (fv === void 0 || fv.has(neighbour)) continue;
234
+ unvisitedNeighbours.push(neighbour);
235
+ }
236
+ if (unvisitedNeighbours.length > 0) if (batchPriority) {
237
+ const priorities = batchPriority(unvisitedNeighbours, {
238
+ graph: graphRef ?? makeNoGraphSentinel(),
239
+ visited: allVisited,
240
+ visitedByFrontier: combinedVisited,
241
+ frontierId: activeFrontier,
242
+ discoveredPaths
243
+ });
244
+ for (const neighbour of unvisitedNeighbours) {
245
+ const priority = priorities.get(neighbour);
246
+ if (priority !== void 0) queue.push({
247
+ nodeId: neighbour,
248
+ frontierIndex: activeFrontier,
249
+ predecessor: nodeId
250
+ }, priority);
251
+ }
252
+ } else for (const neighbour of unvisitedNeighbours) {
230
253
  const neighbourDegree = yield* require_ops.opDegree(neighbour);
231
254
  const neighbourPriority = priority(neighbour, buildPriorityContext(neighbour, activeFrontier, combinedVisited, allVisited, discoveredPaths, iterations + 1, neighbourDegree, graphRef));
232
255
  queue.push({
@@ -585,6 +608,73 @@ async function pipeAsync(graph, seeds, config) {
585
608
  //#endregion
586
609
  //#region src/expansion/priority-helpers.ts
587
610
  /**
611
+ * Compute average MI between each candidate and a set of reference nodes.
612
+ *
613
+ * Uses batch intersection computation for efficiency. Returns a Map of
614
+ * candidate ID to average MI score.
615
+ *
616
+ * @param graph - Source graph
617
+ * @param candidates - Candidate node IDs to compute priorities for
618
+ * @param referenceNodes - Reference nodes to compute MI against
619
+ * @returns Map of candidate ID to average MI score
620
+ */
621
+ function batchAvgMI(graph, candidates, referenceNodes) {
622
+ const result = /* @__PURE__ */ new Map();
623
+ if (candidates.length === 0 || referenceNodes.size === 0) {
624
+ for (const candidate of candidates) result.set(candidate, 0);
625
+ return result;
626
+ }
627
+ const { csr, indexMap } = require_logic.graphToCSR(graph);
628
+ const { nodeToIndex } = indexMap;
629
+ const pairs = [];
630
+ const pairToCandidate = /* @__PURE__ */ new Map();
631
+ const referenceArray = Array.from(referenceNodes);
632
+ for (const candidate of candidates) {
633
+ const candIdx = nodeToIndex.get(candidate);
634
+ if (candIdx === void 0) {
635
+ result.set(candidate, 0);
636
+ continue;
637
+ }
638
+ const startIdx = pairs.length;
639
+ for (const refNode of referenceArray) {
640
+ const refIdx = nodeToIndex.get(refNode);
641
+ if (refIdx !== void 0 && refIdx !== candIdx) pairs.push([candIdx, refIdx]);
642
+ }
643
+ const endIdx = pairs.length;
644
+ for (let i = startIdx; i < endIdx; i++) pairToCandidate.set(i, candidate);
645
+ }
646
+ if (pairs.length === 0) {
647
+ for (const candidate of candidates) if (!result.has(candidate)) result.set(candidate, 0);
648
+ return result;
649
+ }
650
+ const { intersections, sizeUs, sizeVs } = require_logic.intersectionBatch(csr.rowOffsets, csr.colIndices, pairs);
651
+ const candidateScores = /* @__PURE__ */ new Map();
652
+ for (let i = 0; i < pairs.length; i++) {
653
+ const candidate = pairToCandidate.get(i);
654
+ if (candidate === void 0) continue;
655
+ const mi = require_logic.jaccardFromIntersection({
656
+ intersection: intersections[i] ?? 0,
657
+ sizeU: sizeUs[i] ?? 0,
658
+ sizeV: sizeVs[i] ?? 0
659
+ });
660
+ const existing = candidateScores.get(candidate);
661
+ if (existing === void 0) candidateScores.set(candidate, {
662
+ total: mi,
663
+ count: 1
664
+ });
665
+ else {
666
+ existing.total += mi;
667
+ existing.count++;
668
+ }
669
+ }
670
+ for (const candidate of candidates) {
671
+ const scores = candidateScores.get(candidate);
672
+ if (scores === void 0 || scores.count === 0) result.set(candidate, 0);
673
+ else result.set(candidate, scores.total / scores.count);
674
+ }
675
+ return result;
676
+ }
677
+ /**
588
678
  * Compute the average mutual information between a node and all visited
589
679
  * nodes in the same frontier.
590
680
  *
@@ -608,6 +698,17 @@ function avgFrontierMI(graph, nodeId, context, mi) {
608
698
  return count > 0 ? total / count : 0;
609
699
  }
610
700
  /**
701
+ * Get nodes visited by the same frontier (for batch MI computation).
702
+ *
703
+ * @param context - Batch priority context
704
+ * @returns Set of node IDs visited by the same frontier
705
+ */
706
+ function getSameFrontierVisited(context) {
707
+ const result = /* @__PURE__ */ new Set();
708
+ for (const [nodeId, frontierIdx] of context.visitedByFrontier) if (frontierIdx === context.frontierId) result.add(nodeId);
709
+ return result;
710
+ }
711
+ /**
611
712
  * Count the number of a node's neighbours that have been visited by
612
713
  * frontiers other than the node's own frontier.
613
714
  *
@@ -983,6 +1084,39 @@ async function laceAsync(graph, seeds, config) {
983
1084
  priority
984
1085
  });
985
1086
  }
1087
+ /**
1088
+ * Batch priority function for LACE expansion.
1089
+ *
1090
+ * Computes average MI between each candidate and all nodes visited by the
1091
+ * same frontier in a single batch operation. More efficient than computing
1092
+ * MI per-candidate when there are many candidates and visited nodes.
1093
+ *
1094
+ * @param candidates - Candidate node IDs to prioritise
1095
+ * @param context - Batch priority context
1096
+ * @returns Map of node ID to priority (lower = higher priority)
1097
+ */
1098
+ function laceBatchPriority(candidates, context) {
1099
+ const sameFrontierVisited = getSameFrontierVisited(context);
1100
+ const avgMIScores = batchAvgMI(context.graph, candidates, sameFrontierVisited);
1101
+ const priorities = /* @__PURE__ */ new Map();
1102
+ for (const candidate of candidates) {
1103
+ const avgMI = avgMIScores.get(candidate) ?? 0;
1104
+ priorities.set(candidate, 1 - avgMI);
1105
+ }
1106
+ return priorities;
1107
+ }
1108
+ /**
1109
+ * Create a LACE config with batch priority enabled.
1110
+ *
1111
+ * @param config - Base LACE configuration
1112
+ * @returns Configuration with batchPriority set
1113
+ */
1114
+ function laceWithBatchPriority(config) {
1115
+ return {
1116
+ ...config,
1117
+ batchPriority: laceBatchPriority
1118
+ };
1119
+ }
986
1120
  //#endregion
987
1121
  //#region src/expansion/warp.ts
988
1122
  /**
@@ -1087,6 +1221,46 @@ async function fuseAsync(graph, seeds, config) {
1087
1221
  priority
1088
1222
  });
1089
1223
  }
1224
+ /**
1225
+ * Create a batch priority function for FUSE with configurable weight.
1226
+ *
1227
+ * Combines degree with average frontier MI:
1228
+ * Priority = (1 - w) * degree + w * (1 - avgMI)
1229
+ *
1230
+ * @param salienceWeight - Weight for MI component (0-1, default: 0.5)
1231
+ * @returns Batch priority function
1232
+ */
1233
+ function createFuseBatchPriority(salienceWeight = .5) {
1234
+ return (candidates, context) => {
1235
+ const sameFrontierVisited = getSameFrontierVisited(context);
1236
+ const avgMIScores = batchAvgMI(context.graph, candidates, sameFrontierVisited);
1237
+ const priorities = /* @__PURE__ */ new Map();
1238
+ for (const candidate of candidates) {
1239
+ const avgMI = avgMIScores.get(candidate) ?? 0;
1240
+ const degree = context.graph.degree(candidate);
1241
+ const degreeComponent = (1 - salienceWeight) * degree;
1242
+ const salienceComponent = salienceWeight * (1 - avgMI);
1243
+ priorities.set(candidate, degreeComponent + salienceComponent);
1244
+ }
1245
+ return priorities;
1246
+ };
1247
+ }
1248
+ /**
1249
+ * Default FUSE batch priority function with salienceWeight = 0.5.
1250
+ */
1251
+ var fuseBatchPriority = createFuseBatchPriority(.5);
1252
+ /**
1253
+ * Create a FUSE config with batch priority enabled.
1254
+ *
1255
+ * @param config - Base FUSE configuration
1256
+ * @returns Configuration with batchPriority set
1257
+ */
1258
+ function fuseWithBatchPriority(config) {
1259
+ return {
1260
+ ...config,
1261
+ batchPriority: createFuseBatchPriority(config?.salienceWeight ?? .5)
1262
+ };
1263
+ }
1090
1264
  //#endregion
1091
1265
  //#region src/expansion/sift.ts
1092
1266
  /**
@@ -1140,6 +1314,47 @@ async function siftAsync(graph, seeds, config) {
1140
1314
  priority
1141
1315
  });
1142
1316
  }
1317
+ /**
1318
+ * Create a batch priority function for SIFT with configurable threshold.
1319
+ *
1320
+ * Nodes with average MI above the threshold get high priority (low value).
1321
+ * Nodes below the threshold are deferred with degree-based penalty.
1322
+ *
1323
+ * @param miThreshold - MI threshold for phase transition (default: 0.25)
1324
+ * @returns Batch priority function
1325
+ */
1326
+ function createSiftBatchPriority(miThreshold = .25) {
1327
+ return (candidates, context) => {
1328
+ const sameFrontierVisited = getSameFrontierVisited(context);
1329
+ const avgMIScores = batchAvgMI(context.graph, candidates, sameFrontierVisited);
1330
+ const priorities = /* @__PURE__ */ new Map();
1331
+ for (const candidate of candidates) {
1332
+ const avgMI = avgMIScores.get(candidate) ?? 0;
1333
+ if (avgMI >= miThreshold) priorities.set(candidate, 1 - avgMI);
1334
+ else {
1335
+ const degree = context.graph.degree(candidate);
1336
+ priorities.set(candidate, degree + 100);
1337
+ }
1338
+ }
1339
+ return priorities;
1340
+ };
1341
+ }
1342
+ /**
1343
+ * Default SIFT batch priority function with miThreshold = 0.25.
1344
+ */
1345
+ var siftBatchPriority = createSiftBatchPriority(.25);
1346
+ /**
1347
+ * Create a SIFT config with batch priority enabled.
1348
+ *
1349
+ * @param config - Base SIFT configuration
1350
+ * @returns Configuration with batchPriority set
1351
+ */
1352
+ function siftWithBatchPriority(config) {
1353
+ return {
1354
+ ...config,
1355
+ batchPriority: createSiftBatchPriority(config?.miThreshold ?? .25)
1356
+ };
1357
+ }
1143
1358
  //#endregion
1144
1359
  //#region src/expansion/flux.ts
1145
1360
  /**
@@ -1711,6 +1926,18 @@ Object.defineProperty(exports, "baseAsync", {
1711
1926
  return baseAsync;
1712
1927
  }
1713
1928
  });
1929
+ Object.defineProperty(exports, "createFuseBatchPriority", {
1930
+ enumerable: true,
1931
+ get: function() {
1932
+ return createFuseBatchPriority;
1933
+ }
1934
+ });
1935
+ Object.defineProperty(exports, "createSiftBatchPriority", {
1936
+ enumerable: true,
1937
+ get: function() {
1938
+ return createSiftBatchPriority;
1939
+ }
1940
+ });
1714
1941
  Object.defineProperty(exports, "dfsPriority", {
1715
1942
  enumerable: true,
1716
1943
  get: function() {
@@ -1801,6 +2028,18 @@ Object.defineProperty(exports, "fuseAsync", {
1801
2028
  return fuseAsync;
1802
2029
  }
1803
2030
  });
2031
+ Object.defineProperty(exports, "fuseBatchPriority", {
2032
+ enumerable: true,
2033
+ get: function() {
2034
+ return fuseBatchPriority;
2035
+ }
2036
+ });
2037
+ Object.defineProperty(exports, "fuseWithBatchPriority", {
2038
+ enumerable: true,
2039
+ get: function() {
2040
+ return fuseWithBatchPriority;
2041
+ }
2042
+ });
1804
2043
  Object.defineProperty(exports, "hae", {
1805
2044
  enumerable: true,
1806
2045
  get: function() {
@@ -1831,6 +2070,18 @@ Object.defineProperty(exports, "laceAsync", {
1831
2070
  return laceAsync;
1832
2071
  }
1833
2072
  });
2073
+ Object.defineProperty(exports, "laceBatchPriority", {
2074
+ enumerable: true,
2075
+ get: function() {
2076
+ return laceBatchPriority;
2077
+ }
2078
+ });
2079
+ Object.defineProperty(exports, "laceWithBatchPriority", {
2080
+ enumerable: true,
2081
+ get: function() {
2082
+ return laceWithBatchPriority;
2083
+ }
2084
+ });
1834
2085
  Object.defineProperty(exports, "maze", {
1835
2086
  enumerable: true,
1836
2087
  get: function() {
@@ -1909,6 +2160,18 @@ Object.defineProperty(exports, "siftAsync", {
1909
2160
  return siftAsync;
1910
2161
  }
1911
2162
  });
2163
+ Object.defineProperty(exports, "siftBatchPriority", {
2164
+ enumerable: true,
2165
+ get: function() {
2166
+ return siftBatchPriority;
2167
+ }
2168
+ });
2169
+ Object.defineProperty(exports, "siftWithBatchPriority", {
2170
+ enumerable: true,
2171
+ get: function() {
2172
+ return siftWithBatchPriority;
2173
+ }
2174
+ });
1912
2175
  Object.defineProperty(exports, "standardBfs", {
1913
2176
  enumerable: true,
1914
2177
  get: function() {
@@ -1946,4 +2209,4 @@ Object.defineProperty(exports, "warpAsync", {
1946
2209
  }
1947
2210
  });
1948
2211
 
1949
- //# sourceMappingURL=expansion-DaTroIyv.cjs.map
2212
+ //# sourceMappingURL=expansion--UuRowv-.cjs.map