@statelyai/graph 1.0.0 → 2.0.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 +55 -26
- package/dist/{adjacency-list-VsUaH9SJ.mjs → adjacency-list-GeL1Cu-L.mjs} +3 -1
- package/dist/{algorithms-fTqmvhzP.d.mts → algorithms-CsGNehct.d.mts} +137 -2
- package/dist/{algorithms-Ba7o7niK.mjs → algorithms-DF1pSQGv.mjs} +1476 -343
- package/dist/algorithms.d.mts +2 -2
- package/dist/algorithms.mjs +2 -2
- package/dist/{converter-udLITX36.mjs → converter-DyCJJfTe.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 +1 -1
- package/dist/formats/cytoscape/index.mjs +3 -1
- package/dist/formats/d2/index.d.mts +1 -1
- package/dist/formats/d2/index.mjs +26 -12
- package/dist/formats/d3/index.d.mts +1 -1
- package/dist/formats/d3/index.mjs +3 -1
- 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 +21 -14
- package/dist/formats/gexf/index.d.mts +1 -1
- package/dist/formats/gexf/index.mjs +22 -15
- package/dist/formats/gml/index.d.mts +1 -1
- package/dist/formats/gml/index.mjs +21 -12
- package/dist/formats/graphml/index.d.mts +1 -1
- package/dist/formats/graphml/index.mjs +73 -22
- package/dist/formats/jgf/index.d.mts +1 -1
- package/dist/formats/jgf/index.mjs +5 -2
- package/dist/formats/mermaid/index.d.mts +1 -1
- package/dist/formats/mermaid/index.mjs +49 -12
- package/dist/formats/tgf/index.d.mts +1 -1
- package/dist/formats/tgf/index.mjs +1 -1
- package/dist/formats/xyflow/index.d.mts +1 -1
- package/dist/formats/xyflow/index.mjs +31 -4
- package/dist/{index-D9Kj6Fe3.d.mts → index-D51lJnt2.d.mts} +1 -1
- package/dist/{index-CHoriXZD.d.mts → index-DWmo1mIp.d.mts} +77 -18
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +143 -295
- package/dist/{queries-BlkA1HAN.d.mts → queries-BfXeTXRf.d.mts} +43 -12
- package/dist/queries-KirMDR7e.mjs +980 -0
- package/dist/queries.d.mts +1 -1
- package/dist/queries.mjs +1 -768
- package/dist/schemas.d.mts +1 -1
- package/dist/schemas.mjs +23 -84
- package/dist/{types-3-FS9NV2.d.mts → types-DNYdIU21.d.mts} +54 -5
- package/dist/validate-TtH-x3JV.mjs +190 -0
- package/package.json +13 -3
- package/dist/indexing-DR8M1vBy.mjs +0 -137
- /package/dist/{edge-list-DP4otyPU.mjs → edge-list-BcZ0h6zz.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as Graph, m as GraphEdge, v as GraphNode, x as GraphPort } from "./types-DNYdIU21.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/queries.d.ts
|
|
4
4
|
|
|
@@ -20,7 +20,9 @@ import { _ as GraphNode, b as GraphPort, p as GraphEdge, u as Graph } from "./ty
|
|
|
20
20
|
*/
|
|
21
21
|
declare function getEdgesOf<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge<E>[];
|
|
22
22
|
/**
|
|
23
|
-
* Returns incoming edges to a node
|
|
23
|
+
* Returns incoming edges to a node, by *authored* direction
|
|
24
|
+
* (`edge.targetId === nodeId`), regardless of edge mode. For mode-aware
|
|
25
|
+
* traversal use {@link getPredecessors} or {@link getEdgesOf}.
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
28
|
* ```ts
|
|
@@ -36,7 +38,9 @@ declare function getEdgesOf<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge
|
|
|
36
38
|
*/
|
|
37
39
|
declare function getInEdges<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge<E>[];
|
|
38
40
|
/**
|
|
39
|
-
* Returns outgoing edges from a node
|
|
41
|
+
* Returns outgoing edges from a node, by *authored* direction
|
|
42
|
+
* (`edge.sourceId === nodeId`), regardless of edge mode. For mode-aware
|
|
43
|
+
* traversal use {@link getSuccessors} or {@link getEdgesOf}.
|
|
40
44
|
*
|
|
41
45
|
* @example
|
|
42
46
|
* ```ts
|
|
@@ -69,7 +73,9 @@ declare function getOutEdges<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdg
|
|
|
69
73
|
*/
|
|
70
74
|
declare function getEdgesBetween<N, E>(graph: Graph<N, E>, sourceId: string, targetId: string): GraphEdge<E>[];
|
|
71
75
|
/**
|
|
72
|
-
* Returns direct successor nodes
|
|
76
|
+
* Returns direct successor nodes — nodes reachable by traversing one edge
|
|
77
|
+
* away from `nodeId`. Edges whose effective mode is not `'directed'` are
|
|
78
|
+
* traversable both ways, so their other endpoint also counts as a successor.
|
|
73
79
|
*
|
|
74
80
|
* @example
|
|
75
81
|
* ```ts
|
|
@@ -86,7 +92,9 @@ declare function getEdgesBetween<N, E>(graph: Graph<N, E>, sourceId: string, tar
|
|
|
86
92
|
*/
|
|
87
93
|
declare function getSuccessors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
|
|
88
94
|
/**
|
|
89
|
-
* Returns direct predecessor nodes
|
|
95
|
+
* Returns direct predecessor nodes — nodes from which `nodeId` is reachable
|
|
96
|
+
* by traversing one edge. Edges whose effective mode is not `'directed'` are
|
|
97
|
+
* traversable both ways, so their other endpoint also counts as a predecessor.
|
|
90
98
|
*
|
|
91
99
|
* @example
|
|
92
100
|
* ```ts
|
|
@@ -120,9 +128,10 @@ declare function getPredecessors<N>(graph: Graph<N>, nodeId: string): GraphNode<
|
|
|
120
128
|
*/
|
|
121
129
|
declare function getNeighbors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
|
|
122
130
|
/**
|
|
123
|
-
* Returns the total degree of a node (
|
|
124
|
-
*
|
|
125
|
-
*
|
|
131
|
+
* Returns the total degree of a node (number of incident edge endpoints).
|
|
132
|
+
* Each incident edge whose effective mode is not `'directed'` is counted
|
|
133
|
+
* once (a non-directed self-loop counts once; a directed self-loop counts
|
|
134
|
+
* twice — once in, once out).
|
|
126
135
|
*
|
|
127
136
|
* @example
|
|
128
137
|
* ```ts
|
|
@@ -139,7 +148,9 @@ declare function getNeighbors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[
|
|
|
139
148
|
*/
|
|
140
149
|
declare function getDegree(graph: Graph, nodeId: string): number;
|
|
141
150
|
/**
|
|
142
|
-
* Returns the in-degree of a node
|
|
151
|
+
* Returns the in-degree of a node — the number of edges traversable *into*
|
|
152
|
+
* the node. Edges whose effective mode is not `'directed'` count toward both
|
|
153
|
+
* endpoints' in-degree (once per edge).
|
|
143
154
|
*
|
|
144
155
|
* @example
|
|
145
156
|
* ```ts
|
|
@@ -153,7 +164,9 @@ declare function getDegree(graph: Graph, nodeId: string): number;
|
|
|
153
164
|
*/
|
|
154
165
|
declare function getInDegree(graph: Graph, nodeId: string): number;
|
|
155
166
|
/**
|
|
156
|
-
* Returns the out-degree of a node
|
|
167
|
+
* Returns the out-degree of a node — the number of edges traversable *out of*
|
|
168
|
+
* the node. Edges whose effective mode is not `'directed'` count toward both
|
|
169
|
+
* endpoints' out-degree (once per edge).
|
|
157
170
|
*
|
|
158
171
|
* @example
|
|
159
172
|
* ```ts
|
|
@@ -207,6 +220,10 @@ declare function getParent<N>(graph: Graph<N>, nodeId: string): GraphNode<N> | u
|
|
|
207
220
|
/**
|
|
208
221
|
* Returns all ancestors from the node up to the root (nearest parent first).
|
|
209
222
|
*
|
|
223
|
+
* If the parent chain contains a cycle (authored `parentId` cycles are not
|
|
224
|
+
* rejected by `createGraph`), the walk stops at the first repeated node and
|
|
225
|
+
* returns the ancestors collected so far — each ancestor appears exactly once.
|
|
226
|
+
*
|
|
210
227
|
* @example
|
|
211
228
|
* ```ts
|
|
212
229
|
* const graph = createGraph({
|
|
@@ -224,6 +241,10 @@ declare function getAncestors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[
|
|
|
224
241
|
/**
|
|
225
242
|
* Returns all descendants recursively (depth-first).
|
|
226
243
|
*
|
|
244
|
+
* If the hierarchy contains a parent cycle (authored `parentId` cycles are
|
|
245
|
+
* not rejected by `createGraph`), each node is visited at most once: the walk
|
|
246
|
+
* stops at the first repeated node and returns the descendants collected so far.
|
|
247
|
+
*
|
|
227
248
|
* @example
|
|
228
249
|
* ```ts
|
|
229
250
|
* const graph = createGraph({
|
|
@@ -291,6 +312,10 @@ declare function isLeaf(graph: Graph, nodeId: string): boolean;
|
|
|
291
312
|
* Depth of a node in the hierarchy (root = 0).
|
|
292
313
|
* Returns -1 if the node is not found.
|
|
293
314
|
*
|
|
315
|
+
* If the parent chain contains a cycle (authored `parentId` cycles are not
|
|
316
|
+
* rejected by `createGraph`), the walk stops at the first repeated node and
|
|
317
|
+
* returns the number of unique ancestors walked up to that point.
|
|
318
|
+
*
|
|
294
319
|
* @example
|
|
295
320
|
* ```ts
|
|
296
321
|
* const graph = createGraph({
|
|
@@ -328,6 +353,10 @@ declare function getSiblings<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[]
|
|
|
328
353
|
* Least Common Ancestor -- deepest proper ancestor of all given nodes.
|
|
329
354
|
* A proper ancestor excludes the input nodes themselves.
|
|
330
355
|
*
|
|
356
|
+
* If a parent chain contains a cycle (authored `parentId` cycles are not
|
|
357
|
+
* rejected by `createGraph`), each chain walk stops at the first repeated
|
|
358
|
+
* node, so every ancestor is considered exactly once.
|
|
359
|
+
*
|
|
331
360
|
* @example
|
|
332
361
|
* ```ts
|
|
333
362
|
* const graph = createGraph({
|
|
@@ -422,7 +451,8 @@ declare function getRelativeDistanceMap(graph: Graph, parentId: string | null):
|
|
|
422
451
|
*/
|
|
423
452
|
declare function getRelativeDistance(graph: Graph, nodeId: string): number | undefined;
|
|
424
453
|
/**
|
|
425
|
-
* Nodes with no incoming edges (inDegree 0).
|
|
454
|
+
* Nodes with no incoming edges (inDegree 0). A node incident to an edge whose
|
|
455
|
+
* effective mode is not `'directed'` is never a source (the edge points in).
|
|
426
456
|
*
|
|
427
457
|
* @example
|
|
428
458
|
* ```ts
|
|
@@ -439,7 +469,8 @@ declare function getRelativeDistance(graph: Graph, nodeId: string): number | und
|
|
|
439
469
|
*/
|
|
440
470
|
declare function getSources<N>(graph: Graph<N>): GraphNode<N>[];
|
|
441
471
|
/**
|
|
442
|
-
* Nodes with no outgoing edges (outDegree 0).
|
|
472
|
+
* Nodes with no outgoing edges (outDegree 0). A node incident to an edge whose
|
|
473
|
+
* effective mode is not `'directed'` is never a sink (the edge points out).
|
|
443
474
|
*
|
|
444
475
|
* @example
|
|
445
476
|
* ```ts
|