graphwise 1.6.0 → 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/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/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
|
@@ -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"}
|