@statelyai/graph 2.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.
Files changed (73) hide show
  1. package/README.md +67 -19
  2. package/dist/{algorithms-CsGNehct.d.mts → algorithms-D1cgly0g.d.mts} +145 -6
  3. package/dist/{algorithms-DF1pSQGv.mjs → algorithms-DBpH74hR.mjs} +673 -891
  4. package/dist/algorithms.d.mts +2 -2
  5. package/dist/algorithms.mjs +2 -2
  6. package/dist/config-Dt5u1gSf.mjs +793 -0
  7. package/dist/{converter-DyCJJfTe.mjs → converter-DB6Rg6Vd.mjs} +2 -2
  8. package/dist/formats/adjacency-list/index.d.mts +1 -1
  9. package/dist/formats/adjacency-list/index.mjs +1 -1
  10. package/dist/formats/converter/index.d.mts +1 -1
  11. package/dist/formats/converter/index.mjs +1 -1
  12. package/dist/formats/cytoscape/index.d.mts +4 -4
  13. package/dist/formats/cytoscape/index.mjs +8 -4
  14. package/dist/formats/d2/index.d.mts +1 -1
  15. package/dist/formats/d2/index.mjs +1 -1
  16. package/dist/formats/d3/index.d.mts +4 -4
  17. package/dist/formats/d3/index.mjs +8 -4
  18. package/dist/formats/dot/index.d.mts +1 -1
  19. package/dist/formats/dot/index.mjs +1 -1
  20. package/dist/formats/edge-list/index.d.mts +1 -1
  21. package/dist/formats/edge-list/index.mjs +1 -1
  22. package/dist/formats/elk/index.d.mts +1 -1
  23. package/dist/formats/elk/index.mjs +43 -11
  24. package/dist/formats/gexf/index.d.mts +1 -1
  25. package/dist/formats/gexf/index.mjs +22 -2
  26. package/dist/formats/gml/index.d.mts +4 -4
  27. package/dist/formats/gml/index.mjs +8 -4
  28. package/dist/formats/graphml/index.d.mts +1 -1
  29. package/dist/formats/graphml/index.mjs +24 -2
  30. package/dist/formats/jgf/index.d.mts +4 -4
  31. package/dist/formats/jgf/index.mjs +8 -4
  32. package/dist/formats/mermaid/index.d.mts +1 -1
  33. package/dist/formats/mermaid/index.mjs +1 -1
  34. package/dist/formats/tgf/index.d.mts +4 -4
  35. package/dist/formats/tgf/index.mjs +4 -4
  36. package/dist/formats/xyflow/index.d.mts +12 -6
  37. package/dist/formats/xyflow/index.mjs +11 -6
  38. package/dist/{index-D51lJnt2.d.mts → index-BlbSWUvH.d.mts} +1 -1
  39. package/dist/{index-DWmo1mIp.d.mts → index-CNvqxPLJ.d.mts} +82 -14
  40. package/dist/index.d.mts +6 -6
  41. package/dist/index.mjs +152 -17
  42. package/dist/layout/cytoscape.d.mts +66 -0
  43. package/dist/layout/cytoscape.mjs +114 -0
  44. package/dist/layout/d3-force.d.mts +52 -0
  45. package/dist/layout/d3-force.mjs +127 -0
  46. package/dist/layout/d3-hierarchy.d.mts +39 -0
  47. package/dist/layout/d3-hierarchy.mjs +135 -0
  48. package/dist/layout/dagre.d.mts +32 -0
  49. package/dist/layout/dagre.mjs +99 -0
  50. package/dist/layout/elk.d.mts +47 -0
  51. package/dist/layout/elk.mjs +73 -0
  52. package/dist/layout/forceatlas2.d.mts +48 -0
  53. package/dist/layout/forceatlas2.mjs +100 -0
  54. package/dist/layout/graphviz.d.mts +50 -0
  55. package/dist/layout/graphviz.mjs +179 -0
  56. package/dist/layout/index.d.mts +185 -0
  57. package/dist/layout/index.mjs +181 -0
  58. package/dist/layout/webcola.d.mts +40 -0
  59. package/dist/layout/webcola.mjs +104 -0
  60. package/dist/{queries-BfXeTXRf.d.mts → queries-B6quF529.d.mts} +1 -1
  61. package/dist/{queries-KirMDR7e.mjs → queries-BMM0XAv_.mjs} +23 -17
  62. package/dist/queries.d.mts +1 -1
  63. package/dist/queries.mjs +1 -1
  64. package/dist/schemas.d.mts +19 -1
  65. package/dist/schemas.mjs +10 -1
  66. package/dist/{types-DNYdIU21.d.mts → types-BAEQTwK_.d.mts} +46 -3
  67. package/package.json +47 -5
  68. package/schemas/edge.schema.json +27 -0
  69. package/schemas/graph.schema.json +27 -0
  70. /package/dist/{adjacency-list-GeL1Cu-L.mjs → adjacency-list-DQ32Mmhx.mjs} +0 -0
  71. /package/dist/{edge-list-BcZ0h6zz.mjs → edge-list-CA9UTvn2.mjs} +0 -0
  72. /package/dist/{mode-D8OnHFBk.mjs → mode-gu_mhKKs.mjs} +0 -0
  73. /package/dist/{validate-TtH-x3JV.mjs → validate-BsfSOv0S.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "../../types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/tgf/index.d.ts
4
4
 
@@ -8,7 +8,7 @@ import { d as Graph, g as GraphFormatConverter } from "../../types-DNYdIU21.mjs"
8
8
  * @example
9
9
  * ```ts
10
10
  * import { createGraph } from '@statelyai/graph';
11
- * import { toTGF } from '@statelyai/graph/formats/tgf';
11
+ * import { toTGF } from '@statelyai/graph/tgf';
12
12
  *
13
13
  * const graph = createGraph({
14
14
  * nodes: [{ id: 'a', label: 'A' }, { id: 'b', label: 'B' }],
@@ -25,7 +25,7 @@ declare function toTGF(graph: Graph): string;
25
25
  *
26
26
  * @example
27
27
  * ```ts
28
- * import { fromTGF } from '@statelyai/graph/formats/tgf';
28
+ * import { fromTGF } from '@statelyai/graph/tgf';
29
29
  *
30
30
  * const graph = fromTGF('a A\nb B\n#\na b go');
31
31
  * // graph.nodes = [{ id: 'a', label: 'A' }, { id: 'b', label: 'B' }]
@@ -38,7 +38,7 @@ declare function fromTGF(tgf: string): Graph;
38
38
  * @example
39
39
  * ```ts
40
40
  * import { createGraph } from '@statelyai/graph';
41
- * import { tgfConverter } from '@statelyai/graph/formats/tgf';
41
+ * import { tgfConverter } from '@statelyai/graph/tgf';
42
42
  *
43
43
  * const graph = createGraph({
44
44
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,4 +1,4 @@
1
- import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
1
+ import { n as createFormatConverter } from "../../converter-DB6Rg6Vd.mjs";
2
2
 
3
3
  //#region src/formats/tgf/index.ts
4
4
  /**
@@ -7,7 +7,7 @@ import { n as createFormatConverter } from "../../converter-DyCJJfTe.mjs";
7
7
  * @example
8
8
  * ```ts
9
9
  * import { createGraph } from '@statelyai/graph';
10
- * import { toTGF } from '@statelyai/graph/formats/tgf';
10
+ * import { toTGF } from '@statelyai/graph/tgf';
11
11
  *
12
12
  * const graph = createGraph({
13
13
  * nodes: [{ id: 'a', label: 'A' }, { id: 'b', label: 'B' }],
@@ -34,7 +34,7 @@ function toTGF(graph) {
34
34
  *
35
35
  * @example
36
36
  * ```ts
37
- * import { fromTGF } from '@statelyai/graph/formats/tgf';
37
+ * import { fromTGF } from '@statelyai/graph/tgf';
38
38
  *
39
39
  * const graph = fromTGF('a A\nb B\n#\na b go');
40
40
  * // graph.nodes = [{ id: 'a', label: 'A' }, { id: 'b', label: 'B' }]
@@ -94,7 +94,7 @@ function fromTGF(tgf) {
94
94
  * @example
95
95
  * ```ts
96
96
  * import { createGraph } from '@statelyai/graph';
97
- * import { tgfConverter } from '@statelyai/graph/formats/tgf';
97
+ * import { tgfConverter } from '@statelyai/graph/tgf';
98
98
  *
99
99
  * const graph = createGraph({
100
100
  * nodes: [{ id: 'a' }, { id: 'b' }],
@@ -1,11 +1,17 @@
1
- import { L as VisualGraphFormatConverter, P as VisualGraph } from "../../types-DNYdIU21.mjs";
1
+ import { I as VisualGraph, z as VisualGraphFormatConverter } from "../../types-BAEQTwK_.mjs";
2
2
  import { EdgeBase, NodeBase } from "@xyflow/system";
3
3
 
4
4
  //#region src/formats/xyflow/index.d.ts
5
5
  /** xyflow Node — re-exported from `@xyflow/system`. */
6
6
  type XYFlowNode<TNodeData extends Record<string, unknown> = Record<string, unknown>> = NodeBase<TNodeData>;
7
- /** xyflow Edge — re-exported from `@xyflow/system`. */
8
- type XYFlowEdge<TEdgeData extends Record<string, unknown> = Record<string, unknown>> = EdgeBase<TEdgeData>;
7
+ /**
8
+ * xyflow Edge `EdgeBase` from `@xyflow/system` plus the top-level `label`
9
+ * that React Flow / Svelte Flow actually render (it's a renderer prop, so
10
+ * `EdgeBase` itself doesn't declare it).
11
+ */
12
+ type XYFlowEdge<TEdgeData extends Record<string, unknown> = Record<string, unknown>> = EdgeBase<TEdgeData> & {
13
+ label?: string;
14
+ };
9
15
  interface XYFlow<TNodeData extends Record<string, unknown> = Record<string, unknown>, TEdgeData extends Record<string, unknown> = Record<string, unknown>> {
10
16
  nodes: XYFlowNode<TNodeData>[];
11
17
  edges: XYFlowEdge<TEdgeData>[];
@@ -17,7 +23,7 @@ interface XYFlow<TNodeData extends Record<string, unknown> = Record<string, unkn
17
23
  * @example
18
24
  * ```ts
19
25
  * import { createVisualGraph } from '@statelyai/graph';
20
- * import { toXYFlow } from '@statelyai/graph/formats/xyflow';
26
+ * import { toXYFlow } from '@statelyai/graph/xyflow';
21
27
  *
22
28
  * const graph = createVisualGraph({
23
29
  * nodes: [
@@ -37,7 +43,7 @@ declare function toXYFlow(graph: VisualGraph): XYFlow;
37
43
  *
38
44
  * @example
39
45
  * ```ts
40
- * import { fromXYFlow } from '@statelyai/graph/formats/xyflow';
46
+ * import { fromXYFlow } from '@statelyai/graph/xyflow';
41
47
  *
42
48
  * const graph = fromXYFlow({
43
49
  * nodes: [
@@ -55,7 +61,7 @@ declare function fromXYFlow(flow: XYFlow): VisualGraph;
55
61
  * @example
56
62
  * ```ts
57
63
  * import { createVisualGraph } from '@statelyai/graph';
58
- * import { xyflowConverter } from '@statelyai/graph/formats/xyflow';
64
+ * import { xyflowConverter } from '@statelyai/graph/xyflow';
59
65
  *
60
66
  * const graph = createVisualGraph({
61
67
  * nodes: [
@@ -53,7 +53,7 @@ function orderParentsFirst(nodes) {
53
53
  * @example
54
54
  * ```ts
55
55
  * import { createVisualGraph } from '@statelyai/graph';
56
- * import { toXYFlow } from '@statelyai/graph/formats/xyflow';
56
+ * import { toXYFlow } from '@statelyai/graph/xyflow';
57
57
  *
58
58
  * const graph = createVisualGraph({
59
59
  * nodes: [
@@ -93,6 +93,7 @@ function toXYFlow(graph) {
93
93
  } })
94
94
  };
95
95
  if (n.parentId) node.parentId = n.parentId;
96
+ if (n.label) node.data.label = n.label;
96
97
  if (n.shape) node.type = n.shape;
97
98
  if (n.width !== void 0) node.width = n.width;
98
99
  if (n.height !== void 0) node.height = n.height;
@@ -110,6 +111,8 @@ function toXYFlow(graph) {
110
111
  label: e.label,
111
112
  mode: e.mode,
112
113
  weight: e.weight,
114
+ points: e.points,
115
+ routing: e.routing,
113
116
  color: e.color,
114
117
  style: e.style,
115
118
  x: e.x,
@@ -117,7 +120,7 @@ function toXYFlow(graph) {
117
120
  width: e.width,
118
121
  height: e.height
119
122
  } });
120
- if (e.label) edge.data.label = e.label;
123
+ if (e.label) edge.label = e.label;
121
124
  return edge;
122
125
  })
123
126
  };
@@ -127,7 +130,7 @@ function toXYFlow(graph) {
127
130
  *
128
131
  * @example
129
132
  * ```ts
130
- * import { fromXYFlow } from '@statelyai/graph/formats/xyflow';
133
+ * import { fromXYFlow } from '@statelyai/graph/xyflow';
131
134
  *
132
135
  * const graph = fromXYFlow({
133
136
  * nodes: [
@@ -157,7 +160,7 @@ function fromXYFlow(flow) {
157
160
  id: n.id,
158
161
  parentId: n.parentId ?? null,
159
162
  initialNodeId: metadata && "initialNodeId" in metadata ? metadata.initialNodeId : null,
160
- label: metadata && "label" in metadata ? metadata.label : "",
163
+ label: metadata && "label" in metadata ? metadata.label : n.data?.label?.toString() ?? "",
161
164
  data: readUserData(n.data),
162
165
  x: n.position.x,
163
166
  y: n.position.y,
@@ -176,7 +179,7 @@ function fromXYFlow(flow) {
176
179
  id: e.id ?? `e${i}`,
177
180
  sourceId: e.source,
178
181
  targetId: e.target,
179
- label: metadata && "label" in metadata ? metadata.label : e.data?.label?.toString() ?? "",
182
+ label: metadata && "label" in metadata ? metadata.label : e.label ?? e.data?.label?.toString() ?? "",
180
183
  ...e.sourceHandle && { sourcePort: e.sourceHandle },
181
184
  ...e.targetHandle && { targetPort: e.targetHandle },
182
185
  data: readUserData(e.data),
@@ -186,6 +189,8 @@ function fromXYFlow(flow) {
186
189
  height: metadata?.height ?? 0,
187
190
  ...metadata?.mode !== void 0 && { mode: metadata.mode },
188
191
  ...metadata?.weight !== void 0 && { weight: metadata.weight },
192
+ ...metadata?.points !== void 0 && { points: metadata.points },
193
+ ...metadata?.routing !== void 0 && { routing: metadata.routing },
189
194
  ...metadata?.color !== void 0 && { color: metadata.color },
190
195
  ...metadata?.style !== void 0 && { style: metadata.style }
191
196
  };
@@ -198,7 +203,7 @@ function fromXYFlow(flow) {
198
203
  * @example
199
204
  * ```ts
200
205
  * import { createVisualGraph } from '@statelyai/graph';
201
- * import { xyflowConverter } from '@statelyai/graph/formats/xyflow';
206
+ * import { xyflowConverter } from '@statelyai/graph/xyflow';
202
207
  *
203
208
  * const graph = createVisualGraph({
204
209
  * nodes: [
@@ -1,4 +1,4 @@
1
- import { d as Graph, g as GraphFormatConverter } from "./types-DNYdIU21.mjs";
1
+ import { _ as GraphFormatConverter, f as Graph } from "./types-BAEQTwK_.mjs";
2
2
 
3
3
  //#region src/formats/converter/index.d.ts
4
4
 
@@ -1,4 +1,4 @@
1
- import { E as NodeUpdate, F as VisualGraphConfig, H as WeightedWalkOptions, O as PortConfig, P as VisualGraph, S as GraphStep, T as NodeConfig, V as WalkOptions, _ as GraphMode, c as EntitiesConfig, d as Graph, f as GraphConfig, i as DeleteNodeOptions, j as TransitionOptions, l as EntitiesUpdate, m as GraphEdge, o as EdgeConfig, p as GraphDiff, r as CoverageStats, s as EdgeUpdate, v as GraphNode, x as GraphPort, y as GraphPatch } from "./types-DNYdIU21.mjs";
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
 
@@ -383,22 +383,52 @@ declare function getGraphIssues(graph: Graph): GraphIssue[];
383
383
  *
384
384
  * @example
385
385
  * ```ts
386
- * import { createGraph, invalidateIndex, getIndex } from '@statelyai/graph';
386
+ * import { createGraph, getSuccessors, invalidateIndex } from '@statelyai/graph';
387
387
  *
388
388
  * const graph = createGraph({
389
389
  * nodes: [{ id: 'a' }, { id: 'b' }],
390
390
  * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
391
391
  * });
392
392
  * graph.edges[0].targetId = 'a'; // in-place field mutation
393
- * invalidateIndex(graph); // forces rebuild on next getIndex()
393
+ * invalidateIndex(graph); // forces rebuild on next indexed read
394
+ * getSuccessors(graph, 'a');
394
395
  * ```
395
396
  */
396
397
  declare function invalidateIndex(graph: Graph): void;
397
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
398
428
  //#region src/equivalence.d.ts
399
429
  declare const LAYOUT_KEYS: {
400
430
  node: readonly ["x", "y", "width", "height", "style", "color", "shape"];
401
- edge: readonly ["x", "y", "width", "height", "style", "color"];
431
+ edge: readonly ["x", "y", "width", "height", "points", "routing", "style", "color"];
402
432
  };
403
433
  /**
404
434
  * Compare two entities on a given set of keys.
@@ -481,17 +511,21 @@ declare function isEmptyDiff(diff: GraphDiff): boolean;
481
511
  *
482
512
  * @example
483
513
  * ```ts
484
- * import { createGraph, getDiff, invertDiff } from '@statelyai/graph';
514
+ * import { createGraph, getDiff, getInvertedDiff } from '@statelyai/graph';
485
515
  *
486
516
  * const a = createGraph({ nodes: [{ id: 'n1' }], edges: [] });
487
517
  * const b = createGraph({ nodes: [{ id: 'n2' }], edges: [] });
488
518
  *
489
519
  * const diff = getDiff(a, b);
490
- * const inv = invertDiff(diff);
520
+ * const inv = getInvertedDiff(diff);
491
521
  * // inv.nodes.added contains n1 (was removed)
492
522
  * // inv.nodes.removed contains n2 (was added)
493
523
  * ```
494
524
  */
525
+ declare function getInvertedDiff<N, E>(diff: GraphDiff<N, E>): GraphDiff<N, E>;
526
+ /**
527
+ * @deprecated Use {@link getInvertedDiff}.
528
+ */
495
529
  declare function invertDiff<N, E>(diff: GraphDiff<N, E>): GraphDiff<N, E>;
496
530
  /**
497
531
  * Compute an ordered patch list from graph `a` to graph `b`.
@@ -516,16 +550,20 @@ declare function getPatches<N, E>(a: Graph<N, E>, b: Graph<N, E>): GraphPatch<N,
516
550
  *
517
551
  * @example
518
552
  * ```ts
519
- * import { createGraph, getPatches, applyPatches } from '@statelyai/graph';
553
+ * import { createGraph, getPatches, updateGraphWithPatches } from '@statelyai/graph';
520
554
  *
521
555
  * const a = createGraph({ nodes: [{ id: 'n1' }], edges: [] });
522
556
  * const b = createGraph({ nodes: [{ id: 'n1' }, { id: 'n2' }], edges: [] });
523
557
  *
524
558
  * const patches = getPatches(a, b);
525
- * applyPatches(a, patches);
559
+ * updateGraphWithPatches(a, patches);
526
560
  * // a now contains both n1 and n2
527
561
  * ```
528
562
  */
563
+ declare function updateGraphWithPatches<N, E>(graph: Graph<N, E>, patches: GraphPatch<N, E>[]): void;
564
+ /**
565
+ * @deprecated Use {@link updateGraphWithPatches}.
566
+ */
529
567
  declare function applyPatches<N, E>(graph: Graph<N, E>, patches: GraphPatch<N, E>[]): void;
530
568
  /**
531
569
  * Flatten a structured diff into an ordered patch list.
@@ -574,7 +612,7 @@ declare function toDiff<N, E>(patches: GraphPatch<N, E>[]): GraphDiff<N, E>;
574
612
  *
575
613
  * @example
576
614
  * ```ts
577
- * import { createGraph, flatten } from '@statelyai/graph';
615
+ * import { createGraph, getFlattenedGraph } from '@statelyai/graph';
578
616
  *
579
617
  * const graph = createGraph({
580
618
  * nodes: [
@@ -586,11 +624,15 @@ declare function toDiff<N, E>(patches: GraphPatch<N, E>[]): GraphDiff<N, E>;
586
624
  * edges: [{ id: 'e1', sourceId: 'other', targetId: 'parent' }],
587
625
  * });
588
626
  *
589
- * const flat = flatten(graph);
627
+ * const flat = getFlattenedGraph(graph);
590
628
  * // flat.nodes → [child1, child2, other] (leaf nodes only)
591
629
  * // flat.edges → edge from 'other' → 'child1' (resolved via initialNodeId)
592
630
  * ```
593
631
  */
632
+ declare function getFlattenedGraph<N, E, G>(graph: Graph<N, E, G>): Graph<N, E, G>;
633
+ /**
634
+ * @deprecated Use {@link getFlattenedGraph}.
635
+ */
594
636
  declare function flatten<N, E, G>(graph: Graph<N, E, G>): Graph<N, E, G>;
595
637
  /**
596
638
  * Returns the induced subgraph containing only the given node IDs
@@ -621,7 +663,7 @@ declare function getSubgraph<N, E, G>(graph: Graph<N, E, G>, nodeIds: string[]):
621
663
  *
622
664
  * @example
623
665
  * ```ts
624
- * import { createGraph, reverseGraph } from '@statelyai/graph';
666
+ * import { createGraph, getReversedGraph } from '@statelyai/graph';
625
667
  *
626
668
  * const graph = createGraph({
627
669
  * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
@@ -631,13 +673,17 @@ declare function getSubgraph<N, E, G>(graph: Graph<N, E, G>, nodeIds: string[]):
631
673
  * ],
632
674
  * });
633
675
  *
634
- * const rev = reverseGraph(graph);
676
+ * const rev = getReversedGraph(graph);
635
677
  * // rev edges: b→a, c→b
636
678
  *
637
- * const filtered = reverseGraph(graph, (e) => e.id !== 'bc');
679
+ * const filtered = getReversedGraph(graph, (e) => e.id !== 'bc');
638
680
  * // filtered edges: b→a (only ab reversed, bc excluded)
639
681
  * ```
640
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
+ */
641
687
  declare function reverseGraph<N, E, G>(graph: Graph<N, E, G>, filterEdge?: (edge: GraphEdge<E>) => boolean): Graph<N, E, G>;
642
688
  //#endregion
643
689
  //#region src/walks.d.ts
@@ -668,24 +714,46 @@ declare function genPredefinedWalk<N, E>(graph: Graph<N, E>, edgeIds: string[],
668
714
  /**
669
715
  * Yield at most `n` steps from the source generator.
670
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
+ */
671
721
  declare function takeSteps<N, E>(gen: Generator<GraphStep<N, E>>, n: number): Generator<GraphStep<N, E>>;
672
722
  /**
673
723
  * Yield steps until a specific node is reached.
674
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
+ */
675
729
  declare function takeUntilNode<N, E>(gen: Generator<GraphStep<N, E>>, nodeId: string): Generator<GraphStep<N, E>>;
676
730
  /**
677
731
  * Yield steps until a specific edge is traversed.
678
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
+ */
679
737
  declare function takeUntilEdge<N, E>(gen: Generator<GraphStep<N, E>>, edgeId: string): Generator<GraphStep<N, E>>;
680
738
  /**
681
739
  * Yield steps until node coverage reaches the target (0–1).
682
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
+ */
683
747
  declare function takeUntilNodeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number, options?: {
684
748
  from?: string;
685
749
  }): Generator<GraphStep<N, E>>;
686
750
  /**
687
751
  * Yield steps until edge coverage reaches the target (0–1).
688
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
+ */
689
757
  declare function takeUntilEdgeCoverage<N, E>(gen: Generator<GraphStep<N, E>>, graph: Graph<N, E>, coverage: number): Generator<GraphStep<N, E>>;
690
758
  /**
691
759
  * Compute coverage statistics for a completed walk.
@@ -694,4 +762,4 @@ declare function getCoverage<N, E>(graph: Graph<N, E>, steps: GraphStep<N, E>[],
694
762
  from?: string;
695
763
  }): CoverageStats;
696
764
  //#endregion
697
- export { GraphInstance as A, deleteEdge as B, isLayoutEqual as C, getGraphIssues as D, GraphIssue as E, createGraphEdge as F, hasEdge as G, deleteNode as H, createGraphFromTransition as I, updateEntities as J, hasNode as K, createGraphNode as L, addEntities as M, addNode as N, getEdgeMode as O, createGraph as P, createGraphPort as R, areEntitiesEqual as S, invalidateIndex as T, getEdge as U, deleteEntities as V, getNode as W, updateNode as Y, invertDiff as _, getCoverage as a, toPatches as b, takeUntilEdgeCoverage as c, flatten as d, getSubgraph as f, getPatches as g, getDiff as h, genWeightedRandomWalk as i, addEdge as j, isEdgeDirected as k, takeUntilNode as l, applyPatches as m, genQuickRandomWalk as n, takeSteps as o, reverseGraph as p, updateEdge as q, genRandomWalk as r, takeUntilEdge as s, genPredefinedWalk as t, takeUntilNodeCoverage as u, isEmptyDiff as v, isNonLayoutEqual as w, LAYOUT_KEYS as x, toDiff as y, createVisualGraph as z };
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 SinglePathOptions, B as WalkContext, C as MSTOptions, D as PathOptions, E as NodeUpdate, F as VisualGraphConfig, H as WeightedWalkOptions, I as VisualGraphEntity, L as VisualGraphFormatConverter, M as TraversalOptions, N as VisualEdge, O as PortConfig, P as VisualGraph, R as VisualNode, S as GraphStep, T as NodeConfig, V as WalkOptions, _ as GraphMode, a as EdgeChange, b as GraphPath, c as EntitiesConfig, d as Graph, f as GraphConfig, g as GraphFormatConverter, h as GraphEntity, i as DeleteNodeOptions, j as TransitionOptions, k as PortDirection, l as EntitiesUpdate, m as GraphEdge, n as AllPairsShortestPathsOptions, o as EdgeConfig, p as GraphDiff, r as CoverageStats, s as EdgeUpdate, t as AStarOptions, u as EntityRect, v as GraphNode, w as NodeChange, x as GraphPort, y as GraphPatch, z as VisualPort } from "./types-DNYdIU21.mjs";
2
- import { $ as getTopologicalSort, A as getPageRank, B as genSimplePaths, C as getBetweennessCentrality, D as getHITS, E as getEigenvectorCentrality, F as getPostorders, G as getShortestPaths, H as getAllPairsShortestPaths, I as getPreorder, J as getStronglyConnectedComponents, K as getSimplePath, L as getPreorders, M as genPostorders, N as genPreorders, O as getInDegreeCentrality, P as getPostorder, Q as getConnectedComponents, R as genCycles, S as IterativeCentralityOptions, T as getDegreeCentrality, U as getCycles, V as getAStarPath, W as getShortestPath, X as bfs, Y as joinPaths, Z as dfs, _ as getGirvanNewmanCommunities, a as MaxFlowResult, b as getModularity, c as getLouvainCommunities, d as getArticulationPoints, et as hasPath, f as getBiconnectedComponents, g as genGirvanNewmanCommunities, h as LabelPropagationOptions, i as MaxFlowOptions, j as getMinimumSpanningTree, k as getOutDegreeCentrality, l as IsomorphismOptions, m as GirvanNewmanOptions, n as DominatorTreeOptions, nt as isConnected, o as getMaxFlow, p as getBridges, q as getSimplePaths, r as getDominatorTree, rt as isTree, s as LouvainOptions, t as getTransitiveReduction, tt as isAcyclic, u as isIsomorphic, v as getGreedyModularityCommunities, w as getClosenessCentrality, x as HITSResult, y as getLabelPropagationCommunities, z as genShortestPaths } from "./algorithms-CsGNehct.mjs";
3
- import { n as createFormatConverter } from "./index-D51lJnt2.mjs";
4
- import { A as GraphInstance, B as deleteEdge, C as isLayoutEqual, D as getGraphIssues, E as GraphIssue, F as createGraphEdge, G as hasEdge, H as deleteNode, I as createGraphFromTransition, J as updateEntities, K as hasNode, L as createGraphNode, M as addEntities, N as addNode, O as getEdgeMode, P as createGraph, R as createGraphPort, S as areEntitiesEqual, T as invalidateIndex, U as getEdge, V as deleteEntities, W as getNode, Y as updateNode, _ as invertDiff, a as getCoverage, b as toPatches, c as takeUntilEdgeCoverage, d as flatten, f as getSubgraph, g as getPatches, h as getDiff, i as genWeightedRandomWalk, j as addEdge, k as isEdgeDirected, l as takeUntilNode, m as applyPatches, n as genQuickRandomWalk, o as takeSteps, p as reverseGraph, q as updateEdge, r as genRandomWalk, s as takeUntilEdge, t as genPredefinedWalk, u as takeUntilNodeCoverage, v as isEmptyDiff, w as isNonLayoutEqual, x as LAYOUT_KEYS, y as toDiff, z as createVisualGraph } from "./index-DWmo1mIp.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-BfXeTXRf.mjs";
6
- export { AStarOptions, AllPairsShortestPathsOptions, CoverageStats, DeleteNodeOptions, DominatorTreeOptions, EdgeChange, EdgeConfig, EdgeUpdate, EntitiesConfig, EntitiesUpdate, EntityRect, GirvanNewmanOptions, Graph, GraphConfig, GraphDiff, GraphEdge, GraphEntity, GraphFormatConverter, GraphInstance, GraphIssue, GraphMode, GraphNode, GraphPatch, GraphPath, GraphPort, GraphStep, HITSResult, IsomorphismOptions, IterativeCentralityOptions, LAYOUT_KEYS, LabelPropagationOptions, LouvainOptions, MSTOptions, MaxFlowOptions, MaxFlowResult, NodeChange, NodeConfig, NodeUpdate, 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, getDominatorTree, getEdge, getEdgeMode, getEdgesBetween, getEdgesByPort, getEdgesOf, getEigenvectorCentrality, getGirvanNewmanCommunities, getGraphIssues, getGreedyModularityCommunities, getHITS, getInDegree, getInDegreeCentrality, getInEdges, getLCA, getLabelPropagationCommunities, getLouvainCommunities, getMaxFlow, 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, getTransitiveReduction, 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 };