graphwise 1.5.2 → 1.7.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 +36 -11
- package/dist/__test__/fixtures/index.d.ts +1 -0
- package/dist/__test__/fixtures/index.d.ts.map +1 -1
- package/dist/__test__/fixtures/wrap-async.d.ts +10 -0
- package/dist/__test__/fixtures/wrap-async.d.ts.map +1 -0
- package/dist/async/index.d.ts +11 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/ops.d.ts +10 -0
- package/dist/async/ops.d.ts.map +1 -0
- package/dist/async/protocol.d.ts +62 -0
- package/dist/async/protocol.d.ts.map +1 -0
- package/dist/async/runners.d.ts +55 -0
- package/dist/async/runners.d.ts.map +1 -0
- package/dist/async/runners.unit.test.d.ts +8 -0
- package/dist/async/runners.unit.test.d.ts.map +1 -0
- package/dist/async/types.d.ts +15 -0
- package/dist/async/types.d.ts.map +1 -0
- package/dist/async/utils.d.ts +10 -0
- package/dist/async/utils.d.ts.map +1 -0
- package/dist/expansion/base-core.d.ts +24 -0
- package/dist/expansion/base-core.d.ts.map +1 -0
- package/dist/expansion/base-core.unit.test.d.ts +10 -0
- package/dist/expansion/base-core.unit.test.d.ts.map +1 -0
- package/dist/expansion/base-helpers.d.ts +57 -0
- package/dist/expansion/base-helpers.d.ts.map +1 -0
- package/dist/expansion/base.d.ts +32 -1
- package/dist/expansion/base.d.ts.map +1 -1
- package/dist/graph/async-interfaces.d.ts +31 -0
- package/dist/graph/async-interfaces.d.ts.map +1 -0
- package/dist/graph/async-interfaces.unit.test.d.ts +2 -0
- package/dist/graph/async-interfaces.unit.test.d.ts.map +1 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/index/index.cjs +416 -82
- package/dist/index/index.cjs.map +1 -1
- package/dist/index/index.js +416 -83
- package/dist/index/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
| **
|
|
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
|
|
|
@@ -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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
|
|
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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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,24 @@
|
|
|
1
|
+
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { GraphOp, GraphOpResponse } from '../async/protocol';
|
|
3
|
+
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Generator core of the BASE expansion algorithm.
|
|
6
|
+
*
|
|
7
|
+
* Yields GraphOp objects to request graph data, allowing the caller to
|
|
8
|
+
* provide a sync or async runner. The optional `graphRef` parameter is
|
|
9
|
+
* required when the priority function accesses `context.graph` — it is
|
|
10
|
+
* populated in sync mode by `base()`. In async mode (Phase 4+), a proxy
|
|
11
|
+
* graph may be supplied instead.
|
|
12
|
+
*
|
|
13
|
+
* @param graphMeta - Immutable graph metadata (directed, nodeCount, edgeCount)
|
|
14
|
+
* @param seeds - Seed nodes for expansion
|
|
15
|
+
* @param config - Expansion configuration (priority, limits, debug)
|
|
16
|
+
* @param graphRef - Optional real graph reference for context.graph in priority functions
|
|
17
|
+
* @returns An ExpansionResult with all discovered paths and statistics
|
|
18
|
+
*/
|
|
19
|
+
export declare function baseCore<N extends NodeData, E extends EdgeData>(graphMeta: {
|
|
20
|
+
readonly directed: boolean;
|
|
21
|
+
readonly nodeCount: number;
|
|
22
|
+
readonly edgeCount: number;
|
|
23
|
+
}, seeds: readonly Seed[], config?: ExpansionConfig<N, E>, graphRef?: ReadableGraph<N, E>): Generator<GraphOp, ExpansionResult, GraphOpResponse<N, E>>;
|
|
24
|
+
//# sourceMappingURL=base-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-core.d.ts","sourceRoot":"","sources":["../../src/expansion/base-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAU,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1E,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EAGf,eAAe,EAEf,MAAM,SAAS,CAAC;AAqBjB;;;;;;;;;;;;;;GAcG;AACH,wBAAiB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC/D,SAAS,EAAE;IACV,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B,EACD,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,QAAQ,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CA6O5D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for the baseCore generator and baseAsync() entry point.
|
|
3
|
+
*
|
|
4
|
+
* Verifies that:
|
|
5
|
+
* - baseCore driven via runSync produces identical results to base()
|
|
6
|
+
* - baseAsync() produces identical results to base() on the standard fixtures
|
|
7
|
+
* - AbortSignal cancellation works in baseAsync()
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=base-core.unit.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-core.unit.test.d.ts","sourceRoot":"","sources":["../../src/expansion/base-core.unit.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { NodeId } from '../graph';
|
|
2
|
+
import { Seed, ExpansionPath, ExpansionResult, ExpansionStats } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal queue entry for frontier expansion.
|
|
5
|
+
*/
|
|
6
|
+
export interface QueueEntry {
|
|
7
|
+
nodeId: NodeId;
|
|
8
|
+
frontierIndex: number;
|
|
9
|
+
predecessor: NodeId | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Limits structure used by continueExpansion.
|
|
13
|
+
*/
|
|
14
|
+
export interface ExpansionLimits {
|
|
15
|
+
readonly maxIterations: number;
|
|
16
|
+
readonly maxNodes: number;
|
|
17
|
+
readonly maxPaths: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check whether expansion should continue given current progress.
|
|
21
|
+
*
|
|
22
|
+
* Returns shouldContinue=false as soon as any configured limit is reached,
|
|
23
|
+
* along with the appropriate termination reason.
|
|
24
|
+
*
|
|
25
|
+
* @param iterations - Number of iterations completed so far
|
|
26
|
+
* @param nodesVisited - Number of distinct nodes visited so far
|
|
27
|
+
* @param pathsFound - Number of paths discovered so far
|
|
28
|
+
* @param limits - Configured expansion limits (0 = unlimited)
|
|
29
|
+
* @returns Whether to continue and the termination reason if stopping
|
|
30
|
+
*/
|
|
31
|
+
export declare function continueExpansion(iterations: number, nodesVisited: number, pathsFound: number, limits: ExpansionLimits): {
|
|
32
|
+
shouldContinue: boolean;
|
|
33
|
+
termination: ExpansionStats["termination"];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reconstruct path from collision point.
|
|
37
|
+
*
|
|
38
|
+
* Traces backwards through the predecessor maps of both frontiers from the
|
|
39
|
+
* collision node, then concatenates the two halves to form the full path.
|
|
40
|
+
*
|
|
41
|
+
* @param collisionNode - The node where the two frontiers met
|
|
42
|
+
* @param frontierA - Index of the first frontier
|
|
43
|
+
* @param frontierB - Index of the second frontier
|
|
44
|
+
* @param predecessors - Predecessor maps, one per frontier
|
|
45
|
+
* @param seeds - Seed nodes, one per frontier
|
|
46
|
+
* @returns The reconstructed path, or null if seeds are missing
|
|
47
|
+
*/
|
|
48
|
+
export declare function reconstructPath(collisionNode: NodeId, frontierA: number, frontierB: number, predecessors: readonly Map<NodeId, NodeId | null>[], seeds: readonly Seed[]): ExpansionPath | null;
|
|
49
|
+
/**
|
|
50
|
+
* Create an empty expansion result for early termination (e.g. no seeds given).
|
|
51
|
+
*
|
|
52
|
+
* @param algorithm - Name of the algorithm producing this result
|
|
53
|
+
* @param startTime - performance.now() timestamp taken before the algorithm began
|
|
54
|
+
* @returns An ExpansionResult with zero paths and zero stats
|
|
55
|
+
*/
|
|
56
|
+
export declare function emptyResult(algorithm: string, startTime: number): ExpansionResult;
|
|
57
|
+
//# sourceMappingURL=base-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-helpers.d.ts","sourceRoot":"","sources":["../../src/expansion/base-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EACX,IAAI,EACJ,aAAa,EACb,eAAe,EACf,cAAc,EACd,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,eAAe,GACrB;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,CAAA;CAAE,CAWzE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC9B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,EACnD,KAAK,EAAE,SAAS,IAAI,EAAE,GACpB,aAAa,GAAG,IAAI,CAuCtB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GACf,eAAe,CAgBjB"}
|
package/dist/expansion/base.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
3
|
+
import { AsyncRunnerOptions } from '../async/types';
|
|
2
4
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Configuration for the async BASE expansion algorithm.
|
|
7
|
+
*
|
|
8
|
+
* Extends ExpansionConfig with async runner options (cancellation, progress,
|
|
9
|
+
* yield strategy).
|
|
10
|
+
*/
|
|
11
|
+
export interface AsyncExpansionConfig<N extends NodeData = NodeData, E extends EdgeData = EdgeData> extends ExpansionConfig<N, E>, AsyncRunnerOptions {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Run BASE expansion synchronously.
|
|
15
|
+
*
|
|
16
|
+
* Delegates to baseCore + runSync. Behaviour is identical to the previous
|
|
17
|
+
* direct implementation — all existing callers are unaffected.
|
|
5
18
|
*
|
|
6
19
|
* @param graph - Source graph
|
|
7
20
|
* @param seeds - Seed nodes for expansion
|
|
@@ -9,4 +22,22 @@ import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
|
9
22
|
* @returns Expansion result with discovered paths
|
|
10
23
|
*/
|
|
11
24
|
export declare function base<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
25
|
+
/**
|
|
26
|
+
* Run BASE expansion asynchronously.
|
|
27
|
+
*
|
|
28
|
+
* Delegates to baseCore + runAsync. Supports:
|
|
29
|
+
* - Cancellation via AbortSignal (config.signal)
|
|
30
|
+
* - Progress callbacks (config.onProgress)
|
|
31
|
+
* - Custom cooperative yield strategies (config.yieldStrategy)
|
|
32
|
+
*
|
|
33
|
+
* Note: priority functions that access `context.graph` are not supported in
|
|
34
|
+
* async mode without a graph proxy (Phase 4b). The default degree-based
|
|
35
|
+
* priority (DOME) does not access context.graph and works correctly.
|
|
36
|
+
*
|
|
37
|
+
* @param graph - Async source graph
|
|
38
|
+
* @param seeds - Seed nodes for expansion
|
|
39
|
+
* @param config - Expansion and async runner configuration
|
|
40
|
+
* @returns Promise resolving to the expansion result
|
|
41
|
+
*/
|
|
42
|
+
export declare function baseAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
12
43
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/expansion/base.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/expansion/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,gBAAgB,CAAC;AAGxE,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CACpC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAC7B,CAAC,SAAS,QAAQ,GAAG,QAAQ,CAE7B,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,kBAAkB;CAAG;AAErD;;;;;;;;;;GAUG;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,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,eAAe,CAYjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACrE,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAC/B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GACjC,OAAO,CAAC,eAAe,CAAC,CA8B1B"}
|
|
@@ -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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AAS,CAAC,CAAC;IAEhE,2CAA2C;IAC3C,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-interfaces.unit.test.d.ts","sourceRoot":"","sources":["../../src/graph/async-interfaces.unit.test.ts"],"names":[],"mappings":""}
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -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"}
|