graphwise 1.8.0 → 1.9.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/adjacency-map-BtKzcuJq.js +229 -0
- package/dist/adjacency-map-BtKzcuJq.js.map +1 -0
- package/dist/adjacency-map-JqBnMNkF.cjs +234 -0
- package/dist/adjacency-map-JqBnMNkF.cjs.map +1 -0
- package/dist/async/index.cjs +15 -242
- package/dist/async/index.js +2 -229
- package/dist/expansion/index.cjs +43 -0
- package/dist/expansion/index.js +2 -0
- package/dist/expansion-ClDhlMK8.js +1704 -0
- package/dist/expansion-ClDhlMK8.js.map +1 -0
- package/dist/expansion-DaTroIyv.cjs +1949 -0
- package/dist/expansion-DaTroIyv.cjs.map +1 -0
- package/dist/extraction/index.cjs +630 -0
- package/dist/extraction/index.cjs.map +1 -0
- package/dist/extraction/index.js +621 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/gpu/csr.d.ts +29 -30
- package/dist/gpu/csr.d.ts.map +1 -1
- package/dist/gpu/dispatch.d.ts +31 -0
- package/dist/gpu/dispatch.d.ts.map +1 -0
- package/dist/gpu/dispatch.unit.test.d.ts +5 -0
- package/dist/gpu/dispatch.unit.test.d.ts.map +1 -0
- package/dist/gpu/index.cjs +15 -410
- package/dist/gpu/index.d.ts +3 -1
- package/dist/gpu/index.d.ts.map +1 -1
- package/dist/gpu/index.js +2 -400
- package/dist/gpu/kernels/bfs/kernel.d.ts +59 -0
- package/dist/gpu/kernels/bfs/kernel.d.ts.map +1 -0
- package/dist/gpu/kernels/bfs/logic.d.ts +47 -0
- package/dist/gpu/kernels/bfs/logic.d.ts.map +1 -0
- package/dist/gpu/kernels/bfs/logic.unit.test.d.ts +2 -0
- package/dist/gpu/kernels/bfs/logic.unit.test.d.ts.map +1 -0
- package/dist/gpu/kernels/degree-histogram/kernel.d.ts +32 -0
- package/dist/gpu/kernels/degree-histogram/kernel.d.ts.map +1 -0
- package/dist/gpu/kernels/degree-histogram/logic.d.ts +45 -0
- package/dist/gpu/kernels/degree-histogram/logic.d.ts.map +1 -0
- package/dist/gpu/kernels/degree-histogram/logic.unit.test.d.ts +2 -0
- package/dist/gpu/kernels/degree-histogram/logic.unit.test.d.ts.map +1 -0
- package/dist/gpu/kernels/jaccard/kernel.d.ts +40 -0
- package/dist/gpu/kernels/jaccard/kernel.d.ts.map +1 -0
- package/dist/gpu/kernels/jaccard/logic.d.ts +43 -0
- package/dist/gpu/kernels/jaccard/logic.d.ts.map +1 -0
- package/dist/gpu/kernels/jaccard/logic.unit.test.d.ts +2 -0
- package/dist/gpu/kernels/jaccard/logic.unit.test.d.ts.map +1 -0
- package/dist/gpu/kernels/pagerank/kernel.d.ts +44 -0
- package/dist/gpu/kernels/pagerank/kernel.d.ts.map +1 -0
- package/dist/gpu/kernels/pagerank/logic.d.ts +50 -0
- package/dist/gpu/kernels/pagerank/logic.d.ts.map +1 -0
- package/dist/gpu/kernels/pagerank/logic.unit.test.d.ts +2 -0
- package/dist/gpu/kernels/pagerank/logic.unit.test.d.ts.map +1 -0
- package/dist/gpu/kernels/spmv/kernel.d.ts +43 -0
- package/dist/gpu/kernels/spmv/kernel.d.ts.map +1 -0
- package/dist/gpu/kernels/spmv/logic.d.ts +31 -0
- package/dist/gpu/kernels/spmv/logic.d.ts.map +1 -0
- package/dist/gpu/kernels/spmv/logic.unit.test.d.ts +2 -0
- package/dist/gpu/kernels/spmv/logic.unit.test.d.ts.map +1 -0
- package/dist/gpu/operations.d.ts +76 -0
- package/dist/gpu/operations.d.ts.map +1 -0
- package/dist/gpu/operations.unit.test.d.ts +5 -0
- package/dist/gpu/operations.unit.test.d.ts.map +1 -0
- package/dist/gpu/root.d.ts +53 -0
- package/dist/gpu/root.d.ts.map +1 -0
- package/dist/gpu/root.unit.test.d.ts +2 -0
- package/dist/gpu/root.unit.test.d.ts.map +1 -0
- package/dist/gpu/types.d.ts +3 -8
- package/dist/gpu/types.d.ts.map +1 -1
- package/dist/gpu-CHiCN0wa.js +16945 -0
- package/dist/gpu-CHiCN0wa.js.map +1 -0
- package/dist/gpu-Y6owRVMi.cjs +17028 -0
- package/dist/gpu-Y6owRVMi.cjs.map +1 -0
- package/dist/graph/index.cjs +2 -229
- package/dist/graph/index.js +1 -228
- package/dist/index/index.cjs +141 -4040
- package/dist/index/index.js +15 -3917
- package/dist/jaccard-3rCdilwm.js +39 -0
- package/dist/jaccard-3rCdilwm.js.map +1 -0
- package/dist/jaccard-Bys9_dGW.cjs +50 -0
- package/dist/jaccard-Bys9_dGW.cjs.map +1 -0
- package/dist/{kmeans-BIgSyGKu.cjs → kmeans-B8x9D1kt.cjs} +1 -1
- package/dist/{kmeans-BIgSyGKu.cjs.map → kmeans-B8x9D1kt.cjs.map} +1 -1
- package/dist/{kmeans-87ExSUNZ.js → kmeans-DKkL9rAN.js} +1 -1
- package/dist/{kmeans-87ExSUNZ.js.map → kmeans-DKkL9rAN.js.map} +1 -1
- package/dist/ops-djAsQQSh.cjs +277 -0
- package/dist/ops-djAsQQSh.cjs.map +1 -0
- package/dist/ops-upIi6JIi.js +212 -0
- package/dist/ops-upIi6JIi.js.map +1 -0
- package/dist/priority-queue-BIiD1L0k.cjs +148 -0
- package/dist/priority-queue-BIiD1L0k.cjs.map +1 -0
- package/dist/priority-queue-CFDd5cBg.js +143 -0
- package/dist/priority-queue-CFDd5cBg.js.map +1 -0
- package/dist/ranking/index.cjs +43 -0
- package/dist/ranking/index.js +4 -0
- package/dist/ranking/mi/index.cjs +581 -0
- package/dist/ranking/mi/index.cjs.map +1 -0
- package/dist/ranking/mi/index.js +555 -0
- package/dist/ranking/mi/index.js.map +1 -0
- package/dist/ranking-3ez5m67U.js +1016 -0
- package/dist/ranking-3ez5m67U.js.map +1 -0
- package/dist/ranking-DVvajgUZ.cjs +1093 -0
- package/dist/ranking-DVvajgUZ.cjs.map +1 -0
- package/dist/seeds/index.cjs +1 -1
- package/dist/seeds/index.js +1 -1
- package/dist/structures/index.cjs +2 -143
- package/dist/structures/index.js +1 -142
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils-BodeE2Mo.js +22 -0
- package/dist/utils-BodeE2Mo.js.map +1 -0
- package/dist/utils-CDtCcsyF.cjs +33 -0
- package/dist/utils-CDtCcsyF.cjs.map +1 -0
- package/package.json +3 -1
- package/dist/async/index.cjs.map +0 -1
- package/dist/async/index.js.map +0 -1
- package/dist/gpu/context.d.ts +0 -118
- package/dist/gpu/context.d.ts.map +0 -1
- package/dist/gpu/context.unit.test.d.ts +0 -2
- package/dist/gpu/context.unit.test.d.ts.map +0 -1
- package/dist/gpu/index.cjs.map +0 -1
- package/dist/gpu/index.js.map +0 -1
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.js.map +0 -1
- package/dist/index/index.cjs.map +0 -1
- package/dist/index/index.js.map +0 -1
- package/dist/structures/index.cjs.map +0 -1
- package/dist/structures/index.js.map +0 -1
package/dist/async/index.cjs
CHANGED
|
@@ -1,243 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
setTimeout(r, 0);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/async/runners.ts
|
|
22
|
-
/**
|
|
23
|
-
* Resolve a single GraphOp against a synchronous ReadableGraph.
|
|
24
|
-
*
|
|
25
|
-
* Returns a tagged GraphOpResponse so the receiving generator can narrow
|
|
26
|
-
* the result type without type assertions.
|
|
27
|
-
*
|
|
28
|
-
* @param graph - The synchronous graph to query
|
|
29
|
-
* @param op - The operation to resolve
|
|
30
|
-
* @returns The tagged response
|
|
31
|
-
*/
|
|
32
|
-
function resolveSyncOp(graph, op) {
|
|
33
|
-
switch (op.tag) {
|
|
34
|
-
case "neighbours": return {
|
|
35
|
-
tag: "neighbours",
|
|
36
|
-
value: Array.from(graph.neighbours(op.id, op.direction))
|
|
37
|
-
};
|
|
38
|
-
case "degree": return {
|
|
39
|
-
tag: "degree",
|
|
40
|
-
value: graph.degree(op.id, op.direction)
|
|
41
|
-
};
|
|
42
|
-
case "getNode": return {
|
|
43
|
-
tag: "getNode",
|
|
44
|
-
value: graph.getNode(op.id)
|
|
45
|
-
};
|
|
46
|
-
case "getEdge": return {
|
|
47
|
-
tag: "getEdge",
|
|
48
|
-
value: graph.getEdge(op.source, op.target)
|
|
49
|
-
};
|
|
50
|
-
case "hasNode": return {
|
|
51
|
-
tag: "hasNode",
|
|
52
|
-
value: graph.hasNode(op.id)
|
|
53
|
-
};
|
|
54
|
-
case "yield": return { tag: "yield" };
|
|
55
|
-
case "progress": return { tag: "progress" };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Drive a generator to completion using a synchronous graph.
|
|
60
|
-
*
|
|
61
|
-
* The generator yields GraphOp requests; each is resolved immediately
|
|
62
|
-
* against the graph and the tagged response is fed back via gen.next().
|
|
63
|
-
*
|
|
64
|
-
* @param gen - The generator to drive
|
|
65
|
-
* @param graph - The graph to resolve ops against
|
|
66
|
-
* @returns The generator's return value
|
|
67
|
-
*/
|
|
68
|
-
function runSync(gen, graph) {
|
|
69
|
-
let step = gen.next();
|
|
70
|
-
while (step.done !== true) {
|
|
71
|
-
const response = resolveSyncOp(graph, step.value);
|
|
72
|
-
step = gen.next(response);
|
|
73
|
-
}
|
|
74
|
-
return step.value;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Resolve a single GraphOp against an async ReadableGraph.
|
|
78
|
-
*
|
|
79
|
-
* AsyncIterables (neighbours) are collected into readonly arrays so the
|
|
80
|
-
* generator receives the same value type as in sync mode. Returns a tagged
|
|
81
|
-
* GraphOpResponse for type-safe narrowing without assertions.
|
|
82
|
-
*
|
|
83
|
-
* @param graph - The async graph to query
|
|
84
|
-
* @param op - The operation to resolve
|
|
85
|
-
* @returns A promise resolving to the tagged response
|
|
86
|
-
*/
|
|
87
|
-
async function resolveAsyncOp(graph, op) {
|
|
88
|
-
switch (op.tag) {
|
|
89
|
-
case "neighbours": return {
|
|
90
|
-
tag: "neighbours",
|
|
91
|
-
value: await collectAsyncIterable(graph.neighbours(op.id, op.direction))
|
|
92
|
-
};
|
|
93
|
-
case "degree": return {
|
|
94
|
-
tag: "degree",
|
|
95
|
-
value: await graph.degree(op.id, op.direction)
|
|
96
|
-
};
|
|
97
|
-
case "getNode": return {
|
|
98
|
-
tag: "getNode",
|
|
99
|
-
value: await graph.getNode(op.id)
|
|
100
|
-
};
|
|
101
|
-
case "getEdge": return {
|
|
102
|
-
tag: "getEdge",
|
|
103
|
-
value: await graph.getEdge(op.source, op.target)
|
|
104
|
-
};
|
|
105
|
-
case "hasNode": return {
|
|
106
|
-
tag: "hasNode",
|
|
107
|
-
value: await graph.hasNode(op.id)
|
|
108
|
-
};
|
|
109
|
-
case "yield": return { tag: "yield" };
|
|
110
|
-
case "progress": return { tag: "progress" };
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Drive a generator to completion using an async graph.
|
|
115
|
-
*
|
|
116
|
-
* Extends sync semantics with:
|
|
117
|
-
* - Cancellation via AbortSignal (throws DOMException "AbortError")
|
|
118
|
-
* - Cooperative yielding at `yield` ops (calls yieldStrategy)
|
|
119
|
-
* - Progress callbacks at `progress` ops (may be async for backpressure)
|
|
120
|
-
* - Error propagation: graph errors are forwarded via gen.throw(); if the
|
|
121
|
-
* generator does not handle them, they propagate to the caller
|
|
122
|
-
*
|
|
123
|
-
* @param gen - The generator to drive
|
|
124
|
-
* @param graph - The async graph to resolve ops against
|
|
125
|
-
* @param options - Runner configuration
|
|
126
|
-
* @returns A promise resolving to the generator's return value
|
|
127
|
-
*/
|
|
128
|
-
async function runAsync(gen, graph, options) {
|
|
129
|
-
const signal = options?.signal;
|
|
130
|
-
const onProgress = options?.onProgress;
|
|
131
|
-
const yieldStrategy = options?.yieldStrategy ?? defaultYieldStrategy;
|
|
132
|
-
let step = gen.next();
|
|
133
|
-
while (step.done !== true) {
|
|
134
|
-
if (signal?.aborted === true) {
|
|
135
|
-
const abortError = new DOMException("Aborted", "AbortError");
|
|
136
|
-
try {
|
|
137
|
-
gen.throw(abortError);
|
|
138
|
-
} catch {
|
|
139
|
-
throw abortError;
|
|
140
|
-
}
|
|
141
|
-
throw abortError;
|
|
142
|
-
}
|
|
143
|
-
const op = step.value;
|
|
144
|
-
if (op.tag === "yield") {
|
|
145
|
-
await yieldStrategy();
|
|
146
|
-
step = gen.next({ tag: "yield" });
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (op.tag === "progress") {
|
|
150
|
-
if (onProgress !== void 0) {
|
|
151
|
-
const maybePromise = onProgress(op.stats);
|
|
152
|
-
if (maybePromise instanceof Promise) await maybePromise;
|
|
153
|
-
}
|
|
154
|
-
step = gen.next({ tag: "progress" });
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
let response;
|
|
158
|
-
try {
|
|
159
|
-
response = await resolveAsyncOp(graph, op);
|
|
160
|
-
} catch (error) {
|
|
161
|
-
step = gen.throw(error);
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
step = gen.next(response);
|
|
165
|
-
}
|
|
166
|
-
return step.value;
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/async/ops.ts
|
|
170
|
-
function* opNeighbours(id, direction) {
|
|
171
|
-
const response = yield direction !== void 0 ? {
|
|
172
|
-
tag: "neighbours",
|
|
173
|
-
id,
|
|
174
|
-
direction
|
|
175
|
-
} : {
|
|
176
|
-
tag: "neighbours",
|
|
177
|
-
id
|
|
178
|
-
};
|
|
179
|
-
if (response.tag !== "neighbours") throw new TypeError(`Expected neighbours response, got ${response.tag}`);
|
|
180
|
-
return response.value;
|
|
181
|
-
}
|
|
182
|
-
function* opDegree(id, direction) {
|
|
183
|
-
const response = yield direction !== void 0 ? {
|
|
184
|
-
tag: "degree",
|
|
185
|
-
id,
|
|
186
|
-
direction
|
|
187
|
-
} : {
|
|
188
|
-
tag: "degree",
|
|
189
|
-
id
|
|
190
|
-
};
|
|
191
|
-
if (response.tag !== "degree") throw new TypeError(`Expected degree response, got ${response.tag}`);
|
|
192
|
-
return response.value;
|
|
193
|
-
}
|
|
194
|
-
function* opGetNode(id) {
|
|
195
|
-
const response = yield {
|
|
196
|
-
tag: "getNode",
|
|
197
|
-
id
|
|
198
|
-
};
|
|
199
|
-
if (response.tag !== "getNode") throw new TypeError(`Expected getNode response, got ${response.tag}`);
|
|
200
|
-
return response.value;
|
|
201
|
-
}
|
|
202
|
-
function* opGetEdge(source, target) {
|
|
203
|
-
const response = yield {
|
|
204
|
-
tag: "getEdge",
|
|
205
|
-
source,
|
|
206
|
-
target
|
|
207
|
-
};
|
|
208
|
-
if (response.tag !== "getEdge") throw new TypeError(`Expected getEdge response, got ${response.tag}`);
|
|
209
|
-
return response.value;
|
|
210
|
-
}
|
|
211
|
-
function* opHasNode(id) {
|
|
212
|
-
const response = yield {
|
|
213
|
-
tag: "hasNode",
|
|
214
|
-
id
|
|
215
|
-
};
|
|
216
|
-
if (response.tag !== "hasNode") throw new TypeError(`Expected hasNode response, got ${response.tag}`);
|
|
217
|
-
return response.value;
|
|
218
|
-
}
|
|
219
|
-
function* opYield() {
|
|
220
|
-
yield { tag: "yield" };
|
|
221
|
-
}
|
|
222
|
-
function* opProgress(stats) {
|
|
223
|
-
yield {
|
|
224
|
-
tag: "progress",
|
|
225
|
-
stats
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
//#endregion
|
|
229
|
-
exports.collectAsyncIterable = collectAsyncIterable;
|
|
230
|
-
exports.defaultYieldStrategy = defaultYieldStrategy;
|
|
231
|
-
exports.opDegree = opDegree;
|
|
232
|
-
exports.opGetEdge = opGetEdge;
|
|
233
|
-
exports.opGetNode = opGetNode;
|
|
234
|
-
exports.opHasNode = opHasNode;
|
|
235
|
-
exports.opNeighbours = opNeighbours;
|
|
236
|
-
exports.opProgress = opProgress;
|
|
237
|
-
exports.opYield = opYield;
|
|
238
|
-
exports.resolveAsyncOp = resolveAsyncOp;
|
|
239
|
-
exports.resolveSyncOp = resolveSyncOp;
|
|
240
|
-
exports.runAsync = runAsync;
|
|
241
|
-
exports.runSync = runSync;
|
|
242
|
-
|
|
243
|
-
//# sourceMappingURL=index.cjs.map
|
|
2
|
+
const require_utils = require("../utils-CDtCcsyF.cjs");
|
|
3
|
+
const require_ops = require("../ops-djAsQQSh.cjs");
|
|
4
|
+
exports.collectAsyncIterable = require_utils.collectAsyncIterable;
|
|
5
|
+
exports.defaultYieldStrategy = require_utils.defaultYieldStrategy;
|
|
6
|
+
exports.opDegree = require_ops.opDegree;
|
|
7
|
+
exports.opGetEdge = require_ops.opGetEdge;
|
|
8
|
+
exports.opGetNode = require_ops.opGetNode;
|
|
9
|
+
exports.opHasNode = require_ops.opHasNode;
|
|
10
|
+
exports.opNeighbours = require_ops.opNeighbours;
|
|
11
|
+
exports.opProgress = require_ops.opProgress;
|
|
12
|
+
exports.opYield = require_ops.opYield;
|
|
13
|
+
exports.resolveAsyncOp = require_ops.resolveAsyncOp;
|
|
14
|
+
exports.resolveSyncOp = require_ops.resolveSyncOp;
|
|
15
|
+
exports.runAsync = require_ops.runAsync;
|
|
16
|
+
exports.runSync = require_ops.runSync;
|
package/dist/async/index.js
CHANGED
|
@@ -1,230 +1,3 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
import { n as defaultYieldStrategy, t as collectAsyncIterable } from "../utils-BodeE2Mo.js";
|
|
2
|
+
import { a as opNeighbours, c as resolveAsyncOp, d as runSync, i as opHasNode, l as resolveSyncOp, n as opGetEdge, o as opProgress, r as opGetNode, s as opYield, t as opDegree, u as runAsync } from "../ops-upIi6JIi.js";
|
|
228
3
|
export { collectAsyncIterable, defaultYieldStrategy, opDegree, opGetEdge, opGetNode, opHasNode, opNeighbours, opProgress, opYield, resolveAsyncOp, resolveSyncOp, runAsync, runSync };
|
|
229
|
-
|
|
230
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_expansion = require("../expansion-DaTroIyv.cjs");
|
|
3
|
+
exports.base = require_expansion.base;
|
|
4
|
+
exports.baseAsync = require_expansion.baseAsync;
|
|
5
|
+
exports.dfsPriority = require_expansion.dfsPriority;
|
|
6
|
+
exports.dfsPriorityAsync = require_expansion.dfsPriorityAsync;
|
|
7
|
+
exports.dfsPriorityFn = require_expansion.dfsPriorityFn;
|
|
8
|
+
exports.dome = require_expansion.dome;
|
|
9
|
+
exports.domeAsync = require_expansion.domeAsync;
|
|
10
|
+
exports.domeHighDegree = require_expansion.domeHighDegree;
|
|
11
|
+
exports.domeHighDegreeAsync = require_expansion.domeHighDegreeAsync;
|
|
12
|
+
exports.edge = require_expansion.edge;
|
|
13
|
+
exports.edgeAsync = require_expansion.edgeAsync;
|
|
14
|
+
exports.flux = require_expansion.flux;
|
|
15
|
+
exports.fluxAsync = require_expansion.fluxAsync;
|
|
16
|
+
exports.frontierBalanced = require_expansion.frontierBalanced;
|
|
17
|
+
exports.frontierBalancedAsync = require_expansion.frontierBalancedAsync;
|
|
18
|
+
exports.fuse = require_expansion.fuse;
|
|
19
|
+
exports.fuseAsync = require_expansion.fuseAsync;
|
|
20
|
+
exports.hae = require_expansion.hae;
|
|
21
|
+
exports.haeAsync = require_expansion.haeAsync;
|
|
22
|
+
exports.kHop = require_expansion.kHop;
|
|
23
|
+
exports.lace = require_expansion.lace;
|
|
24
|
+
exports.laceAsync = require_expansion.laceAsync;
|
|
25
|
+
exports.maze = require_expansion.maze;
|
|
26
|
+
exports.mazeAsync = require_expansion.mazeAsync;
|
|
27
|
+
exports.pipe = require_expansion.pipe;
|
|
28
|
+
exports.pipeAsync = require_expansion.pipeAsync;
|
|
29
|
+
exports.randomPriority = require_expansion.randomPriority;
|
|
30
|
+
exports.randomPriorityAsync = require_expansion.randomPriorityAsync;
|
|
31
|
+
exports.randomWalk = require_expansion.randomWalk;
|
|
32
|
+
exports.reach = require_expansion.reach;
|
|
33
|
+
exports.reachAsync = require_expansion.reachAsync;
|
|
34
|
+
exports.sage = require_expansion.sage;
|
|
35
|
+
exports.sageAsync = require_expansion.sageAsync;
|
|
36
|
+
exports.sift = require_expansion.sift;
|
|
37
|
+
exports.siftAsync = require_expansion.siftAsync;
|
|
38
|
+
exports.standardBfs = require_expansion.standardBfs;
|
|
39
|
+
exports.standardBfsAsync = require_expansion.standardBfsAsync;
|
|
40
|
+
exports.tide = require_expansion.tide;
|
|
41
|
+
exports.tideAsync = require_expansion.tideAsync;
|
|
42
|
+
exports.warp = require_expansion.warp;
|
|
43
|
+
exports.warpAsync = require_expansion.warpAsync;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as pipe, B as base, C as tideAsync, D as reachAsync, E as reach, F as haeAsync, I as dome, L as domeAsync, M as edge, N as edgeAsync, O as sage, P as hae, R as domeHighDegree, S as tide, T as mazeAsync, V as baseAsync, _ as fuseAsync, a as dfsPriorityFn, b as lace, c as frontierBalanced, d as standardBfsAsync, f as flux, g as fuse, h as siftAsync, i as dfsPriorityAsync, j as pipeAsync, k as sageAsync, l as frontierBalancedAsync, m as sift, n as kHop, o as randomPriority, p as fluxAsync, r as dfsPriority, s as randomPriorityAsync, t as randomWalk, u as standardBfs, v as warp, w as maze, x as laceAsync, y as warpAsync, z as domeHighDegreeAsync } from "../expansion-ClDhlMK8.js";
|
|
2
|
+
export { base, baseAsync, dfsPriority, dfsPriorityAsync, dfsPriorityFn, dome, domeAsync, domeHighDegree, domeHighDegreeAsync, edge, edgeAsync, flux, fluxAsync, frontierBalanced, frontierBalancedAsync, fuse, fuseAsync, hae, haeAsync, kHop, lace, laceAsync, maze, mazeAsync, pipe, pipeAsync, randomPriority, randomPriorityAsync, randomWalk, reach, reachAsync, sage, sageAsync, sift, siftAsync, standardBfs, standardBfsAsync, tide, tideAsync, warp, warpAsync };
|