graphwise 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +38 -0
  2. package/dist/__test__/fixtures/index.d.ts +1 -0
  3. package/dist/__test__/fixtures/index.d.ts.map +1 -1
  4. package/dist/__test__/fixtures/metrics.d.ts +86 -0
  5. package/dist/__test__/fixtures/metrics.d.ts.map +1 -0
  6. package/dist/__test__/fixtures/metrics.unit.test.d.ts +7 -0
  7. package/dist/__test__/fixtures/metrics.unit.test.d.ts.map +1 -0
  8. package/dist/expansion/dfs-priority.d.ts +23 -0
  9. package/dist/expansion/dfs-priority.d.ts.map +1 -0
  10. package/dist/expansion/dfs-priority.unit.test.d.ts +2 -0
  11. package/dist/expansion/dfs-priority.unit.test.d.ts.map +1 -0
  12. package/dist/expansion/index.d.ts +3 -0
  13. package/dist/expansion/index.d.ts.map +1 -1
  14. package/dist/expansion/k-hop.d.ts +26 -0
  15. package/dist/expansion/k-hop.d.ts.map +1 -0
  16. package/dist/expansion/k-hop.unit.test.d.ts +2 -0
  17. package/dist/expansion/k-hop.unit.test.d.ts.map +1 -0
  18. package/dist/expansion/random-walk.d.ts +35 -0
  19. package/dist/expansion/random-walk.d.ts.map +1 -0
  20. package/dist/expansion/random-walk.unit.test.d.ts +2 -0
  21. package/dist/expansion/random-walk.unit.test.d.ts.map +1 -0
  22. package/dist/index/index.cjs +716 -5
  23. package/dist/index/index.cjs.map +1 -1
  24. package/dist/index/index.js +707 -6
  25. package/dist/index/index.js.map +1 -1
  26. package/dist/ranking/baselines/hitting-time.d.ts +27 -0
  27. package/dist/ranking/baselines/hitting-time.d.ts.map +1 -0
  28. package/dist/ranking/baselines/hitting-time.unit.test.d.ts +2 -0
  29. package/dist/ranking/baselines/hitting-time.unit.test.d.ts.map +1 -0
  30. package/dist/ranking/baselines/index.d.ts +1 -0
  31. package/dist/ranking/baselines/index.d.ts.map +1 -1
  32. package/dist/ranking/mi/cosine.d.ts +13 -0
  33. package/dist/ranking/mi/cosine.d.ts.map +1 -0
  34. package/dist/ranking/mi/cosine.unit.test.d.ts +2 -0
  35. package/dist/ranking/mi/cosine.unit.test.d.ts.map +1 -0
  36. package/dist/ranking/mi/hub-promoted.d.ts +13 -0
  37. package/dist/ranking/mi/hub-promoted.d.ts.map +1 -0
  38. package/dist/ranking/mi/hub-promoted.unit.test.d.ts +2 -0
  39. package/dist/ranking/mi/hub-promoted.unit.test.d.ts.map +1 -0
  40. package/dist/ranking/mi/index.d.ts +5 -0
  41. package/dist/ranking/mi/index.d.ts.map +1 -1
  42. package/dist/ranking/mi/overlap-coefficient.d.ts +13 -0
  43. package/dist/ranking/mi/overlap-coefficient.d.ts.map +1 -0
  44. package/dist/ranking/mi/overlap-coefficient.unit.test.d.ts +2 -0
  45. package/dist/ranking/mi/overlap-coefficient.unit.test.d.ts.map +1 -0
  46. package/dist/ranking/mi/resource-allocation.d.ts +13 -0
  47. package/dist/ranking/mi/resource-allocation.d.ts.map +1 -0
  48. package/dist/ranking/mi/resource-allocation.unit.test.d.ts +2 -0
  49. package/dist/ranking/mi/resource-allocation.unit.test.d.ts.map +1 -0
  50. package/dist/ranking/mi/sorensen.d.ts +13 -0
  51. package/dist/ranking/mi/sorensen.d.ts.map +1 -0
  52. package/dist/ranking/mi/sorensen.unit.test.d.ts +2 -0
  53. package/dist/ranking/mi/sorensen.unit.test.d.ts.map +1 -0
  54. package/dist/ranking/mi/types.d.ts +1 -1
  55. package/dist/ranking/mi/types.d.ts.map +1 -1
  56. package/dist/schemas/graph.d.ts +1 -1
  57. package/package.json +1 -1
package/README.md CHANGED
@@ -47,6 +47,8 @@ Three key properties:
47
47
  2. **Frontier collision detection**: when a vertex is reached by multiple frontiers, the connecting path is recorded
48
48
  3. **Implicit termination**: halts when all frontier queues are empty; no depth bound or size threshold
49
49
 
50
+ ---
51
+
50
52
  #### DOME: Degree-Ordered Multi-seed Expansion
51
53
 
52
54
  The default priority function uses degree-based hub deferral:
@@ -55,6 +57,8 @@ $$\pi(v) = \frac{\deg^{+}(v) + \deg^{-}(v)}{w_V(v) + \varepsilon}$$
55
57
 
56
58
  where $\deg^{+}(v)$ is weighted out-degree, $\deg^{-}(v)$ is weighted in-degree, $w_V(v)$ is node weight, and $\varepsilon > 0$ prevents division by zero.
57
59
 
60
+ ---
61
+
58
62
  #### Expansion Variants
59
63
 
60
64
  | Algorithm | Priority Function | Phases |
@@ -73,18 +77,24 @@ where $\deg^{+}(v)$ is weighted out-degree, $\deg^{-}(v)$ is weighted in-degree,
73
77
  | **SIFT** | MI threshold with degree fallback | 1 |
74
78
  | **FLUX** | Density-adaptive strategy switching | 1 |
75
79
 
80
+ ---
81
+
76
82
  #### EDGE: Entropy-Driven Graph Expansion
77
83
 
78
84
  $$\pi_{\text{EDGE}}(v) = \frac{1}{H_{\text{local}}(v) + \varepsilon} \times \log(\deg(v) + 1)$$
79
85
 
80
86
  where $H_{\text{local}}(v) = -\sum_{\tau} p(\tau) \log p(\tau)$ is the Shannon entropy of the neighbour type distribution. Nodes bridging heterogeneous structural regimes (high entropy) are explored first.
81
87
 
88
+ ---
89
+
82
90
  #### PIPE: Path-potential Informed Priority Expansion
83
91
 
84
92
  $$\pi_{\text{PIPE}}(v) = \frac{\deg(v)}{1 + \mathrm{pathPotential}(v)}$$
85
93
 
86
94
  where $\mathrm{pathPotential}(v) = \lvert N(v) \cap \bigcup_{j \neq i} V_j \rvert$ counts neighbours already visited by other seed frontiers. High path potential indicates imminent path completion.
87
95
 
96
+ ---
97
+
88
98
  #### SAGE: Salience-Accumulation Guided Expansion
89
99
 
90
100
  $$
@@ -93,6 +103,8 @@ $$
93
103
 
94
104
  where $\text{salience}(v)$ counts discovered paths containing $v$. Salience dominates in Phase 2; degree serves as tiebreaker.
95
105
 
106
+ ---
107
+
96
108
  #### REACH: Retrospective Expansion with Adaptive Convergence
97
109
 
98
110
  $$
@@ -105,6 +117,8 @@ $$
105
117
  \widehat{\text{MI}}(v) = \frac{1}{\lvert \mathcal{P}\_{\text{top}} \rvert} \sum\_{p} J(N(v), N(p\_{\text{endpoint}}))
106
118
  $$
107
119
 
120
+ ---
121
+
108
122
  #### MAZE: Multi-frontier Adaptive Zone Expansion
109
123
 
110
124
  $$
@@ -113,30 +127,40 @@ $$
113
127
 
114
128
  Phase 1 uses PIPE's path potential until $M$ paths found. Phase 2 incorporates SAGE's salience feedback. Phase 3 evaluates diversity, path count, and salience plateau for termination.
115
129
 
130
+ ---
131
+
116
132
  #### TIDE: Total Interconnected Degree Expansion
117
133
 
118
134
  $$\pi_{\text{TIDE}}(v) = \deg(v) + \sum_{w \in N(v)} \deg(w)$$
119
135
 
120
136
  Nodes in sparse regions (low aggregate neighbourhood degree) are explored first. Related to EDGE but uses raw degree sums rather than entropy.
121
137
 
138
+ ---
139
+
122
140
  #### LACE: Local Affinity-Computed Expansion
123
141
 
124
142
  $$\pi_{\text{LACE}}(v) = 1 - \overline{\text{MI}}(v, \text{frontier})$$
125
143
 
126
144
  Prioritises nodes by average MI to already-visited frontier nodes. Related to HAE but uses MI to visited nodes rather than type entropy.
127
145
 
146
+ ---
147
+
128
148
  #### WARP: Weighted Adjacent Reachability Priority
129
149
 
130
150
  $$\pi_{\text{WARP}}(v) = \frac{1}{1 + \text{bridge}(v)}$$
131
151
 
132
152
  Pure cross-frontier bridge score without degree normalisation. Related to PIPE but omits the degree numerator.
133
153
 
154
+ ---
155
+
134
156
  #### FUSE: Fused Utility-Salience Expansion
135
157
 
136
158
  $$\pi_{\text{FUSE}}(v) = (1 - w) \cdot \deg(v) + w \cdot (1 - \overline{\text{MI}})$$
137
159
 
138
160
  Single-phase weighted blend of degree and MI. Related to SAGE but uses continuous blending rather than two-phase transition.
139
161
 
162
+ ---
163
+
140
164
  #### SIFT: Salience-Informed Frontier Threshold
141
165
 
142
166
  $$
@@ -145,10 +169,16 @@ $$
145
169
 
146
170
  MI-threshold-based priority with degree fallback. Related to REACH but uses a hard threshold instead of continuous MI-weighted priority.
147
171
 
172
+ ---
173
+
148
174
  #### FLUX: Flexible Local Utility Crossover
149
175
 
150
176
  Density-adaptive strategy switching. Selects between DOME, EDGE, and PIPE modes per-node based on local graph density and cross-frontier bridge score. Related to MAZE but adapts spatially (per-node) rather than temporally (per-phase).
151
177
 
178
+ ---
179
+
180
+ ---
181
+
152
182
  ### Path Ranking: PARSE
153
183
 
154
184
  **Path Aggregation Ranked by Salience Estimation** (PARSE) scores paths by the geometric mean of per-edge mutual information, eliminating length bias:
@@ -235,6 +265,10 @@ where $c(\tau_u)$ is the count of nodes with the same type as $u$. Weights Jacca
235
265
  | **Betweenness** | Fraction of shortest paths through node |
236
266
  | **Random** | Uniform random score (null baseline) |
237
267
 
268
+ ---
269
+
270
+ ---
271
+
238
272
  ### Seed Selection: GRASP
239
273
 
240
274
  **Graph-agnostic Representative seed pAir Sampling**: selects structurally representative seed pairs from an unknown graph using reservoir sampling and structural feature clustering. Operates blind: no full graph loading, no ground-truth labels, no human-defined strata.
@@ -245,6 +279,10 @@ Three phases:
245
279
  2. **Structural features**: for each sampled node compute $\log(\deg + 1)$, clustering coefficient, approximate PageRank
246
280
  3. **Cluster and sample**: MiniBatchKMeans into $K$ groups; sample within-cluster and cross-cluster pairs
247
281
 
282
+ ---
283
+
284
+ ---
285
+
248
286
  ## Module Exports
249
287
 
250
288
  ```typescript
@@ -7,4 +7,5 @@
7
7
  export * from './types';
8
8
  export * from './helpers';
9
9
  export * from './graphs';
10
+ export * from './metrics';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { NodeId, NodeData, EdgeData, ReadableGraph } from '../../graph';
2
+ import { ExpansionResult } from '../../expansion/types';
3
+ import { PARSEResult } from '../../ranking/parse';
4
+ /**
5
+ * Fraction of visited nodes whose degree is below the 90th percentile of all
6
+ * sampled node degrees. A high ratio indicates the algorithm successfully
7
+ * defers high-degree hubs in favour of lower-degree nodes.
8
+ */
9
+ export declare function hubDeferralRatio<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, result: ExpansionResult): number;
10
+ /**
11
+ * Count of distinct intermediate nodes (i.e. excluding endpoints) across all
12
+ * discovered paths. Higher values indicate broader path diversity.
13
+ */
14
+ export declare function pathDiversity(result: ExpansionResult): number;
15
+ /**
16
+ * Ratio of sampled edges to sampled nodes. Reflects how densely the sampled
17
+ * subgraph is connected (higher = more edges per node).
18
+ */
19
+ export declare function subgraphDensity(result: ExpansionResult): number;
20
+ /**
21
+ * Ratio of discovered paths to total nodes visited. Measures how efficiently
22
+ * the expansion produced useful paths relative to exploration cost.
23
+ */
24
+ export declare function coverageEfficiency(result: ExpansionResult): number;
25
+ /**
26
+ * Ratio of total iterations to paths discovered. Measures how many
27
+ * iterations were required per path. Returns Infinity when no paths
28
+ * were found (expansion terminated without connecting seeds).
29
+ */
30
+ export declare function firstPathLatency(result: ExpansionResult): number;
31
+ /**
32
+ * Number of distinct node types present in the sampled node set.
33
+ * Nodes without a `type` property are counted as a single unnamed type.
34
+ */
35
+ export declare function typeCoverage<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, result: ExpansionResult): number;
36
+ /**
37
+ * Number of connected components that contain at least one path node,
38
+ * determined via union-find over the sampled edge set. Higher values
39
+ * indicate paths spanning structurally distant regions of the graph.
40
+ */
41
+ export declare function communitySpan(result: ExpansionResult): number;
42
+ /**
43
+ * Spearman rank correlation coefficient between two rankings (arrays of node
44
+ * IDs ordered from highest to lowest). Returns a value in [-1, 1] where 1
45
+ * means identical order and -1 means perfectly reversed.
46
+ *
47
+ * Only nodes present in both rankings are considered.
48
+ */
49
+ export declare function spearmanRho(rankingA: readonly NodeId[], rankingB: readonly NodeId[]): number;
50
+ /**
51
+ * Kendall tau rank correlation coefficient between two rankings. Returns a
52
+ * value in [-1, 1] where 1 means identical and -1 means fully reversed.
53
+ *
54
+ * Only nodes present in both rankings are considered.
55
+ */
56
+ export declare function kendallTau(rankingA: readonly NodeId[], rankingB: readonly NodeId[]): number;
57
+ /**
58
+ * Ratio of weak-link path salience to consistent-path salience. Values below
59
+ * 1 indicate the consistent path scores higher (expected behaviour); values
60
+ * above 1 indicate the weak-link path is incorrectly ranked higher.
61
+ *
62
+ * @param consistent - Mean salience of paths expected to rank highest
63
+ * @param weakLink - Mean salience of paths expected to rank lower
64
+ */
65
+ export declare function weakLinkSensitivity(consistent: number, weakLink: number): number;
66
+ /**
67
+ * Sample variance of salience scores across all ranked paths. Returns 0 when
68
+ * all paths have identical scores (no discriminative power).
69
+ */
70
+ export declare function scoreVariance(parseResult: PARSEResult): number;
71
+ /**
72
+ * Pearson correlation between path length (number of edges) and salience
73
+ * score. Values near 0 indicate length-unbiased ranking; strong positive or
74
+ * negative values indicate length bias.
75
+ */
76
+ export declare function lengthBias(parseResult: PARSEResult): number;
77
+ /**
78
+ * Ratio of hub path salience to peripheral path salience. Values below 1
79
+ * indicate hub paths score lower (hub penalty is working); values at or above
80
+ * 1 indicate no penalty.
81
+ *
82
+ * @param peripheral - Mean salience of paths through low-degree nodes
83
+ * @param hub - Mean salience of paths through high-degree hub nodes
84
+ */
85
+ export declare function hubPenaltyStrength(peripheral: number, hub: number): number;
86
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMvD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACtE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,MAAM,EAAE,eAAe,GACrB,MAAM,CAaR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa7D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAM/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAMlE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAKhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAClE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,MAAM,EAAE,eAAe,GACrB,MAAM,CASR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CA4C7D;AAMD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAC1B,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CA+BR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,QAAQ,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,CAsCR;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAS9D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA+B3D;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAK1E"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Unit tests for the comparison metrics module.
3
+ *
4
+ * Tests use minimal mock data to verify each metric function independently.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=metrics.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/metrics.unit.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,23 @@
1
+ import { NodeData, EdgeData, ReadableGraph } from '../graph';
2
+ import { Seed, ExpansionResult, ExpansionConfig, PriorityContext } from './types';
3
+ /**
4
+ * DFS priority function: negative iteration produces LIFO ordering.
5
+ *
6
+ * Lower priority values are expanded first, so negating the iteration
7
+ * counter ensures the most recently enqueued node is always next.
8
+ */
9
+ export declare function dfsPriorityFn<N extends NodeData, E extends EdgeData>(_nodeId: string, context: PriorityContext<N, E>): number;
10
+ /**
11
+ * Run DFS-priority expansion (LIFO discovery order).
12
+ *
13
+ * Uses the BASE framework with a negative-iteration priority function,
14
+ * which causes the most recently discovered node to be expanded first —
15
+ * equivalent to depth-first search behaviour.
16
+ *
17
+ * @param graph - Source graph
18
+ * @param seeds - Seed nodes for expansion
19
+ * @param config - Expansion configuration
20
+ * @returns Expansion result with discovered paths
21
+ */
22
+ export declare function dfsPriority<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
23
+ //# sourceMappingURL=dfs-priority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dfs-priority.d.ts","sourceRoot":"","sources":["../../src/expansion/dfs-priority.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EACf,eAAe,EACf,MAAM,SAAS,CAAC;AAGjB;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACnE,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,MAAM,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACjE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,eAAe,CAKjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=dfs-priority.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dfs-priority.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/dfs-priority.unit.test.ts"],"names":[],"mappings":""}
@@ -24,4 +24,7 @@ export * from './flux';
24
24
  export * from './standard-bfs';
25
25
  export * from './frontier-balanced';
26
26
  export * from './random-priority';
27
+ export * from './dfs-priority';
28
+ export * from './k-hop';
29
+ export * from './random-walk';
27
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expansion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/expansion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { NodeData, EdgeData, ReadableGraph } from '../graph';
2
+ import { Seed, ExpansionResult, ExpansionConfig } from './types';
3
+ /**
4
+ * Configuration for k-hop expansion.
5
+ */
6
+ export interface KHopConfig<N extends NodeData = NodeData, E extends EdgeData = EdgeData> extends ExpansionConfig<N, E> {
7
+ /**
8
+ * Maximum number of hops from any seed node.
9
+ * Defaults to 2.
10
+ */
11
+ readonly k?: number;
12
+ }
13
+ /**
14
+ * Run k-hop expansion (fixed-depth BFS).
15
+ *
16
+ * Explores all nodes reachable within exactly k hops of any seed using
17
+ * breadth-first search. Paths between seeds are detected when a node
18
+ * is reached by frontiers from two different seeds.
19
+ *
20
+ * @param graph - Source graph
21
+ * @param seeds - Seed nodes for expansion
22
+ * @param config - K-hop configuration (k defaults to 2)
23
+ * @returns Expansion result with discovered paths
24
+ */
25
+ export declare function kHop<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: KHopConfig<N, E>): ExpansionResult;
26
+ //# sourceMappingURL=k-hop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"k-hop.d.ts","sourceRoot":"","sources":["../../src/expansion/k-hop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EAGf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,UAAU,CAC1B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAC5B,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC1D,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GACvB,eAAe,CA4JjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=k-hop.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"k-hop.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/k-hop.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { NodeData, EdgeData, ReadableGraph } from '../graph';
2
+ import { Seed, ExpansionResult } from './types';
3
+ /**
4
+ * Configuration for random-walk-with-restart expansion.
5
+ */
6
+ export interface RandomWalkConfig {
7
+ /** Probability of restarting a walk from its seed node (default: 0.15). */
8
+ readonly restartProbability?: number;
9
+ /** Number of walks to perform per seed node (default: 10). */
10
+ readonly walks?: number;
11
+ /** Maximum steps per walk (default: 20). */
12
+ readonly walkLength?: number;
13
+ /** Random seed for deterministic reproducibility (default: 0). */
14
+ readonly seed?: number;
15
+ }
16
+ /**
17
+ * Run random-walk-with-restart expansion.
18
+ *
19
+ * For each seed, performs `walks` independent random walks of up to
20
+ * `walkLength` steps. At each step the walk either restarts (with
21
+ * probability `restartProbability`) or moves to a uniformly sampled
22
+ * neighbour. All visited nodes and traversed edges are collected.
23
+ *
24
+ * Inter-seed paths are detected when a walk reaches a node that was
25
+ * previously reached by a walk originating from a different seed.
26
+ * The recorded path contains only the two seed endpoints rather than
27
+ * the full walk trajectory, consistent with the ExpansionPath contract.
28
+ *
29
+ * @param graph - Source graph
30
+ * @param seeds - Seed nodes for expansion
31
+ * @param config - Random walk configuration
32
+ * @returns Expansion result with discovered paths
33
+ */
34
+ export declare function randomWalk<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: RandomWalkConfig): ExpansionResult;
35
+ //# sourceMappingURL=random-walk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-walk.d.ts","sourceRoot":"","sources":["../../src/expansion/random-walk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EAGf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AAqBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAChE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,gBAAgB,GACvB,eAAe,CAwJjB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=random-walk.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-walk.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/random-walk.unit.test.ts"],"names":[],"mappings":""}