graphwise 1.5.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -177,6 +177,17 @@ Density-adaptive strategy switching. Selects between DOME, EDGE, and PIPE modes
177
177
 
178
178
  ---
179
179
 
180
+ #### Expansion Baselines
181
+
182
+ | Algorithm | Priority Function | Description |
183
+ | --------------------- | ------------------------------ | ------------------------------------------ |
184
+ | **BFS** | Discovery order (FIFO) | Standard breadth-first search |
185
+ | **DFS** | Negative iteration (LIFO) | Depth-first exploration |
186
+ | **Frontier-Balanced** | Round-robin across frontiers | Fair inter-frontier distribution |
187
+ | **Random Priority** | Seeded hash (FNV-1a) | Null hypothesis baseline |
188
+ | **k-Hop** | BFS with depth limit $k$ | Fixed-depth ego-network extraction |
189
+ | **Random Walk** | Stochastic neighbour selection | Random walk with restart ($\alpha = 0.15$) |
190
+
180
191
  ---
181
192
 
182
193
  ### Path Ranking: PARSE
@@ -251,19 +262,33 @@ where $c(\tau_u)$ is the count of nodes with the same type as $u$. Weights Jacca
251
262
 
252
263
  ---
253
264
 
265
+ #### MI Baselines
266
+
267
+ | Measure | Formula | Description |
268
+ | ----------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
269
+ | **Cosine Similarity** | $\frac{\lvert N(u) \cap N(v) \rvert}{\sqrt{\lvert N(u) \rvert} \cdot \sqrt{\lvert N(v) \rvert}}$ | Neighbourhood vector cosine; more tolerant of degree asymmetry than Jaccard |
270
+ | **Sorensen-Dice** | $\frac{2 \lvert N(u) \cap N(v) \rvert}{\lvert N(u) \rvert + \lvert N(v) \rvert}$ | Harmonic mean variant of Jaccard; equivalent to F1-score |
271
+ | **Resource Allocation** | $\sum_{w \in N(u) \cap N(v)} \frac{1}{\deg(w)}$ | Like Adamic-Adar but without the log; penalises hubs more aggressively |
272
+ | **Overlap Coefficient** | $\frac{\lvert N(u) \cap N(v) \rvert}{\min(\lvert N(u) \rvert, \lvert N(v) \rvert)}$ | Fraction of smaller neighbourhood that is shared; less sensitive to degree asymmetry |
273
+ | **Hub Promoted** | $\frac{\lvert N(u) \cap N(v) \rvert}{\min(\deg(u), \deg(v))}$ | Promotes hub connections; edges involving high-degree nodes score higher |
274
+
275
+ ---
276
+
254
277
  ### Ranking Baselines
255
278
 
256
- | Measure | Formula |
257
- | --------------------------- | --------------------------------------------------- |
258
- | **Katz Index** | $\sum_{k=1}^{\infty} \beta^k (A^k)_{st}$ |
259
- | **Communicability** | $(e^A)_{st}$ |
260
- | **Resistance Distance** | $L^{+}\_{ss} + L^{+}\_{tt} - 2L^{+}\_{st}$ |
261
- | **Jaccard Arithmetic Mean** | $\frac{1}{k} \sum J(N(u), N(v))$ |
262
- | **Degree-Sum** | $\sum_{v \in P} \deg(v)$ |
263
- | **Widest Path** | $\min_{(u,v) \in P} w(u,v)$ |
264
- | **PageRank** | Stationary distribution of random walk with damping |
265
- | **Betweenness** | Fraction of shortest paths through node |
266
- | **Random** | Uniform random score (null baseline) |
279
+ | Measure | Formula |
280
+ | --------------------------- | -------------------------------------------------------------------------------------- |
281
+ | **Katz Index** | $\sum_{k=1}^{\infty} \beta^k (A^k)_{st}$ |
282
+ | **Communicability** | $(e^A)_{st}$ |
283
+ | **Resistance Distance** | $L^{+}\_{ss} + L^{+}\_{tt} - 2L^{+}\_{st}$ |
284
+ | **Jaccard Arithmetic Mean** | $\frac{1}{k} \sum J(N(u), N(v))$ |
285
+ | **Degree-Sum** | $\sum_{v \in P} \deg(v)$ |
286
+ | **Widest Path** | $\min_{(u,v) \in P} w(u,v)$ |
287
+ | **PageRank** | Stationary distribution of random walk with damping |
288
+ | **Betweenness** | Fraction of shortest paths through node |
289
+ | **Hitting Time** | $H(s,t) = \left((I - Q)^{-1} \mathbf{1}\right)_s$ (exact) or Monte Carlo approximation |
290
+ | **Shortest Path** | Hop count on unweighted graphs |
291
+ | **Random** | Uniform random score (null baseline) |
267
292
 
268
293
  ---
269
294
 
@@ -8,4 +8,5 @@ export * from './types';
8
8
  export * from './helpers';
9
9
  export * from './graphs';
10
10
  export * from './metrics';
11
+ export * from './wrap-async';
11
12
  //# 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;AACzB,cAAc,WAAW,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;AAC1B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { NodeData, EdgeData, ReadableGraph } from '../../graph';
2
+ import { AsyncReadableGraph } from '../../graph/async-interfaces';
3
+ /**
4
+ * Wrap a synchronous ReadableGraph as an AsyncReadableGraph.
5
+ *
6
+ * @param graph - The synchronous graph to wrap
7
+ * @returns An AsyncReadableGraph that delegates to the sync graph
8
+ */
9
+ export declare function wrapAsync<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>): AsyncReadableGraph<N, E>;
10
+ //# sourceMappingURL=wrap-async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-async.d.ts","sourceRoot":"","sources":["../../../src/__test__/fixtures/wrap-async.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEX,QAAQ,EACR,QAAQ,EAER,aAAa,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC/D,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAsE1B"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Async module — generator protocol, runners, and utilities.
3
+ *
4
+ * @module async
5
+ */
6
+ export * from './protocol';
7
+ export * from './ops';
8
+ export * from './types';
9
+ export * from './runners';
10
+ export * from './utils';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { NodeId, NodeData, EdgeData, Direction } from '../graph';
2
+ import { GraphOp, GraphOpResponse, ProgressStats } from './protocol';
3
+ export declare function opNeighbours<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(id: NodeId, direction?: Direction): Generator<GraphOp, readonly NodeId[], GraphOpResponse<N, E>>;
4
+ export declare function opDegree<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(id: NodeId, direction?: Direction): Generator<GraphOp, number, GraphOpResponse<N, E>>;
5
+ export declare function opGetNode<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(id: NodeId): Generator<GraphOp, N | undefined, GraphOpResponse<N, E>>;
6
+ export declare function opGetEdge<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(source: NodeId, target: NodeId): Generator<GraphOp, E | undefined, GraphOpResponse<N, E>>;
7
+ export declare function opHasNode<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(id: NodeId): Generator<GraphOp, boolean, GraphOpResponse<N, E>>;
8
+ export declare function opYield<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(): Generator<GraphOp, void, GraphOpResponse<N, E>>;
9
+ export declare function opProgress<N extends NodeData = NodeData, E extends EdgeData = EdgeData>(stats: ProgressStats): Generator<GraphOp, void, GraphOpResponse<N, E>>;
10
+ //# sourceMappingURL=ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/async/ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1E,wBAAiB,YAAY,CAC5B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAE7B,EAAE,EAAE,MAAM,EACV,SAAS,CAAC,EAAE,SAAS,GACnB,SAAS,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAU9D;AAED,wBAAiB,QAAQ,CACxB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAE7B,EAAE,EAAE,MAAM,EACV,SAAS,CAAC,EAAE,SAAS,GACnB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAUnD;AAED,wBAAiB,SAAS,CACzB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC5B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAMtE;AAED,wBAAiB,SAAS,CACzB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAE7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACZ,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,SAAS,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAU1D;AAED,wBAAiB,SAAS,CACzB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC5B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAMhE;AAED,wBAAiB,OAAO,CACvB,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,KACzB,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAEnD;AAED,wBAAiB,UAAU,CAC1B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC5B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAEvE"}
@@ -0,0 +1,62 @@
1
+ import { NodeId, NodeData, EdgeData, Direction } from '../graph';
2
+ /** Operations the generator can yield to request graph data. */
3
+ export type GraphOp = {
4
+ readonly tag: "neighbours";
5
+ readonly id: NodeId;
6
+ readonly direction?: Direction;
7
+ } | {
8
+ readonly tag: "degree";
9
+ readonly id: NodeId;
10
+ readonly direction?: Direction;
11
+ } | {
12
+ readonly tag: "getNode";
13
+ readonly id: NodeId;
14
+ } | {
15
+ readonly tag: "getEdge";
16
+ readonly source: NodeId;
17
+ readonly target: NodeId;
18
+ } | {
19
+ readonly tag: "hasNode";
20
+ readonly id: NodeId;
21
+ } | {
22
+ readonly tag: "yield";
23
+ } | {
24
+ readonly tag: "progress";
25
+ readonly stats: ProgressStats;
26
+ };
27
+ /**
28
+ * Tagged response from a runner for a graph operation.
29
+ *
30
+ * Using a discriminated union with `tag` allows type-safe narrowing
31
+ * without type assertions (satisfying strict lint rules).
32
+ */
33
+ export type GraphOpResponse<N extends NodeData = NodeData, E extends EdgeData = EdgeData> = {
34
+ readonly tag: "neighbours";
35
+ readonly value: readonly NodeId[];
36
+ } | {
37
+ readonly tag: "degree";
38
+ readonly value: number;
39
+ } | {
40
+ readonly tag: "getNode";
41
+ readonly value: N | undefined;
42
+ } | {
43
+ readonly tag: "getEdge";
44
+ readonly value: E | undefined;
45
+ } | {
46
+ readonly tag: "hasNode";
47
+ readonly value: boolean;
48
+ } | {
49
+ readonly tag: "yield";
50
+ } | {
51
+ readonly tag: "progress";
52
+ };
53
+ /** Progress statistics emitted during expansion. */
54
+ export interface ProgressStats {
55
+ readonly iterations: number;
56
+ readonly nodesVisited: number;
57
+ readonly edgesTraversed: number;
58
+ readonly pathsFound: number;
59
+ readonly frontierSizes: readonly number[];
60
+ readonly elapsedMs: number;
61
+ }
62
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/async/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEtE,gEAAgE;AAChE,MAAM,MAAM,OAAO,GAChB;IACA,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAC9B,GACD;IACA,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAC9B,GACD;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChD;IACA,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACvB,GACD;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAAE,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAC1B,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,IAE3B;IAAE,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACjE;IAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;CAAE,CAAC;AAEhC,oDAAoD;AACpD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B"}
@@ -0,0 +1,55 @@
1
+ import { NodeData, EdgeData, ReadableGraph } from '../graph';
2
+ import { AsyncReadableGraph } from '../graph/async-interfaces';
3
+ import { GraphOp, GraphOpResponse } from './protocol';
4
+ import { AsyncRunnerOptions } from './types';
5
+ /**
6
+ * Resolve a single GraphOp against a synchronous ReadableGraph.
7
+ *
8
+ * Returns a tagged GraphOpResponse so the receiving generator can narrow
9
+ * the result type without type assertions.
10
+ *
11
+ * @param graph - The synchronous graph to query
12
+ * @param op - The operation to resolve
13
+ * @returns The tagged response
14
+ */
15
+ export declare function resolveSyncOp<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, op: GraphOp): GraphOpResponse<N, E>;
16
+ /**
17
+ * Drive a generator to completion using a synchronous graph.
18
+ *
19
+ * The generator yields GraphOp requests; each is resolved immediately
20
+ * against the graph and the tagged response is fed back via gen.next().
21
+ *
22
+ * @param gen - The generator to drive
23
+ * @param graph - The graph to resolve ops against
24
+ * @returns The generator's return value
25
+ */
26
+ export declare function runSync<N extends NodeData, E extends EdgeData, R>(gen: Generator<GraphOp, R, GraphOpResponse<N, E>>, graph: ReadableGraph<N, E>): R;
27
+ /**
28
+ * Resolve a single GraphOp against an async ReadableGraph.
29
+ *
30
+ * AsyncIterables (neighbours) are collected into readonly arrays so the
31
+ * generator receives the same value type as in sync mode. Returns a tagged
32
+ * GraphOpResponse for type-safe narrowing without assertions.
33
+ *
34
+ * @param graph - The async graph to query
35
+ * @param op - The operation to resolve
36
+ * @returns A promise resolving to the tagged response
37
+ */
38
+ export declare function resolveAsyncOp<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, op: GraphOp): Promise<GraphOpResponse<N, E>>;
39
+ /**
40
+ * Drive a generator to completion using an async graph.
41
+ *
42
+ * Extends sync semantics with:
43
+ * - Cancellation via AbortSignal (throws DOMException "AbortError")
44
+ * - Cooperative yielding at `yield` ops (calls yieldStrategy)
45
+ * - Progress callbacks at `progress` ops (may be async for backpressure)
46
+ * - Error propagation: graph errors are forwarded via gen.throw(); if the
47
+ * generator does not handle them, they propagate to the caller
48
+ *
49
+ * @param gen - The generator to drive
50
+ * @param graph - The async graph to resolve ops against
51
+ * @param options - Runner configuration
52
+ * @returns A promise resolving to the generator's return value
53
+ */
54
+ export declare function runAsync<N extends NodeData, E extends EdgeData, R>(gen: Generator<GraphOp, R, GraphOpResponse<N, E>>, graph: AsyncReadableGraph<N, E>, options?: AsyncRunnerOptions): Promise<R>;
55
+ //# sourceMappingURL=runners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runners.d.ts","sourceRoot":"","sources":["../../src/async/runners.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAOlD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACnE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,EAAE,EAAE,OAAO,GACT,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAoBvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAAE,CAAC,EAChE,GAAG,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACjD,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,CAAC,CAOH;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC1E,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,EAAE,EAAE,OAAO,GACT,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAyBhC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAAE,CAAC,EACvE,GAAG,EAAE,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACjD,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,OAAO,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CA0DZ"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Unit tests for sync and async runners.
3
+ *
4
+ * Verifies that runSync and runAsync correctly drive generator-based
5
+ * algorithms, resolve all op tags, handle cancellation, and propagate errors.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=runners.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runners.unit.test.d.ts","sourceRoot":"","sources":["../../src/async/runners.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,15 @@
1
+ import { ProgressStats } from './protocol';
2
+ /** Strategy for cooperative yielding in async mode. */
3
+ export type YieldStrategy = () => Promise<void>;
4
+ /** Configuration for the async runner. */
5
+ export interface AsyncRunnerOptions {
6
+ /** AbortSignal for cancellation. */
7
+ readonly signal?: AbortSignal;
8
+ /** Progress callback, called at yield points. Async return = backpressure. */
9
+ readonly onProgress?: (stats: ProgressStats) => void | Promise<void>;
10
+ /** Custom yield strategy (default: setTimeout(0)). */
11
+ readonly yieldStrategy?: YieldStrategy;
12
+ /** Yield every N iterations (default: 100). */
13
+ readonly yieldInterval?: number;
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/async/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,uDAAuD;AACvD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC,oCAAoC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,sDAAsD;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Async utility functions.
3
+ *
4
+ * @module async/utils
5
+ */
6
+ /** Collect an AsyncIterable into a readonly array. */
7
+ export declare function collectAsyncIterable<T>(iter: AsyncIterable<T>): Promise<readonly T[]>;
8
+ /** Default yield strategy: setTimeout(0) to yield to the event loop. */
9
+ export declare function defaultYieldStrategy(): Promise<void>;
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/async/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sDAAsD;AACtD,wBAAsB,oBAAoB,CAAC,CAAC,EAC3C,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAIvB;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Cross-algorithm comparison integration tests for expansion algorithms.
3
+ *
4
+ * Runs all expansion algorithms head-to-head on the same graphs to verify
5
+ * relative performance properties. Tests are structural rather than exact —
6
+ * they validate ordering relationships and quality bounds with tolerance.
7
+ *
8
+ * Graphs used:
9
+ * - Three-community (bob → mia): rich inter-community structure, liaison bridges
10
+ * - Two-department (alice → jack): dense clusters with bottleneck edges
11
+ * - Social hub (bob → kate): hub node with niche interest clusters
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=comparison.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparison.integration.test.d.ts","sourceRoot":"","sources":["../../src/expansion/comparison.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -0,0 +1,31 @@
1
+ import { NodeId, NodeData, EdgeData, Direction } from './types';
2
+ /**
3
+ * Async read-only interface for graph traversal and queries.
4
+ *
5
+ * Mirrors ReadableGraph but all operations return Promises or AsyncIterables,
6
+ * enabling use with remote graph data sources where each operation may
7
+ * require a network fetch.
8
+ */
9
+ export interface AsyncReadableGraph<N extends NodeData = NodeData, E extends EdgeData = EdgeData> {
10
+ /** Whether the graph is directed (true) or undirected (false) */
11
+ readonly directed: boolean;
12
+ /** Total number of nodes in the graph */
13
+ readonly nodeCount: Promise<number>;
14
+ /** Total number of edges in the graph */
15
+ readonly edgeCount: Promise<number>;
16
+ /** Check if a node exists in the graph. */
17
+ hasNode(id: NodeId): Promise<boolean>;
18
+ /** Retrieve node data by identifier. */
19
+ getNode(id: NodeId): Promise<N | undefined>;
20
+ /** Iterate over all node identifiers in the graph. */
21
+ nodeIds(): AsyncIterable<NodeId>;
22
+ /** Get neighbouring node identifiers in the specified direction. */
23
+ neighbours(id: NodeId, direction?: Direction): AsyncIterable<NodeId>;
24
+ /** Get the degree (number of connected edges) for a node. */
25
+ degree(id: NodeId, direction?: Direction): Promise<number>;
26
+ /** Retrieve edge data between two nodes. */
27
+ getEdge(source: NodeId, target: NodeId): Promise<E | undefined>;
28
+ /** Iterate over all edges in the graph. */
29
+ edges(): AsyncIterable<E>;
30
+ }
31
+ //# sourceMappingURL=async-interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-interfaces.d.ts","sourceRoot":"","sources":["../../src/graph/async-interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAClC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAE7B,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpC,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC,wCAAwC;IACxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAE5C,sDAAsD;IACtD,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAEjC,oEAAoE;IACpE,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAErE,6DAA6D;IAC7D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3D,4CAA4C;IAC5C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAEhE,2CAA2C;IAC3C,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=async-interfaces.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-interfaces.unit.test.d.ts","sourceRoot":"","sources":["../../src/graph/async-interfaces.unit.test.ts"],"names":[],"mappings":""}
@@ -6,4 +6,5 @@
6
6
  export * from './types';
7
7
  export * from './interfaces';
8
8
  export * from './adjacency-map';
9
+ export * from './async-interfaces';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Cross-variant comparison integration tests for MI functions.
3
+ *
4
+ * Runs all MI variants through PARSE on the same paths and compares their
5
+ * structural properties. Tests verify:
6
+ * - All variants produce non-zero salience
7
+ * - Novel variants produce distinct salience from jaccard baseline
8
+ * - PARSE exhibits near-zero length bias across all variants
9
+ * - Ranking order is consistent with MI variant semantics
10
+ *
11
+ * Graphs used:
12
+ * - Three-community (bob → mia): rich clustering structure for SPAN
13
+ * - City-village (nightclub → shop): density contrast for SCALE
14
+ * - Social hub (bob → kate): hub/peripheral contrast for SKEW/NOTCH
15
+ * - Quality-vs-popularity (source → target): explicit high/low MI paths
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=comparison.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparison.integration.test.d.ts","sourceRoot":"","sources":["../../../src/ranking/mi/comparison.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphwise",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Graph algorithms for citation network analysis - novel expansion, MI variants, and path ranking",
5
5
  "type": "module",
6
6
  "sideEffects": false,