@statelyai/graph 1.0.0 → 2.1.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 +121 -44
- package/dist/{adjacency-list-VsUaH9SJ.mjs → adjacency-list-DQ32Mmhx.mjs} +3 -1
- package/dist/algorithms-D1cgly0g.d.mts +452 -0
- package/dist/algorithms-DBpH74hR.mjs +3309 -0
- package/dist/algorithms.d.mts +2 -2
- package/dist/algorithms.mjs +2 -2
- package/dist/config-Dt5u1gSf.mjs +793 -0
- package/dist/{converter-udLITX36.mjs → converter-DB6Rg6Vd.mjs} +2 -2
- package/dist/format-support.mjs +38 -11
- package/dist/formats/adjacency-list/index.d.mts +1 -1
- package/dist/formats/adjacency-list/index.mjs +1 -1
- package/dist/formats/converter/index.d.mts +1 -1
- package/dist/formats/converter/index.mjs +1 -1
- package/dist/formats/cytoscape/index.d.mts +4 -4
- package/dist/formats/cytoscape/index.mjs +10 -4
- package/dist/formats/d2/index.d.mts +1 -1
- package/dist/formats/d2/index.mjs +26 -12
- package/dist/formats/d3/index.d.mts +4 -4
- package/dist/formats/d3/index.mjs +10 -4
- package/dist/formats/dot/index.d.mts +1 -1
- package/dist/formats/dot/index.mjs +22 -6
- package/dist/formats/edge-list/index.d.mts +1 -1
- package/dist/formats/edge-list/index.mjs +1 -1
- package/dist/formats/elk/index.d.mts +1 -1
- package/dist/formats/elk/index.mjs +63 -24
- package/dist/formats/gexf/index.d.mts +1 -1
- package/dist/formats/gexf/index.mjs +43 -16
- package/dist/formats/gml/index.d.mts +4 -4
- package/dist/formats/gml/index.mjs +28 -15
- package/dist/formats/graphml/index.d.mts +1 -1
- package/dist/formats/graphml/index.mjs +96 -23
- package/dist/formats/jgf/index.d.mts +4 -4
- package/dist/formats/jgf/index.mjs +12 -5
- package/dist/formats/mermaid/index.d.mts +1 -1
- package/dist/formats/mermaid/index.mjs +49 -12
- package/dist/formats/tgf/index.d.mts +4 -4
- package/dist/formats/tgf/index.mjs +4 -4
- package/dist/formats/xyflow/index.d.mts +12 -6
- package/dist/formats/xyflow/index.mjs +42 -10
- package/dist/{index-D9Kj6Fe3.d.mts → index-BlbSWUvH.d.mts} +1 -1
- package/dist/{index-CHoriXZD.d.mts → index-CNvqxPLJ.d.mts} +157 -30
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +290 -307
- package/dist/layout/cytoscape.d.mts +66 -0
- package/dist/layout/cytoscape.mjs +114 -0
- package/dist/layout/d3-force.d.mts +52 -0
- package/dist/layout/d3-force.mjs +127 -0
- package/dist/layout/d3-hierarchy.d.mts +39 -0
- package/dist/layout/d3-hierarchy.mjs +135 -0
- package/dist/layout/dagre.d.mts +32 -0
- package/dist/layout/dagre.mjs +99 -0
- package/dist/layout/elk.d.mts +47 -0
- package/dist/layout/elk.mjs +73 -0
- package/dist/layout/forceatlas2.d.mts +48 -0
- package/dist/layout/forceatlas2.mjs +100 -0
- package/dist/layout/graphviz.d.mts +50 -0
- package/dist/layout/graphviz.mjs +179 -0
- package/dist/layout/index.d.mts +185 -0
- package/dist/layout/index.mjs +181 -0
- package/dist/layout/webcola.d.mts +40 -0
- package/dist/layout/webcola.mjs +104 -0
- package/dist/{queries-BlkA1HAN.d.mts → queries-B6quF529.d.mts} +43 -12
- package/dist/queries-BMM0XAv_.mjs +986 -0
- package/dist/queries.d.mts +1 -1
- package/dist/queries.mjs +1 -768
- package/dist/schemas.d.mts +19 -1
- package/dist/schemas.mjs +32 -84
- package/dist/{types-3-FS9NV2.d.mts → types-BAEQTwK_.d.mts} +99 -7
- package/dist/validate-BsfSOv0S.mjs +190 -0
- package/package.json +59 -7
- package/schemas/edge.schema.json +27 -0
- package/schemas/graph.schema.json +27 -0
- package/dist/algorithms-Ba7o7niK.mjs +0 -2394
- package/dist/algorithms-fTqmvhzP.d.mts +0 -178
- package/dist/indexing-DR8M1vBy.mjs +0 -137
- /package/dist/{edge-list-DP4otyPU.mjs → edge-list-CA9UTvn2.mjs} +0 -0
- /package/dist/{mode-D8OnHFBk.mjs → mode-gu_mhKKs.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as PortConfig, C as GraphStep, D as NodeUpdate, E as NodeConfig, I as VisualGraph, L as VisualGraphConfig, N as TransitionOptions, S as GraphPort, U as WalkOptions, W as WeightedWalkOptions, b as GraphPatch, c as EdgeUpdate, f as Graph, h as GraphEdge, i as DeleteNodeOptions, l as EntitiesConfig, m as GraphDiff, o as EdgeConfig, p as GraphConfig, r as CoverageStats, u as EntitiesUpdate, v as GraphMode, y as GraphNode } from "./types-BAEQTwK_.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/graph.d.ts
|
|
4
4
|
|
|
@@ -193,18 +193,23 @@ declare function deleteNode(graph: Graph, id: string, opts?: DeleteNodeOptions):
|
|
|
193
193
|
declare function deleteEdge(graph: Graph, id: string): void;
|
|
194
194
|
/**
|
|
195
195
|
* **Mutable.** Update a node in place.
|
|
196
|
+
* Optional fields (`x`, `y`, `width`, `height`, `shape`, `color`, `style`,
|
|
197
|
+
* `ports`) accept `null` to unset; `undefined` leaves them unchanged.
|
|
196
198
|
* @returns The updated node.
|
|
197
199
|
*
|
|
198
200
|
* @example
|
|
199
201
|
* ```ts
|
|
200
202
|
* const graph = createGraph({ nodes: [{ id: 'a', label: 'old' }] });
|
|
201
|
-
* const updated = updateNode(graph, 'a', { label: 'new' });
|
|
202
|
-
* // updated.label === 'new'
|
|
203
|
+
* const updated = updateNode(graph, 'a', { label: 'new', x: 100 });
|
|
204
|
+
* // updated.label === 'new', updated.x === 100
|
|
203
205
|
* ```
|
|
204
206
|
*/
|
|
205
|
-
declare function updateNode<N, P = any>(graph: Graph<N, any, any, P>, id: string, update:
|
|
207
|
+
declare function updateNode<N, P = any>(graph: Graph<N, any, any, P>, id: string, update: NodeUpdate<N, P>): GraphNode<N, P>;
|
|
206
208
|
/**
|
|
207
209
|
* **Mutable.** Update an edge in place.
|
|
210
|
+
* Optional fields (`weight`, `mode`, `sourcePort`, `targetPort`, `x`, `y`,
|
|
211
|
+
* `width`, `height`, `color`, `style`) accept `null` to unset; `undefined`
|
|
212
|
+
* leaves them unchanged.
|
|
208
213
|
* @returns The updated edge.
|
|
209
214
|
*
|
|
210
215
|
* @example
|
|
@@ -213,11 +218,11 @@ declare function updateNode<N, P = any>(graph: Graph<N, any, any, P>, id: string
|
|
|
213
218
|
* nodes: [{ id: 'a' }, { id: 'b' }],
|
|
214
219
|
* edges: [{ id: 'e1', sourceId: 'a', targetId: 'b', label: 'old' }],
|
|
215
220
|
* });
|
|
216
|
-
* const updated = updateEdge(graph, 'e1', { label: 'new' });
|
|
217
|
-
* // updated.label === 'new'
|
|
221
|
+
* const updated = updateEdge(graph, 'e1', { label: 'new', weight: 2 });
|
|
222
|
+
* // updated.label === 'new', updated.weight === 2
|
|
218
223
|
* ```
|
|
219
224
|
*/
|
|
220
|
-
declare function updateEdge<N, E>(graph: Graph<N, E>, id: string, update:
|
|
225
|
+
declare function updateEdge<N, E>(graph: Graph<N, E>, id: string, update: EdgeUpdate<E>): GraphEdge<E>;
|
|
221
226
|
/**
|
|
222
227
|
* **Mutable.** Add multiple nodes and edges to the graph.
|
|
223
228
|
* Nodes are added first, then edges (so edges can reference new nodes).
|
|
@@ -308,8 +313,8 @@ declare class GraphInstance<N = any, E = any, G = any, P = any> {
|
|
|
308
313
|
addEdge(config: EdgeConfig<E>): GraphEdge<E>;
|
|
309
314
|
deleteNode(id: string, opts?: DeleteNodeOptions): void;
|
|
310
315
|
deleteEdge(id: string): void;
|
|
311
|
-
updateNode(id: string, update:
|
|
312
|
-
updateEdge(id: string, update:
|
|
316
|
+
updateNode(id: string, update: NodeUpdate<N, P>): GraphNode<N, P>;
|
|
317
|
+
updateEdge(id: string, update: EdgeUpdate<E>): GraphEdge<E>;
|
|
313
318
|
addEntities(entities: EntitiesConfig<N, E, P>): void;
|
|
314
319
|
deleteEntities(ids: string | string[], opts?: DeleteNodeOptions): void;
|
|
315
320
|
updateEntities(updates: EntitiesUpdate<N, E, P>): void;
|
|
@@ -325,26 +330,105 @@ declare function getEdgeMode(graph: Graph, edge: GraphEdge): GraphMode;
|
|
|
325
330
|
/** Whether an edge points only from source to target. */
|
|
326
331
|
declare function isEdgeDirected(graph: Graph, edge: GraphEdge): boolean;
|
|
327
332
|
//#endregion
|
|
333
|
+
//#region src/validate.d.ts
|
|
334
|
+
/**
|
|
335
|
+
* A structural problem found in a graph by {@link getGraphIssues}.
|
|
336
|
+
*/
|
|
337
|
+
interface GraphIssue {
|
|
338
|
+
/** Stable machine-readable code, e.g. `'duplicate-node-id'`. */
|
|
339
|
+
code: string;
|
|
340
|
+
/** What is wrong, which entity is affected, and how to fix it. */
|
|
341
|
+
message: string;
|
|
342
|
+
/** Location of the offending value, e.g. `['nodes', 0, 'id']`. */
|
|
343
|
+
path?: (string | number)[];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Validates the structural invariants of a graph and returns the issues
|
|
347
|
+
* found, or `[]` when the graph is valid. Pure — never throws, never mutates.
|
|
348
|
+
*
|
|
349
|
+
* This is the recommended gate for untrusted or imported graphs (e.g. parsed
|
|
350
|
+
* from a file or received over the wire) before handing them to queries and
|
|
351
|
+
* algorithms: the mutation APIs (`addNode`, `addEdge`, `updateNode`, …)
|
|
352
|
+
* validate incrementally, but `createGraph` does **not** — it accepts
|
|
353
|
+
* dangling `parentId`/edge references and even `parentId` cycles as-is.
|
|
354
|
+
*
|
|
355
|
+
* For Zod-based shape validation of arbitrary unknown values, see
|
|
356
|
+
* `validateGraph` in `@statelyai/graph/schemas` (which reuses these checks).
|
|
357
|
+
*
|
|
358
|
+
* Issue codes: `duplicate-node-id`, `duplicate-edge-id`,
|
|
359
|
+
* `missing-initial-node`, `missing-parent`, `missing-node-initial`,
|
|
360
|
+
* `duplicate-port-name`, `parent-cycle`, `dangling-edge-endpoint`,
|
|
361
|
+
* `missing-source-port`, `missing-target-port`.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* const graph = createGraph({
|
|
366
|
+
* nodes: [{ id: 'a', parentId: 'ghost' }],
|
|
367
|
+
* edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
|
|
368
|
+
* });
|
|
369
|
+
* getGraphIssues(graph);
|
|
370
|
+
* // => [
|
|
371
|
+
* // { code: 'missing-parent', message: '...', path: ['nodes', 0, 'parentId'] },
|
|
372
|
+
* // { code: 'dangling-edge-endpoint', message: '...', path: ['edges', 0, 'targetId'] },
|
|
373
|
+
* // ]
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
declare function getGraphIssues(graph: Graph): GraphIssue[];
|
|
377
|
+
//#endregion
|
|
328
378
|
//#region src/indexing.d.ts
|
|
329
379
|
/**
|
|
330
|
-
* Clear the cached index. Call this if you mutate
|
|
380
|
+
* Clear the cached index. Call this if you mutate fields of existing
|
|
381
|
+
* nodes/edges in place (e.g. `edge.targetId = 'a'`) — such mutations are not
|
|
382
|
+
* auto-detected. Array replacement and length changes are auto-detected.
|
|
331
383
|
*
|
|
332
384
|
* @example
|
|
333
385
|
* ```ts
|
|
334
|
-
* import { createGraph,
|
|
386
|
+
* import { createGraph, getSuccessors, invalidateIndex } from '@statelyai/graph';
|
|
335
387
|
*
|
|
336
|
-
* const graph = createGraph({
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
388
|
+
* const graph = createGraph({
|
|
389
|
+
* nodes: [{ id: 'a' }, { id: 'b' }],
|
|
390
|
+
* edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
|
|
391
|
+
* });
|
|
392
|
+
* graph.edges[0].targetId = 'a'; // in-place field mutation
|
|
393
|
+
* invalidateIndex(graph); // forces rebuild on next indexed read
|
|
394
|
+
* getSuccessors(graph, 'a');
|
|
340
395
|
* ```
|
|
341
396
|
*/
|
|
342
397
|
declare function invalidateIndex(graph: Graph): void;
|
|
343
398
|
//#endregion
|
|
399
|
+
//#region src/generators.d.ts
|
|
400
|
+
/**
|
|
401
|
+
* Create the complete graph K_n: every pair of distinct nodes connected by
|
|
402
|
+
* one undirected edge. Nodes are `n0..n{n-1}` (`options.idPrefix` overrides
|
|
403
|
+
* the `n` prefix); edges are `e0..`.
|
|
404
|
+
*/
|
|
405
|
+
declare function createCompleteGraph(n: number, options?: {
|
|
406
|
+
idPrefix?: string;
|
|
407
|
+
}): Graph;
|
|
408
|
+
/**
|
|
409
|
+
* Create a `rows × cols` grid graph: node `(r, c)` is connected to its right
|
|
410
|
+
* and down neighbors by undirected edges. Nodes are `n{r}_{c}`
|
|
411
|
+
* (`options.idPrefix` overrides the `n` prefix); edges are `e0..`.
|
|
412
|
+
*/
|
|
413
|
+
declare function createGridGraph(rows: number, cols: number, options?: {
|
|
414
|
+
idPrefix?: string;
|
|
415
|
+
}): Graph;
|
|
416
|
+
/**
|
|
417
|
+
* Create an Erdős–Rényi G(n, p) random graph: each of the n·(n-1)/2 node
|
|
418
|
+
* pairs gets an undirected edge with probability `probability`. With
|
|
419
|
+
* `options.seed` the result is deterministic per seed (mulberry32);
|
|
420
|
+
* otherwise `Math.random` is used. Nodes are `n0..n{n-1}`
|
|
421
|
+
* (`options.idPrefix` overrides the `n` prefix); edges are `e0..`.
|
|
422
|
+
*/
|
|
423
|
+
declare function createRandomGraph(n: number, probability: number, options?: {
|
|
424
|
+
seed?: number;
|
|
425
|
+
idPrefix?: string;
|
|
426
|
+
}): Graph;
|
|
427
|
+
//#endregion
|
|
344
428
|
//#region src/equivalence.d.ts
|
|
345
429
|
declare const LAYOUT_KEYS: {
|
|
346
430
|
node: readonly ["x", "y", "width", "height", "style", "color", "shape"];
|
|
347
|
-
edge: readonly ["x", "y", "width", "height", "style", "color"];
|
|
431
|
+
edge: readonly ["x", "y", "width", "height", "points", "routing", "style", "color"];
|
|
348
432
|
};
|
|
349
433
|
/**
|
|
350
434
|
* Compare two entities on a given set of keys.
|
|
@@ -427,21 +511,26 @@ declare function isEmptyDiff(diff: GraphDiff): boolean;
|
|
|
427
511
|
*
|
|
428
512
|
* @example
|
|
429
513
|
* ```ts
|
|
430
|
-
* import { createGraph, getDiff,
|
|
514
|
+
* import { createGraph, getDiff, getInvertedDiff } from '@statelyai/graph';
|
|
431
515
|
*
|
|
432
516
|
* const a = createGraph({ nodes: [{ id: 'n1' }], edges: [] });
|
|
433
517
|
* const b = createGraph({ nodes: [{ id: 'n2' }], edges: [] });
|
|
434
518
|
*
|
|
435
519
|
* const diff = getDiff(a, b);
|
|
436
|
-
* const inv =
|
|
520
|
+
* const inv = getInvertedDiff(diff);
|
|
437
521
|
* // inv.nodes.added contains n1 (was removed)
|
|
438
522
|
* // inv.nodes.removed contains n2 (was added)
|
|
439
523
|
* ```
|
|
440
524
|
*/
|
|
525
|
+
declare function getInvertedDiff<N, E>(diff: GraphDiff<N, E>): GraphDiff<N, E>;
|
|
526
|
+
/**
|
|
527
|
+
* @deprecated Use {@link getInvertedDiff}.
|
|
528
|
+
*/
|
|
441
529
|
declare function invertDiff<N, E>(diff: GraphDiff<N, E>): GraphDiff<N, E>;
|
|
442
530
|
/**
|
|
443
531
|
* Compute an ordered patch list from graph `a` to graph `b`.
|
|
444
|
-
* Order
|
|
532
|
+
* Order (see {@link toPatches}): add nodes → update edges → delete edges →
|
|
533
|
+
* delete nodes → add edges → update nodes.
|
|
445
534
|
*
|
|
446
535
|
* @example
|
|
447
536
|
* ```ts
|
|
@@ -461,16 +550,20 @@ declare function getPatches<N, E>(a: Graph<N, E>, b: Graph<N, E>): GraphPatch<N,
|
|
|
461
550
|
*
|
|
462
551
|
* @example
|
|
463
552
|
* ```ts
|
|
464
|
-
* import { createGraph, getPatches,
|
|
553
|
+
* import { createGraph, getPatches, updateGraphWithPatches } from '@statelyai/graph';
|
|
465
554
|
*
|
|
466
555
|
* const a = createGraph({ nodes: [{ id: 'n1' }], edges: [] });
|
|
467
556
|
* const b = createGraph({ nodes: [{ id: 'n1' }, { id: 'n2' }], edges: [] });
|
|
468
557
|
*
|
|
469
558
|
* const patches = getPatches(a, b);
|
|
470
|
-
*
|
|
559
|
+
* updateGraphWithPatches(a, patches);
|
|
471
560
|
* // a now contains both n1 and n2
|
|
472
561
|
* ```
|
|
473
562
|
*/
|
|
563
|
+
declare function updateGraphWithPatches<N, E>(graph: Graph<N, E>, patches: GraphPatch<N, E>[]): void;
|
|
564
|
+
/**
|
|
565
|
+
* @deprecated Use {@link updateGraphWithPatches}.
|
|
566
|
+
*/
|
|
474
567
|
declare function applyPatches<N, E>(graph: Graph<N, E>, patches: GraphPatch<N, E>[]): void;
|
|
475
568
|
/**
|
|
476
569
|
* Flatten a structured diff into an ordered patch list.
|
|
@@ -519,7 +612,7 @@ declare function toDiff<N, E>(patches: GraphPatch<N, E>[]): GraphDiff<N, E>;
|
|
|
519
612
|
*
|
|
520
613
|
* @example
|
|
521
614
|
* ```ts
|
|
522
|
-
* import { createGraph,
|
|
615
|
+
* import { createGraph, getFlattenedGraph } from '@statelyai/graph';
|
|
523
616
|
*
|
|
524
617
|
* const graph = createGraph({
|
|
525
618
|
* nodes: [
|
|
@@ -531,11 +624,15 @@ declare function toDiff<N, E>(patches: GraphPatch<N, E>[]): GraphDiff<N, E>;
|
|
|
531
624
|
* edges: [{ id: 'e1', sourceId: 'other', targetId: 'parent' }],
|
|
532
625
|
* });
|
|
533
626
|
*
|
|
534
|
-
* const flat =
|
|
627
|
+
* const flat = getFlattenedGraph(graph);
|
|
535
628
|
* // flat.nodes → [child1, child2, other] (leaf nodes only)
|
|
536
629
|
* // flat.edges → edge from 'other' → 'child1' (resolved via initialNodeId)
|
|
537
630
|
* ```
|
|
538
631
|
*/
|
|
632
|
+
declare function getFlattenedGraph<N, E, G>(graph: Graph<N, E, G>): Graph<N, E, G>;
|
|
633
|
+
/**
|
|
634
|
+
* @deprecated Use {@link getFlattenedGraph}.
|
|
635
|
+
*/
|
|
539
636
|
declare function flatten<N, E, G>(graph: Graph<N, E, G>): Graph<N, E, G>;
|
|
540
637
|
/**
|
|
541
638
|
* Returns the induced subgraph containing only the given node IDs
|
|
@@ -566,7 +663,7 @@ declare function getSubgraph<N, E, G>(graph: Graph<N, E, G>, nodeIds: string[]):
|
|
|
566
663
|
*
|
|
567
664
|
* @example
|
|
568
665
|
* ```ts
|
|
569
|
-
* import { createGraph,
|
|
666
|
+
* import { createGraph, getReversedGraph } from '@statelyai/graph';
|
|
570
667
|
*
|
|
571
668
|
* const graph = createGraph({
|
|
572
669
|
* nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
|
|
@@ -576,18 +673,23 @@ declare function getSubgraph<N, E, G>(graph: Graph<N, E, G>, nodeIds: string[]):
|
|
|
576
673
|
* ],
|
|
577
674
|
* });
|
|
578
675
|
*
|
|
579
|
-
* const rev =
|
|
676
|
+
* const rev = getReversedGraph(graph);
|
|
580
677
|
* // rev edges: b→a, c→b
|
|
581
678
|
*
|
|
582
|
-
* const filtered =
|
|
679
|
+
* const filtered = getReversedGraph(graph, (e) => e.id !== 'bc');
|
|
583
680
|
* // filtered edges: b→a (only ab reversed, bc excluded)
|
|
584
681
|
* ```
|
|
585
682
|
*/
|
|
683
|
+
declare function getReversedGraph<N, E, G>(graph: Graph<N, E, G>, filterEdge?: (edge: GraphEdge<E>) => boolean): Graph<N, E, G>;
|
|
684
|
+
/**
|
|
685
|
+
* @deprecated Use {@link getReversedGraph}.
|
|
686
|
+
*/
|
|
586
687
|
declare function reverseGraph<N, E, G>(graph: Graph<N, E, G>, filterEdge?: (edge: GraphEdge<E>) => boolean): Graph<N, E, G>;
|
|
587
688
|
//#endregion
|
|
588
689
|
//#region src/walks.d.ts
|
|
589
690
|
/**
|
|
590
|
-
* Random walk. At each node, picks a uniformly random
|
|
691
|
+
* Random walk. At each node, picks a uniformly random traversable edge
|
|
692
|
+
* (outgoing edges, plus non-directed edges both ways).
|
|
591
693
|
* Yields steps indefinitely (may revisit nodes) until a sink node is reached.
|
|
592
694
|
*/
|
|
593
695
|
declare function genRandomWalk<N, E>(graph: Graph<N, E>, options?: WalkOptions<E>): Generator<GraphStep<N, E>>;
|
|
@@ -597,36 +699,61 @@ declare function genRandomWalk<N, E>(graph: Graph<N, E>, options?: WalkOptions<E
|
|
|
597
699
|
declare function genWeightedRandomWalk<N, E>(graph: Graph<N, E>, options?: WeightedWalkOptions<E>): Generator<GraphStep<N, E>>;
|
|
598
700
|
/**
|
|
599
701
|
* Quick random walk targeting unvisited edges.
|
|
600
|
-
* If unvisited
|
|
601
|
-
* Otherwise,
|
|
702
|
+
* If unvisited traversable edges exist at the current node, picks one randomly.
|
|
703
|
+
* Otherwise, walks the fewest-hop path (BFS, honoring `filter` and edge modes)
|
|
704
|
+
* to the nearest unvisited edge. Ends when no unvisited edge is reachable.
|
|
602
705
|
*/
|
|
603
706
|
declare function genQuickRandomWalk<N, E>(graph: Graph<N, E>, options?: WalkOptions<E>): Generator<GraphStep<N, E>>;
|
|
604
707
|
/**
|
|
605
708
|
* Walk a predefined sequence of edge IDs.
|
|
606
709
|
* Validates each edge exists and connects from the current position.
|
|
710
|
+
* Edges whose effective mode is not `'directed'` may be traversed
|
|
711
|
+
* target → source as well.
|
|
607
712
|
*/
|
|
608
713
|
declare function genPredefinedWalk<N, E>(graph: Graph<N, E>, edgeIds: string[], options?: Pick<WalkOptions<E>, 'from'>): Generator<GraphStep<N, E>>;
|
|
609
714
|
/**
|
|
610
715
|
* Yield at most `n` steps from the source generator.
|
|
611
716
|
*/
|
|
717
|
+
declare function genWalkSteps<N, E>(gen: Generator<GraphStep<N, E>>, n: number): Generator<GraphStep<N, E>>;
|
|
718
|
+
/**
|
|
719
|
+
* @deprecated Use {@link genWalkSteps}.
|
|
720
|
+
*/
|
|
612
721
|
declare function takeSteps<N, E>(gen: Generator<GraphStep<N, E>>, n: number): Generator<GraphStep<N, E>>;
|
|
613
722
|
/**
|
|
614
723
|
* Yield steps until a specific node is reached.
|
|
615
724
|
*/
|
|
725
|
+
declare function genWalkUntilNode<N, E>(gen: Generator<GraphStep<N, E>>, nodeId: string): Generator<GraphStep<N, E>>;
|
|
726
|
+
/**
|
|
727
|
+
* @deprecated Use {@link genWalkUntilNode}.
|
|
728
|
+
*/
|
|
616
729
|
declare function takeUntilNode<N, E>(gen: Generator<GraphStep<N, E>>, nodeId: string): Generator<GraphStep<N, E>>;
|
|
617
730
|
/**
|
|
618
731
|
* Yield steps until a specific edge is traversed.
|
|
619
732
|
*/
|
|
733
|
+
declare function genWalkUntilEdge<N, E>(gen: Generator<GraphStep<N, E>>, edgeId: string): Generator<GraphStep<N, E>>;
|
|
734
|
+
/**
|
|
735
|
+
* @deprecated Use {@link genWalkUntilEdge}.
|
|
736
|
+
*/
|
|
620
737
|
declare function takeUntilEdge<N, E>(gen: Generator<GraphStep<N, E>>, edgeId: string): Generator<GraphStep<N, E>>;
|
|
621
738
|
/**
|
|
622
739
|
* Yield steps until node coverage reaches the target (0–1).
|
|
623
740
|
*/
|
|
741
|
+
declare function genWalkUntilNodeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number, options?: {
|
|
742
|
+
from?: string;
|
|
743
|
+
}): Generator<GraphStep<N, E>>;
|
|
744
|
+
/**
|
|
745
|
+
* @deprecated Use {@link genWalkUntilNodeCoverage}.
|
|
746
|
+
*/
|
|
624
747
|
declare function takeUntilNodeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number, options?: {
|
|
625
748
|
from?: string;
|
|
626
749
|
}): Generator<GraphStep<N, E>>;
|
|
627
750
|
/**
|
|
628
751
|
* Yield steps until edge coverage reaches the target (0–1).
|
|
629
752
|
*/
|
|
753
|
+
declare function genWalkUntilEdgeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number): Generator<GraphStep<N, E>>;
|
|
754
|
+
/**
|
|
755
|
+
* @deprecated Use {@link genWalkUntilEdgeCoverage}.
|
|
756
|
+
*/
|
|
630
757
|
declare function takeUntilEdgeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number): Generator<GraphStep<N, E>>;
|
|
631
758
|
/**
|
|
632
759
|
* Compute coverage statistics for a completed walk.
|
|
@@ -635,4 +762,4 @@ declare function getCoverage<N, E>(graph: Graph<N, E>, steps: GraphStep<N, E>[],
|
|
|
635
762
|
from?: string;
|
|
636
763
|
}): CoverageStats;
|
|
637
764
|
//#endregion
|
|
638
|
-
export {
|
|
765
|
+
export { deleteEntities as $, LAYOUT_KEYS as A, getEdgeMode as B, getInvertedDiff as C, toDiff as D, isEmptyDiff as E, createGridGraph as F, addNode as G, GraphInstance as H, createRandomGraph as I, createGraphFromTransition as J, createGraph as K, invalidateIndex as L, isLayoutEqual as M, isNonLayoutEqual as N, toPatches as O, createCompleteGraph as P, deleteEdge as Q, GraphIssue as R, getDiff as S, invertDiff as T, addEdge as U, isEdgeDirected as V, addEntities as W, createGraphPort as X, createGraphNode as Y, createVisualGraph as Z, getFlattenedGraph as _, genWalkUntilEdge as a, updateEdge as at, reverseGraph as b, genWalkUntilNodeCoverage as c, takeSteps as d, deleteNode as et, takeUntilEdge as f, flatten as g, takeUntilNodeCoverage as h, genWalkSteps as i, hasNode as it, areEntitiesEqual as j, updateGraphWithPatches as k, genWeightedRandomWalk as l, takeUntilNode as m, genQuickRandomWalk as n, getNode as nt, genWalkUntilEdgeCoverage as o, updateEntities as ot, takeUntilEdgeCoverage as p, createGraphEdge as q, genRandomWalk as r, hasEdge as rt, genWalkUntilNode as s, updateNode as st, genPredefinedWalk as t, getEdge as tt, getCoverage as u, getReversedGraph as v, getPatches as w, applyPatches as x, getSubgraph as y, getGraphIssues as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { A as
|
|
3
|
-
import { n as createFormatConverter } from "./index-
|
|
4
|
-
import { A as
|
|
5
|
-
import { C as getSinks, D as isLeaf, E as isCompound, S as getSiblings, T as getSuccessors, _ as getPorts, a as getDescendants, b as getRelativeDistanceMap, c as getEdgesOf, d as getLCA, f as getNeighbors, g as getPort, h as getParent, i as getDepth, l as getInDegree, m as getOutEdges, n as getChildren, o as getEdgesBetween, p as getOutDegree, r as getDegree, s as getEdgesByPort, t as getAncestors, u as getInEdges, v as getPredecessors, w as getSources, x as getRoots, y as getRelativeDistance } from "./queries-
|
|
6
|
-
export { AStarOptions, AllPairsShortestPathsOptions, CoverageStats, DeleteNodeOptions, EdgeChange, EdgeConfig, EntitiesConfig, EntitiesUpdate, EntityRect, GirvanNewmanOptions, Graph, GraphConfig, GraphDiff, GraphEdge, GraphEntity, GraphFormatConverter, GraphInstance, GraphMode, GraphNode, GraphPatch, GraphPath, GraphPort, GraphStep, HITSResult, IsomorphismOptions, IterativeCentralityOptions, LAYOUT_KEYS, LabelPropagationOptions, MSTOptions, NodeChange, NodeConfig, PathOptions, PortConfig, PortDirection, SinglePathOptions, TransitionOptions, TraversalOptions, VisualEdge, VisualGraph, VisualGraphConfig, VisualGraphEntity, VisualGraphFormatConverter, VisualNode, VisualPort, WalkContext, WalkOptions, WeightedWalkOptions, addEdge, addEntities, addNode, applyPatches, areEntitiesEqual, bfs, createFormatConverter, createGraph, createGraphEdge, createGraphFromTransition, createGraphNode, createGraphPort, createVisualGraph, deleteEdge, deleteEntities, deleteNode, dfs, flatten, genCycles, genGirvanNewmanCommunities, genPostorders, genPredefinedWalk, genPreorders, genQuickRandomWalk, genRandomWalk, genShortestPaths, genSimplePaths, genWeightedRandomWalk, getAStarPath, getAllPairsShortestPaths, getAncestors, getArticulationPoints, getBetweennessCentrality, getBiconnectedComponents, getBridges, getChildren, getClosenessCentrality, getConnectedComponents, getCoverage, getCycles, getDegree, getDegreeCentrality, getDepth, getDescendants, getDiff, getEdge, getEdgeMode, getEdgesBetween, getEdgesByPort, getEdgesOf, getEigenvectorCentrality, getGirvanNewmanCommunities, getGreedyModularityCommunities, getHITS, getInDegree, getInDegreeCentrality, getInEdges, getLCA, getLabelPropagationCommunities, getMinimumSpanningTree, getModularity, getNeighbors, getNode, getOutDegree, getOutDegreeCentrality, getOutEdges, getPageRank, getParent, getPatches, getPort, getPorts, getPostorder, getPostorders, getPredecessors, getPreorder, getPreorders, getRelativeDistance, getRelativeDistanceMap, getRoots, getShortestPath, getShortestPaths, getSiblings, getSimplePath, getSimplePaths, getSinks, getSources, getStronglyConnectedComponents, getSubgraph, getSuccessors, getTopologicalSort, hasEdge, hasNode, hasPath, invalidateIndex, invertDiff, isAcyclic, isCompound, isConnected, isEdgeDirected, isEmptyDiff, isIsomorphic, isLayoutEqual, isLeaf, isNonLayoutEqual, isTree, joinPaths, reverseGraph, takeSteps, takeUntilEdge, takeUntilEdgeCoverage, takeUntilNode, takeUntilNodeCoverage, toDiff, toPatches, updateEdge, updateEntities, updateNode };
|
|
1
|
+
import { A as PortConfig, B as VisualNode, C as GraphStep, D as NodeUpdate, E as NodeConfig, F as VisualEdge, H as WalkContext, I as VisualGraph, L as VisualGraphConfig, M as SinglePathOptions, N as TransitionOptions, O as PathOptions, P as TraversalOptions, R as VisualGraphEntity, S as GraphPort, T as NodeChange, U as WalkOptions, V as VisualPort, W as WeightedWalkOptions, _ as GraphFormatConverter, a as EdgeChange, b as GraphPatch, c as EdgeUpdate, d as EntityRect, f as Graph, g as GraphEntity, h as GraphEdge, i as DeleteNodeOptions, j as PortDirection, k as Point, l as EntitiesConfig, m as GraphDiff, n as AllPairsShortestPathsOptions, o as EdgeConfig, p as GraphConfig, r as CoverageStats, s as EdgeRouting, t as AStarOptions, u as EntitiesUpdate, v as GraphMode, w as MSTOptions, x as GraphPath, y as GraphNode, z as VisualGraphFormatConverter } from "./types-BAEQTwK_.mjs";
|
|
2
|
+
import { $ as getAllPairsShortestPaths, A as HITSResult, B as getOutDegreeCentrality, C as getModularity, D as getCoreNumbers, E as isBipartite, F as getDegreeCentrality, G as getPostorder, H as getMinimumSpanningTree, I as getEigenvectorCentrality, J as getPreorders, K as getPostorders, L as getHITS, M as KatzCentralityOptions, N as getBetweennessCentrality, O as getKCore, P as getClosenessCentrality, Q as getAStarPath, R as getInDegreeCentrality, S as getLabelPropagationCommunities, T as getMaximumBipartiteMatching, U as genPostorders, V as getPageRank, W as genPreorders, X as genShortestPaths, Y as genCycles, Z as genSimplePaths, _ as GirvanNewmanOptions, _t as isTree, a as MaxFlowResult, at as getSimplePaths, b as getGirvanNewmanCommunities, c as getMaxFlow, ct as bfs, d as getLouvainCommunities, dt as genDFS, et as getCycles, f as IsomorphismOptions, ft as getConnectedComponents, g as getBridges, gt as isConnected, h as getBiconnectedComponents, ht as isAcyclic, i as MaxFlowOptions, it as getSimplePath, j as IterativeCentralityOptions, k as EigenvectorCentralityOptions, l as getMinCut, lt as dfs, m as getArticulationPoints, mt as hasPath, n as DominatorTreeOptions, nt as getShortestPath, o as MinCutOptions, ot as getStronglyConnectedComponents, p as isIsomorphic, pt as getTopologicalSort, q as getPreorder, r as getDominatorTree, rt as getShortestPaths, s as MinCutResult, st as joinPaths, t as getTransitiveReduction, tt as getJoinedPath, u as LouvainOptions, ut as genBFS, v as LabelPropagationOptions, w as BipartiteMatch, x as getGreedyModularityCommunities, y as genGirvanNewmanCommunities, z as getKatzCentrality } from "./algorithms-D1cgly0g.mjs";
|
|
3
|
+
import { n as createFormatConverter } from "./index-BlbSWUvH.mjs";
|
|
4
|
+
import { $ as deleteEntities, A as LAYOUT_KEYS, B as getEdgeMode, C as getInvertedDiff, D as toDiff, E as isEmptyDiff, F as createGridGraph, G as addNode, H as GraphInstance, I as createRandomGraph, J as createGraphFromTransition, K as createGraph, L as invalidateIndex, M as isLayoutEqual, N as isNonLayoutEqual, O as toPatches, P as createCompleteGraph, Q as deleteEdge, R as GraphIssue, S as getDiff, T as invertDiff, U as addEdge, V as isEdgeDirected, W as addEntities, X as createGraphPort, Y as createGraphNode, Z as createVisualGraph, _ as getFlattenedGraph, a as genWalkUntilEdge, at as updateEdge, b as reverseGraph, c as genWalkUntilNodeCoverage, d as takeSteps, et as deleteNode, f as takeUntilEdge, g as flatten, h as takeUntilNodeCoverage, i as genWalkSteps, it as hasNode, j as areEntitiesEqual, k as updateGraphWithPatches, l as genWeightedRandomWalk, m as takeUntilNode, n as genQuickRandomWalk, nt as getNode, o as genWalkUntilEdgeCoverage, ot as updateEntities, p as takeUntilEdgeCoverage, q as createGraphEdge, r as genRandomWalk, rt as hasEdge, s as genWalkUntilNode, st as updateNode, t as genPredefinedWalk, tt as getEdge, u as getCoverage, v as getReversedGraph, w as getPatches, x as applyPatches, y as getSubgraph, z as getGraphIssues } from "./index-CNvqxPLJ.mjs";
|
|
5
|
+
import { C as getSinks, D as isLeaf, E as isCompound, S as getSiblings, T as getSuccessors, _ as getPorts, a as getDescendants, b as getRelativeDistanceMap, c as getEdgesOf, d as getLCA, f as getNeighbors, g as getPort, h as getParent, i as getDepth, l as getInDegree, m as getOutEdges, n as getChildren, o as getEdgesBetween, p as getOutDegree, r as getDegree, s as getEdgesByPort, t as getAncestors, u as getInEdges, v as getPredecessors, w as getSources, x as getRoots, y as getRelativeDistance } from "./queries-B6quF529.mjs";
|
|
6
|
+
export { AStarOptions, AllPairsShortestPathsOptions, BipartiteMatch, CoverageStats, DeleteNodeOptions, DominatorTreeOptions, EdgeChange, EdgeConfig, EdgeRouting, EdgeUpdate, EigenvectorCentralityOptions, EntitiesConfig, EntitiesUpdate, EntityRect, GirvanNewmanOptions, Graph, GraphConfig, GraphDiff, GraphEdge, GraphEntity, GraphFormatConverter, GraphInstance, GraphIssue, GraphMode, GraphNode, GraphPatch, GraphPath, GraphPort, GraphStep, HITSResult, IsomorphismOptions, IterativeCentralityOptions, KatzCentralityOptions, LAYOUT_KEYS, LabelPropagationOptions, LouvainOptions, MSTOptions, MaxFlowOptions, MaxFlowResult, MinCutOptions, MinCutResult, NodeChange, NodeConfig, NodeUpdate, PathOptions, Point, PortConfig, PortDirection, SinglePathOptions, TransitionOptions, TraversalOptions, VisualEdge, VisualGraph, VisualGraphConfig, VisualGraphEntity, VisualGraphFormatConverter, VisualNode, VisualPort, WalkContext, WalkOptions, WeightedWalkOptions, addEdge, addEntities, addNode, applyPatches, areEntitiesEqual, bfs, createCompleteGraph, createFormatConverter, createGraph, createGraphEdge, createGraphFromTransition, createGraphNode, createGraphPort, createGridGraph, createRandomGraph, createVisualGraph, deleteEdge, deleteEntities, deleteNode, dfs, flatten, genBFS, genCycles, genDFS, genGirvanNewmanCommunities, genPostorders, genPredefinedWalk, genPreorders, genQuickRandomWalk, genRandomWalk, genShortestPaths, genSimplePaths, genWalkSteps, genWalkUntilEdge, genWalkUntilEdgeCoverage, genWalkUntilNode, genWalkUntilNodeCoverage, genWeightedRandomWalk, getAStarPath, getAllPairsShortestPaths, getAncestors, getArticulationPoints, getBetweennessCentrality, getBiconnectedComponents, getBridges, getChildren, getClosenessCentrality, getConnectedComponents, getCoreNumbers, getCoverage, getCycles, getDegree, getDegreeCentrality, getDepth, getDescendants, getDiff, getDominatorTree, getEdge, getEdgeMode, getEdgesBetween, getEdgesByPort, getEdgesOf, getEigenvectorCentrality, getFlattenedGraph, getGirvanNewmanCommunities, getGraphIssues, getGreedyModularityCommunities, getHITS, getInDegree, getInDegreeCentrality, getInEdges, getInvertedDiff, getJoinedPath, getKCore, getKatzCentrality, getLCA, getLabelPropagationCommunities, getLouvainCommunities, getMaxFlow, getMaximumBipartiteMatching, getMinCut, getMinimumSpanningTree, getModularity, getNeighbors, getNode, getOutDegree, getOutDegreeCentrality, getOutEdges, getPageRank, getParent, getPatches, getPort, getPorts, getPostorder, getPostorders, getPredecessors, getPreorder, getPreorders, getRelativeDistance, getRelativeDistanceMap, getReversedGraph, getRoots, getShortestPath, getShortestPaths, getSiblings, getSimplePath, getSimplePaths, getSinks, getSources, getStronglyConnectedComponents, getSubgraph, getSuccessors, getTopologicalSort, getTransitiveReduction, hasEdge, hasNode, hasPath, invalidateIndex, invertDiff, isAcyclic, isBipartite, isCompound, isConnected, isEdgeDirected, isEmptyDiff, isIsomorphic, isLayoutEqual, isLeaf, isNonLayoutEqual, isTree, joinPaths, reverseGraph, takeSteps, takeUntilEdge, takeUntilEdgeCoverage, takeUntilNode, takeUntilNodeCoverage, toDiff, toPatches, updateEdge, updateEntities, updateGraphWithPatches, updateNode };
|