graphwise 1.6.0 → 1.8.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 +81 -30
- package/dist/async/index.cjs +243 -0
- package/dist/async/index.cjs.map +1 -0
- package/dist/async/index.js +230 -0
- package/dist/async/index.js.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/expansion/dfs-priority.d.ts +11 -0
- package/dist/expansion/dfs-priority.d.ts.map +1 -1
- package/dist/expansion/dome.d.ts +20 -0
- package/dist/expansion/dome.d.ts.map +1 -1
- package/dist/expansion/edge.d.ts +18 -0
- package/dist/expansion/edge.d.ts.map +1 -1
- package/dist/expansion/flux.d.ts +16 -0
- package/dist/expansion/flux.d.ts.map +1 -1
- package/dist/expansion/frontier-balanced.d.ts +11 -0
- package/dist/expansion/frontier-balanced.d.ts.map +1 -1
- package/dist/expansion/fuse.d.ts +16 -0
- package/dist/expansion/fuse.d.ts.map +1 -1
- package/dist/expansion/hae.d.ts +16 -0
- package/dist/expansion/hae.d.ts.map +1 -1
- package/dist/expansion/lace.d.ts +16 -0
- package/dist/expansion/lace.d.ts.map +1 -1
- package/dist/expansion/maze.d.ts +17 -0
- package/dist/expansion/maze.d.ts.map +1 -1
- package/dist/expansion/pipe.d.ts +16 -0
- package/dist/expansion/pipe.d.ts.map +1 -1
- package/dist/expansion/random-priority.d.ts +18 -0
- package/dist/expansion/random-priority.d.ts.map +1 -1
- package/dist/expansion/reach.d.ts +17 -0
- package/dist/expansion/reach.d.ts.map +1 -1
- package/dist/expansion/sage.d.ts +15 -0
- package/dist/expansion/sage.d.ts.map +1 -1
- package/dist/expansion/sift.d.ts +16 -0
- package/dist/expansion/sift.d.ts.map +1 -1
- package/dist/expansion/standard-bfs.d.ts +11 -0
- package/dist/expansion/standard-bfs.d.ts.map +1 -1
- package/dist/expansion/tide.d.ts +16 -0
- package/dist/expansion/tide.d.ts.map +1 -1
- package/dist/expansion/warp.d.ts +16 -0
- package/dist/expansion/warp.d.ts.map +1 -1
- package/dist/index/index.cjs +1060 -99
- package/dist/index/index.cjs.map +1 -1
- package/dist/index/index.js +1015 -100
- package/dist/index/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/ranking/mi/adamic-adar.d.ts +8 -0
- package/dist/ranking/mi/adamic-adar.d.ts.map +1 -1
- package/dist/ranking/mi/adaptive.d.ts +8 -0
- package/dist/ranking/mi/adaptive.d.ts.map +1 -1
- package/dist/ranking/mi/cosine.d.ts +7 -0
- package/dist/ranking/mi/cosine.d.ts.map +1 -1
- package/dist/ranking/mi/etch.d.ts +8 -0
- package/dist/ranking/mi/etch.d.ts.map +1 -1
- package/dist/ranking/mi/hub-promoted.d.ts +7 -0
- package/dist/ranking/mi/hub-promoted.d.ts.map +1 -1
- package/dist/ranking/mi/jaccard.d.ts +7 -0
- package/dist/ranking/mi/jaccard.d.ts.map +1 -1
- package/dist/ranking/mi/notch.d.ts +8 -0
- package/dist/ranking/mi/notch.d.ts.map +1 -1
- package/dist/ranking/mi/overlap-coefficient.d.ts +7 -0
- package/dist/ranking/mi/overlap-coefficient.d.ts.map +1 -1
- package/dist/ranking/mi/resource-allocation.d.ts +8 -0
- package/dist/ranking/mi/resource-allocation.d.ts.map +1 -1
- package/dist/ranking/mi/scale.d.ts +7 -0
- package/dist/ranking/mi/scale.d.ts.map +1 -1
- package/dist/ranking/mi/skew.d.ts +7 -0
- package/dist/ranking/mi/skew.d.ts.map +1 -1
- package/dist/ranking/mi/sorensen.d.ts +7 -0
- package/dist/ranking/mi/sorensen.d.ts.map +1 -1
- package/dist/ranking/mi/span.d.ts +8 -0
- package/dist/ranking/mi/span.d.ts.map +1 -1
- package/dist/ranking/mi/types.d.ts +12 -0
- package/dist/ranking/mi/types.d.ts.map +1 -1
- package/dist/ranking/parse.d.ts +24 -1
- package/dist/ranking/parse.d.ts.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
//#region src/async/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Async utility functions.
|
|
4
|
+
*
|
|
5
|
+
* @module async/utils
|
|
6
|
+
*/
|
|
7
|
+
/** Collect an AsyncIterable into a readonly array. */
|
|
8
|
+
async function collectAsyncIterable(iter) {
|
|
9
|
+
const result = [];
|
|
10
|
+
for await (const item of iter) result.push(item);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
/** Default yield strategy: setTimeout(0) to yield to the event loop. */
|
|
14
|
+
function defaultYieldStrategy() {
|
|
15
|
+
return new Promise((r) => {
|
|
16
|
+
setTimeout(r, 0);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/async/runners.ts
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a single GraphOp against a synchronous ReadableGraph.
|
|
23
|
+
*
|
|
24
|
+
* Returns a tagged GraphOpResponse so the receiving generator can narrow
|
|
25
|
+
* the result type without type assertions.
|
|
26
|
+
*
|
|
27
|
+
* @param graph - The synchronous graph to query
|
|
28
|
+
* @param op - The operation to resolve
|
|
29
|
+
* @returns The tagged response
|
|
30
|
+
*/
|
|
31
|
+
function resolveSyncOp(graph, op) {
|
|
32
|
+
switch (op.tag) {
|
|
33
|
+
case "neighbours": return {
|
|
34
|
+
tag: "neighbours",
|
|
35
|
+
value: Array.from(graph.neighbours(op.id, op.direction))
|
|
36
|
+
};
|
|
37
|
+
case "degree": return {
|
|
38
|
+
tag: "degree",
|
|
39
|
+
value: graph.degree(op.id, op.direction)
|
|
40
|
+
};
|
|
41
|
+
case "getNode": return {
|
|
42
|
+
tag: "getNode",
|
|
43
|
+
value: graph.getNode(op.id)
|
|
44
|
+
};
|
|
45
|
+
case "getEdge": return {
|
|
46
|
+
tag: "getEdge",
|
|
47
|
+
value: graph.getEdge(op.source, op.target)
|
|
48
|
+
};
|
|
49
|
+
case "hasNode": return {
|
|
50
|
+
tag: "hasNode",
|
|
51
|
+
value: graph.hasNode(op.id)
|
|
52
|
+
};
|
|
53
|
+
case "yield": return { tag: "yield" };
|
|
54
|
+
case "progress": return { tag: "progress" };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Drive a generator to completion using a synchronous graph.
|
|
59
|
+
*
|
|
60
|
+
* The generator yields GraphOp requests; each is resolved immediately
|
|
61
|
+
* against the graph and the tagged response is fed back via gen.next().
|
|
62
|
+
*
|
|
63
|
+
* @param gen - The generator to drive
|
|
64
|
+
* @param graph - The graph to resolve ops against
|
|
65
|
+
* @returns The generator's return value
|
|
66
|
+
*/
|
|
67
|
+
function runSync(gen, graph) {
|
|
68
|
+
let step = gen.next();
|
|
69
|
+
while (step.done !== true) {
|
|
70
|
+
const response = resolveSyncOp(graph, step.value);
|
|
71
|
+
step = gen.next(response);
|
|
72
|
+
}
|
|
73
|
+
return step.value;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolve a single GraphOp against an async ReadableGraph.
|
|
77
|
+
*
|
|
78
|
+
* AsyncIterables (neighbours) are collected into readonly arrays so the
|
|
79
|
+
* generator receives the same value type as in sync mode. Returns a tagged
|
|
80
|
+
* GraphOpResponse for type-safe narrowing without assertions.
|
|
81
|
+
*
|
|
82
|
+
* @param graph - The async graph to query
|
|
83
|
+
* @param op - The operation to resolve
|
|
84
|
+
* @returns A promise resolving to the tagged response
|
|
85
|
+
*/
|
|
86
|
+
async function resolveAsyncOp(graph, op) {
|
|
87
|
+
switch (op.tag) {
|
|
88
|
+
case "neighbours": return {
|
|
89
|
+
tag: "neighbours",
|
|
90
|
+
value: await collectAsyncIterable(graph.neighbours(op.id, op.direction))
|
|
91
|
+
};
|
|
92
|
+
case "degree": return {
|
|
93
|
+
tag: "degree",
|
|
94
|
+
value: await graph.degree(op.id, op.direction)
|
|
95
|
+
};
|
|
96
|
+
case "getNode": return {
|
|
97
|
+
tag: "getNode",
|
|
98
|
+
value: await graph.getNode(op.id)
|
|
99
|
+
};
|
|
100
|
+
case "getEdge": return {
|
|
101
|
+
tag: "getEdge",
|
|
102
|
+
value: await graph.getEdge(op.source, op.target)
|
|
103
|
+
};
|
|
104
|
+
case "hasNode": return {
|
|
105
|
+
tag: "hasNode",
|
|
106
|
+
value: await graph.hasNode(op.id)
|
|
107
|
+
};
|
|
108
|
+
case "yield": return { tag: "yield" };
|
|
109
|
+
case "progress": return { tag: "progress" };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Drive a generator to completion using an async graph.
|
|
114
|
+
*
|
|
115
|
+
* Extends sync semantics with:
|
|
116
|
+
* - Cancellation via AbortSignal (throws DOMException "AbortError")
|
|
117
|
+
* - Cooperative yielding at `yield` ops (calls yieldStrategy)
|
|
118
|
+
* - Progress callbacks at `progress` ops (may be async for backpressure)
|
|
119
|
+
* - Error propagation: graph errors are forwarded via gen.throw(); if the
|
|
120
|
+
* generator does not handle them, they propagate to the caller
|
|
121
|
+
*
|
|
122
|
+
* @param gen - The generator to drive
|
|
123
|
+
* @param graph - The async graph to resolve ops against
|
|
124
|
+
* @param options - Runner configuration
|
|
125
|
+
* @returns A promise resolving to the generator's return value
|
|
126
|
+
*/
|
|
127
|
+
async function runAsync(gen, graph, options) {
|
|
128
|
+
const signal = options?.signal;
|
|
129
|
+
const onProgress = options?.onProgress;
|
|
130
|
+
const yieldStrategy = options?.yieldStrategy ?? defaultYieldStrategy;
|
|
131
|
+
let step = gen.next();
|
|
132
|
+
while (step.done !== true) {
|
|
133
|
+
if (signal?.aborted === true) {
|
|
134
|
+
const abortError = new DOMException("Aborted", "AbortError");
|
|
135
|
+
try {
|
|
136
|
+
gen.throw(abortError);
|
|
137
|
+
} catch {
|
|
138
|
+
throw abortError;
|
|
139
|
+
}
|
|
140
|
+
throw abortError;
|
|
141
|
+
}
|
|
142
|
+
const op = step.value;
|
|
143
|
+
if (op.tag === "yield") {
|
|
144
|
+
await yieldStrategy();
|
|
145
|
+
step = gen.next({ tag: "yield" });
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (op.tag === "progress") {
|
|
149
|
+
if (onProgress !== void 0) {
|
|
150
|
+
const maybePromise = onProgress(op.stats);
|
|
151
|
+
if (maybePromise instanceof Promise) await maybePromise;
|
|
152
|
+
}
|
|
153
|
+
step = gen.next({ tag: "progress" });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
let response;
|
|
157
|
+
try {
|
|
158
|
+
response = await resolveAsyncOp(graph, op);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
step = gen.throw(error);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
step = gen.next(response);
|
|
164
|
+
}
|
|
165
|
+
return step.value;
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/async/ops.ts
|
|
169
|
+
function* opNeighbours(id, direction) {
|
|
170
|
+
const response = yield direction !== void 0 ? {
|
|
171
|
+
tag: "neighbours",
|
|
172
|
+
id,
|
|
173
|
+
direction
|
|
174
|
+
} : {
|
|
175
|
+
tag: "neighbours",
|
|
176
|
+
id
|
|
177
|
+
};
|
|
178
|
+
if (response.tag !== "neighbours") throw new TypeError(`Expected neighbours response, got ${response.tag}`);
|
|
179
|
+
return response.value;
|
|
180
|
+
}
|
|
181
|
+
function* opDegree(id, direction) {
|
|
182
|
+
const response = yield direction !== void 0 ? {
|
|
183
|
+
tag: "degree",
|
|
184
|
+
id,
|
|
185
|
+
direction
|
|
186
|
+
} : {
|
|
187
|
+
tag: "degree",
|
|
188
|
+
id
|
|
189
|
+
};
|
|
190
|
+
if (response.tag !== "degree") throw new TypeError(`Expected degree response, got ${response.tag}`);
|
|
191
|
+
return response.value;
|
|
192
|
+
}
|
|
193
|
+
function* opGetNode(id) {
|
|
194
|
+
const response = yield {
|
|
195
|
+
tag: "getNode",
|
|
196
|
+
id
|
|
197
|
+
};
|
|
198
|
+
if (response.tag !== "getNode") throw new TypeError(`Expected getNode response, got ${response.tag}`);
|
|
199
|
+
return response.value;
|
|
200
|
+
}
|
|
201
|
+
function* opGetEdge(source, target) {
|
|
202
|
+
const response = yield {
|
|
203
|
+
tag: "getEdge",
|
|
204
|
+
source,
|
|
205
|
+
target
|
|
206
|
+
};
|
|
207
|
+
if (response.tag !== "getEdge") throw new TypeError(`Expected getEdge response, got ${response.tag}`);
|
|
208
|
+
return response.value;
|
|
209
|
+
}
|
|
210
|
+
function* opHasNode(id) {
|
|
211
|
+
const response = yield {
|
|
212
|
+
tag: "hasNode",
|
|
213
|
+
id
|
|
214
|
+
};
|
|
215
|
+
if (response.tag !== "hasNode") throw new TypeError(`Expected hasNode response, got ${response.tag}`);
|
|
216
|
+
return response.value;
|
|
217
|
+
}
|
|
218
|
+
function* opYield() {
|
|
219
|
+
yield { tag: "yield" };
|
|
220
|
+
}
|
|
221
|
+
function* opProgress(stats) {
|
|
222
|
+
yield {
|
|
223
|
+
tag: "progress",
|
|
224
|
+
stats
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
export { collectAsyncIterable, defaultYieldStrategy, opDegree, opGetEdge, opGetNode, opHasNode, opNeighbours, opProgress, opYield, resolveAsyncOp, resolveSyncOp, runAsync, runSync };
|
|
229
|
+
|
|
230
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/async/utils.ts","../../src/async/runners.ts","../../src/async/ops.ts"],"sourcesContent":["/**\n * Async utility functions.\n *\n * @module async/utils\n */\n\n/** Collect an AsyncIterable into a readonly array. */\nexport async function collectAsyncIterable<T>(\n\titer: AsyncIterable<T>,\n): Promise<readonly T[]> {\n\tconst result: T[] = [];\n\tfor await (const item of iter) result.push(item);\n\treturn result;\n}\n\n/** Default yield strategy: setTimeout(0) to yield to the event loop. */\nexport function defaultYieldStrategy(): Promise<void> {\n\treturn new Promise((r) => {\n\t\tsetTimeout(r, 0);\n\t});\n}\n","/**\n * Sync and async runners for generator-based graph algorithms.\n *\n * The runner drives a generator that yields GraphOp objects, resolves each op\n * against the graph, and feeds the result back via gen.next(response). This\n * allows algorithm logic to be written once as a generator and executed\n * synchronously or asynchronously depending on the graph backing.\n *\n * @module async/runners\n */\n\nimport type { NodeData, EdgeData, ReadableGraph } from \"../graph\";\nimport type { AsyncReadableGraph } from \"../graph/async-interfaces\";\nimport type { GraphOp, GraphOpResponse } from \"./protocol\";\nimport type { AsyncRunnerOptions } from \"./types\";\nimport { collectAsyncIterable, defaultYieldStrategy } from \"./utils\";\n\n// ---------------------------------------------------------------------------\n// Sync runner\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a single GraphOp against a synchronous ReadableGraph.\n *\n * Returns a tagged GraphOpResponse so the receiving generator can narrow\n * the result type without type assertions.\n *\n * @param graph - The synchronous graph to query\n * @param op - The operation to resolve\n * @returns The tagged response\n */\nexport function resolveSyncOp<N extends NodeData, E extends EdgeData>(\n\tgraph: ReadableGraph<N, E>,\n\top: GraphOp,\n): GraphOpResponse<N, E> {\n\tswitch (op.tag) {\n\t\tcase \"neighbours\":\n\t\t\treturn {\n\t\t\t\ttag: \"neighbours\",\n\t\t\t\tvalue: Array.from(graph.neighbours(op.id, op.direction)),\n\t\t\t};\n\t\tcase \"degree\":\n\t\t\treturn { tag: \"degree\", value: graph.degree(op.id, op.direction) };\n\t\tcase \"getNode\":\n\t\t\treturn { tag: \"getNode\", value: graph.getNode(op.id) };\n\t\tcase \"getEdge\":\n\t\t\treturn { tag: \"getEdge\", value: graph.getEdge(op.source, op.target) };\n\t\tcase \"hasNode\":\n\t\t\treturn { tag: \"hasNode\", value: graph.hasNode(op.id) };\n\t\tcase \"yield\":\n\t\t\treturn { tag: \"yield\" };\n\t\tcase \"progress\":\n\t\t\treturn { tag: \"progress\" };\n\t}\n}\n\n/**\n * Drive a generator to completion using a synchronous graph.\n *\n * The generator yields GraphOp requests; each is resolved immediately\n * against the graph and the tagged response is fed back via gen.next().\n *\n * @param gen - The generator to drive\n * @param graph - The graph to resolve ops against\n * @returns The generator's return value\n */\nexport function runSync<N extends NodeData, E extends EdgeData, R>(\n\tgen: Generator<GraphOp, R, GraphOpResponse<N, E>>,\n\tgraph: ReadableGraph<N, E>,\n): R {\n\tlet step = gen.next();\n\twhile (step.done !== true) {\n\t\tconst response = resolveSyncOp(graph, step.value);\n\t\tstep = gen.next(response);\n\t}\n\treturn step.value;\n}\n\n// ---------------------------------------------------------------------------\n// Async runner\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve a single GraphOp against an async ReadableGraph.\n *\n * AsyncIterables (neighbours) are collected into readonly arrays so the\n * generator receives the same value type as in sync mode. Returns a tagged\n * GraphOpResponse for type-safe narrowing without assertions.\n *\n * @param graph - The async graph to query\n * @param op - The operation to resolve\n * @returns A promise resolving to the tagged response\n */\nexport async function resolveAsyncOp<N extends NodeData, E extends EdgeData>(\n\tgraph: AsyncReadableGraph<N, E>,\n\top: GraphOp,\n): Promise<GraphOpResponse<N, E>> {\n\tswitch (op.tag) {\n\t\tcase \"neighbours\":\n\t\t\treturn {\n\t\t\t\ttag: \"neighbours\",\n\t\t\t\tvalue: await collectAsyncIterable(\n\t\t\t\t\tgraph.neighbours(op.id, op.direction),\n\t\t\t\t),\n\t\t\t};\n\t\tcase \"degree\":\n\t\t\treturn { tag: \"degree\", value: await graph.degree(op.id, op.direction) };\n\t\tcase \"getNode\":\n\t\t\treturn { tag: \"getNode\", value: await graph.getNode(op.id) };\n\t\tcase \"getEdge\":\n\t\t\treturn {\n\t\t\t\ttag: \"getEdge\",\n\t\t\t\tvalue: await graph.getEdge(op.source, op.target),\n\t\t\t};\n\t\tcase \"hasNode\":\n\t\t\treturn { tag: \"hasNode\", value: await graph.hasNode(op.id) };\n\t\tcase \"yield\":\n\t\t\treturn { tag: \"yield\" };\n\t\tcase \"progress\":\n\t\t\treturn { tag: \"progress\" };\n\t}\n}\n\n/**\n * Drive a generator to completion using an async graph.\n *\n * Extends sync semantics with:\n * - Cancellation via AbortSignal (throws DOMException \"AbortError\")\n * - Cooperative yielding at `yield` ops (calls yieldStrategy)\n * - Progress callbacks at `progress` ops (may be async for backpressure)\n * - Error propagation: graph errors are forwarded via gen.throw(); if the\n * generator does not handle them, they propagate to the caller\n *\n * @param gen - The generator to drive\n * @param graph - The async graph to resolve ops against\n * @param options - Runner configuration\n * @returns A promise resolving to the generator's return value\n */\nexport async function runAsync<N extends NodeData, E extends EdgeData, R>(\n\tgen: Generator<GraphOp, R, GraphOpResponse<N, E>>,\n\tgraph: AsyncReadableGraph<N, E>,\n\toptions?: AsyncRunnerOptions,\n): Promise<R> {\n\tconst signal = options?.signal;\n\tconst onProgress = options?.onProgress;\n\tconst yieldStrategy = options?.yieldStrategy ?? defaultYieldStrategy;\n\n\tlet step = gen.next();\n\n\twhile (step.done !== true) {\n\t\t// Check for cancellation before processing each op. Throw the error\n\t\t// into the generator so that any finally blocks in the algorithm run\n\t\t// before the error propagates to the caller.\n\t\tif (signal?.aborted === true) {\n\t\t\tconst abortError = new DOMException(\"Aborted\", \"AbortError\");\n\t\t\ttry {\n\t\t\t\tgen.throw(abortError);\n\t\t\t} catch {\n\t\t\t\t// Generator did not handle the error — propagate it\n\t\t\t\tthrow abortError;\n\t\t\t}\n\t\t\t// Generator handled the error but we still honour cancellation\n\t\t\tthrow abortError;\n\t\t}\n\n\t\tconst op = step.value;\n\n\t\t// Handle cooperative yield ops without hitting the graph\n\t\tif (op.tag === \"yield\") {\n\t\t\tawait yieldStrategy();\n\t\t\tstep = gen.next({ tag: \"yield\" });\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Handle progress ops: call the callback (awaiting if async)\n\t\tif (op.tag === \"progress\") {\n\t\t\tif (onProgress !== undefined) {\n\t\t\t\tconst maybePromise = onProgress(op.stats);\n\t\t\t\tif (maybePromise instanceof Promise) {\n\t\t\t\t\tawait maybePromise;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstep = gen.next({ tag: \"progress\" });\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Resolve graph ops, forwarding any errors into the generator\n\t\tlet response: GraphOpResponse<N, E>;\n\t\ttry {\n\t\t\tresponse = await resolveAsyncOp(graph, op);\n\t\t} catch (error) {\n\t\t\t// Forward the error into the generator; if unhandled, it propagates\n\t\t\tstep = gen.throw(error);\n\t\t\tcontinue;\n\t\t}\n\n\t\tstep = gen.next(response);\n\t}\n\n\treturn step.value;\n}\n","/**\n * Type-safe yield helpers for graph operations.\n *\n * Each function is a sub-generator that yields one GraphOp and returns\n * the correctly-typed result. Narrowing is done via the tagged discriminated\n * union in GraphOpResponse — no type assertions needed.\n *\n * Use with `yield*` inside algorithm generators.\n *\n * @module async/ops\n */\n\nimport type { NodeId, NodeData, EdgeData, Direction } from \"../graph\";\nimport type { GraphOp, GraphOpResponse, ProgressStats } from \"./protocol\";\n\nexport function* opNeighbours<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(\n\tid: NodeId,\n\tdirection?: Direction,\n): Generator<GraphOp, readonly NodeId[], GraphOpResponse<N, E>> {\n\tconst op: GraphOp =\n\t\tdirection !== undefined\n\t\t\t? { tag: \"neighbours\", id, direction }\n\t\t\t: { tag: \"neighbours\", id };\n\tconst response: GraphOpResponse<N, E> = yield op;\n\tif (response.tag !== \"neighbours\") {\n\t\tthrow new TypeError(`Expected neighbours response, got ${response.tag}`);\n\t}\n\treturn response.value;\n}\n\nexport function* opDegree<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(\n\tid: NodeId,\n\tdirection?: Direction,\n): Generator<GraphOp, number, GraphOpResponse<N, E>> {\n\tconst op: GraphOp =\n\t\tdirection !== undefined\n\t\t\t? { tag: \"degree\", id, direction }\n\t\t\t: { tag: \"degree\", id };\n\tconst response: GraphOpResponse<N, E> = yield op;\n\tif (response.tag !== \"degree\") {\n\t\tthrow new TypeError(`Expected degree response, got ${response.tag}`);\n\t}\n\treturn response.value;\n}\n\nexport function* opGetNode<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(id: NodeId): Generator<GraphOp, N | undefined, GraphOpResponse<N, E>> {\n\tconst response: GraphOpResponse<N, E> = yield { tag: \"getNode\", id };\n\tif (response.tag !== \"getNode\") {\n\t\tthrow new TypeError(`Expected getNode response, got ${response.tag}`);\n\t}\n\treturn response.value;\n}\n\nexport function* opGetEdge<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(\n\tsource: NodeId,\n\ttarget: NodeId,\n): Generator<GraphOp, E | undefined, GraphOpResponse<N, E>> {\n\tconst response: GraphOpResponse<N, E> = yield {\n\t\ttag: \"getEdge\",\n\t\tsource,\n\t\ttarget,\n\t};\n\tif (response.tag !== \"getEdge\") {\n\t\tthrow new TypeError(`Expected getEdge response, got ${response.tag}`);\n\t}\n\treturn response.value;\n}\n\nexport function* opHasNode<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(id: NodeId): Generator<GraphOp, boolean, GraphOpResponse<N, E>> {\n\tconst response: GraphOpResponse<N, E> = yield { tag: \"hasNode\", id };\n\tif (response.tag !== \"hasNode\") {\n\t\tthrow new TypeError(`Expected hasNode response, got ${response.tag}`);\n\t}\n\treturn response.value;\n}\n\nexport function* opYield<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(): Generator<GraphOp, void, GraphOpResponse<N, E>> {\n\tyield { tag: \"yield\" };\n}\n\nexport function* opProgress<\n\tN extends NodeData = NodeData,\n\tE extends EdgeData = EdgeData,\n>(stats: ProgressStats): Generator<GraphOp, void, GraphOpResponse<N, E>> {\n\tyield { tag: \"progress\", stats };\n}\n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AAiB,aAIhB,IACA,WAC+D;CAK/D,MAAM,WAAkC,MAHvC,cAAc,KAAA,IACX;EAAE,KAAK;EAAc;EAAI;EAAW,GACpC;EAAE,KAAK;EAAc;EAAI;AAE7B,KAAI,SAAS,QAAQ,aACpB,OAAM,IAAI,UAAU,qCAAqC,SAAS,MAAM;AAEzE,QAAO,SAAS;;AAGjB,UAAiB,SAIhB,IACA,WACoD;CAKpD,MAAM,WAAkC,MAHvC,cAAc,KAAA,IACX;EAAE,KAAK;EAAU;EAAI;EAAW,GAChC;EAAE,KAAK;EAAU;EAAI;AAEzB,KAAI,SAAS,QAAQ,SACpB,OAAM,IAAI,UAAU,iCAAiC,SAAS,MAAM;AAErE,QAAO,SAAS;;AAGjB,UAAiB,UAGf,IAAsE;CACvE,MAAM,WAAkC,MAAM;EAAE,KAAK;EAAW;EAAI;AACpE,KAAI,SAAS,QAAQ,UACpB,OAAM,IAAI,UAAU,kCAAkC,SAAS,MAAM;AAEtE,QAAO,SAAS;;AAGjB,UAAiB,UAIhB,QACA,QAC2D;CAC3D,MAAM,WAAkC,MAAM;EAC7C,KAAK;EACL;EACA;EACA;AACD,KAAI,SAAS,QAAQ,UACpB,OAAM,IAAI,UAAU,kCAAkC,SAAS,MAAM;AAEtE,QAAO,SAAS;;AAGjB,UAAiB,UAGf,IAAgE;CACjE,MAAM,WAAkC,MAAM;EAAE,KAAK;EAAW;EAAI;AACpE,KAAI,SAAS,QAAQ,UACpB,OAAM,IAAI,UAAU,kCAAkC,SAAS,MAAM;AAEtE,QAAO,SAAS;;AAGjB,UAAiB,UAGoC;AACpD,OAAM,EAAE,KAAK,SAAS;;AAGvB,UAAiB,WAGf,OAAuE;AACxE,OAAM;EAAE,KAAK;EAAY;EAAO"}
|
|
@@ -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"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig, PriorityContext } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* DFS priority function: negative iteration produces LIFO ordering.
|
|
5
7
|
*
|
|
@@ -20,4 +22,13 @@ export declare function dfsPriorityFn<N extends NodeData, E extends EdgeData>(_n
|
|
|
20
22
|
* @returns Expansion result with discovered paths
|
|
21
23
|
*/
|
|
22
24
|
export declare function dfsPriority<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
25
|
+
/**
|
|
26
|
+
* Run DFS-priority expansion asynchronously (LIFO discovery order).
|
|
27
|
+
*
|
|
28
|
+
* @param graph - Async source graph
|
|
29
|
+
* @param seeds - Seed nodes for expansion
|
|
30
|
+
* @param config - Expansion and async runner configuration
|
|
31
|
+
* @returns Promise resolving to the expansion result
|
|
32
|
+
*/
|
|
33
|
+
export declare function dfsPriorityAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
23
34
|
//# sourceMappingURL=dfs-priority.d.ts.map
|
|
@@ -1 +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;
|
|
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,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EACf,eAAe,EACf,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAEnD;;;;;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;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EAC5E,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,CAE1B"}
|
package/dist/expansion/dome.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* Run DOME expansion (degree-ordered).
|
|
5
7
|
*
|
|
@@ -9,8 +11,26 @@ import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
|
9
11
|
* @returns Expansion result with discovered paths
|
|
10
12
|
*/
|
|
11
13
|
export declare function dome<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
14
|
+
/**
|
|
15
|
+
* Run DOME expansion asynchronously (degree-ordered).
|
|
16
|
+
*
|
|
17
|
+
* @param graph - Async source graph
|
|
18
|
+
* @param seeds - Seed nodes for expansion
|
|
19
|
+
* @param config - Expansion and async runner configuration
|
|
20
|
+
* @returns Promise resolving to the expansion result
|
|
21
|
+
*/
|
|
22
|
+
export declare function domeAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
12
23
|
/**
|
|
13
24
|
* DOME with reverse priority (high degree first).
|
|
14
25
|
*/
|
|
15
26
|
export declare function domeHighDegree<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
27
|
+
/**
|
|
28
|
+
* Run DOME high-degree expansion asynchronously (high degree first).
|
|
29
|
+
*
|
|
30
|
+
* @param graph - Async source graph
|
|
31
|
+
* @param seeds - Seed nodes for expansion
|
|
32
|
+
* @param config - Expansion and async runner configuration
|
|
33
|
+
* @returns Promise resolving to the expansion result
|
|
34
|
+
*/
|
|
35
|
+
export declare function domeHighDegreeAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
16
36
|
//# sourceMappingURL=dome.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dome.d.ts","sourceRoot":"","sources":["../../src/expansion/dome.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"dome.d.ts","sourceRoot":"","sources":["../../src/expansion/dome.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAsBnD;;;;;;;GAOG;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,CAKjB;AAED;;;;;;;GAOG;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,CAE1B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACpE,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;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,QAAQ,EAElB,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,CAK1B"}
|
package/dist/expansion/edge.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* Run EDGE expansion (Entropy-Driven Graph Expansion).
|
|
5
7
|
*
|
|
@@ -12,4 +14,20 @@ import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
|
12
14
|
* @returns Expansion result with discovered paths
|
|
13
15
|
*/
|
|
14
16
|
export declare function edge<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
17
|
+
/**
|
|
18
|
+
* Run EDGE expansion asynchronously.
|
|
19
|
+
*
|
|
20
|
+
* Delegates to `haeAsync` with the default `node.type` mapper.
|
|
21
|
+
*
|
|
22
|
+
* Note: the HAE priority function accesses `context.graph` to retrieve
|
|
23
|
+
* neighbour types. Full async equivalence requires PriorityContext
|
|
24
|
+
* refactoring (Phase 4b deferred). This export establishes the async API
|
|
25
|
+
* surface; use with a `wrapAsync`-wrapped sync graph for testing.
|
|
26
|
+
*
|
|
27
|
+
* @param graph - Async source graph
|
|
28
|
+
* @param seeds - Seed nodes for expansion
|
|
29
|
+
* @param config - Expansion and async runner configuration
|
|
30
|
+
* @returns Promise resolving to the expansion result
|
|
31
|
+
*/
|
|
32
|
+
export declare function edgeAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
15
33
|
//# sourceMappingURL=edge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/expansion/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/expansion/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAOnD;;;;;;;;;;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,CAKjB;AAED;;;;;;;;;;;;;;GAcG;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,CAK1B"}
|
package/dist/expansion/flux.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* Configuration for MAZE expansion.
|
|
5
7
|
*/
|
|
@@ -22,4 +24,18 @@ export interface MAZEConfig<N extends NodeData = NodeData, E extends EdgeData =
|
|
|
22
24
|
* @returns Expansion result with discovered paths
|
|
23
25
|
*/
|
|
24
26
|
export declare function flux<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: MAZEConfig<N, E>): ExpansionResult;
|
|
27
|
+
/**
|
|
28
|
+
* Run FLUX expansion asynchronously.
|
|
29
|
+
*
|
|
30
|
+
* Note: the FLUX priority function accesses `context.graph` to compute
|
|
31
|
+
* local density and cross-frontier bridge scores. Full async equivalence
|
|
32
|
+
* requires PriorityContext refactoring (Phase 4b deferred). This export
|
|
33
|
+
* establishes the async API surface.
|
|
34
|
+
*
|
|
35
|
+
* @param graph - Async source graph
|
|
36
|
+
* @param seeds - Seed nodes for expansion
|
|
37
|
+
* @param config - FLUX (MAZEConfig) configuration combined with async runner options
|
|
38
|
+
* @returns Promise resolving to the expansion result
|
|
39
|
+
*/
|
|
40
|
+
export declare function fluxAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: MAZEConfig<N, E> & AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
25
41
|
//# sourceMappingURL=flux.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flux.d.ts","sourceRoot":"","sources":["../../src/expansion/flux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"flux.d.ts","sourceRoot":"","sources":["../../src/expansion/flux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAA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graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* Run frontier-balanced expansion (round-robin across frontiers).
|
|
5
7
|
*
|
|
@@ -9,4 +11,13 @@ import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
|
9
11
|
* @returns Expansion result with discovered paths
|
|
10
12
|
*/
|
|
11
13
|
export declare function frontierBalanced<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: ExpansionConfig<N, E>): ExpansionResult;
|
|
14
|
+
/**
|
|
15
|
+
* Run frontier-balanced expansion asynchronously (round-robin across frontiers).
|
|
16
|
+
*
|
|
17
|
+
* @param graph - Async source graph
|
|
18
|
+
* @param seeds - Seed nodes for expansion
|
|
19
|
+
* @param config - Expansion and async runner configuration
|
|
20
|
+
* @returns Promise resolving to the expansion result
|
|
21
|
+
*/
|
|
22
|
+
export declare function frontierBalancedAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
12
23
|
//# sourceMappingURL=frontier-balanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontier-balanced.d.ts","sourceRoot":"","sources":["../../src/expansion/frontier-balanced.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"frontier-balanced.d.ts","sourceRoot":"","sources":["../../src/expansion/frontier-balanced.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAanD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ,EACtE,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;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAC1C,CAAC,SAAS,QAAQ,EAClB,CAAC,SAAS,QAAQ,EAElB,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,CAE1B"}
|
package/dist/expansion/fuse.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NodeData, EdgeData, ReadableGraph } from '../graph';
|
|
2
|
+
import { AsyncReadableGraph } from '../graph/async-interfaces';
|
|
2
3
|
import { Seed, ExpansionResult, ExpansionConfig } from './types';
|
|
4
|
+
import { AsyncExpansionConfig } from './base';
|
|
3
5
|
/**
|
|
4
6
|
* Configuration for FUSE expansion.
|
|
5
7
|
*/
|
|
@@ -25,4 +27,18 @@ export type SAGEConfig<N extends NodeData = NodeData, E extends EdgeData = EdgeD
|
|
|
25
27
|
* @returns Expansion result with discovered paths
|
|
26
28
|
*/
|
|
27
29
|
export declare function fuse<N extends NodeData, E extends EdgeData>(graph: ReadableGraph<N, E>, seeds: readonly Seed[], config?: FUSEConfig<N, E>): ExpansionResult;
|
|
30
|
+
/**
|
|
31
|
+
* Run FUSE expansion asynchronously.
|
|
32
|
+
*
|
|
33
|
+
* Note: the FUSE priority function accesses `context.graph` via
|
|
34
|
+
* `avgFrontierMI`. Full async equivalence requires PriorityContext
|
|
35
|
+
* refactoring (Phase 4b deferred). This export establishes the async
|
|
36
|
+
* API surface.
|
|
37
|
+
*
|
|
38
|
+
* @param graph - Async source graph
|
|
39
|
+
* @param seeds - Seed nodes for expansion
|
|
40
|
+
* @param config - FUSE configuration combined with async runner options
|
|
41
|
+
* @returns Promise resolving to the expansion result
|
|
42
|
+
*/
|
|
43
|
+
export declare function fuseAsync<N extends NodeData, E extends EdgeData>(graph: AsyncReadableGraph<N, E>, seeds: readonly Seed[], config?: FUSEConfig<N, E> & AsyncExpansionConfig<N, E>): Promise<ExpansionResult>;
|
|
28
44
|
//# sourceMappingURL=fuse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fuse.d.ts","sourceRoot":"","sources":["../../src/expansion/fuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"fuse.d.ts","sourceRoot":"","sources":["../../src/expansion/fuse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;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,EACX,IAAI,EACJ,eAAe,EACf,eAAe,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,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