@statelyai/graph 0.13.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.
Files changed (57) hide show
  1. package/README.md +57 -26
  2. package/dist/{adjacency-list-Ca0VjKIf.mjs → adjacency-list-GeL1Cu-L.mjs} +5 -3
  3. package/dist/{algorithms-BlM-qoJb.d.mts → algorithms-CsGNehct.d.mts} +137 -2
  4. package/dist/{algorithms-BNDQcHU3.mjs → algorithms-DF1pSQGv.mjs} +1494 -357
  5. package/dist/algorithms.d.mts +2 -2
  6. package/dist/algorithms.mjs +2 -2
  7. package/dist/{converter-Dspillnn.mjs → converter-DyCJJfTe.mjs} +2 -2
  8. package/dist/{edge-list-gKe8-iRa.mjs → edge-list-BcZ0h6zz.mjs} +1 -1
  9. package/dist/format-support.mjs +67 -11
  10. package/dist/formats/adjacency-list/index.d.mts +1 -1
  11. package/dist/formats/adjacency-list/index.mjs +1 -1
  12. package/dist/formats/converter/index.d.mts +1 -60
  13. package/dist/formats/converter/index.mjs +1 -1
  14. package/dist/formats/cytoscape/index.d.mts +1 -1
  15. package/dist/formats/cytoscape/index.mjs +5 -3
  16. package/dist/formats/d2/index.d.mts +109 -0
  17. package/dist/formats/d2/index.mjs +1100 -0
  18. package/dist/formats/d3/index.d.mts +2 -2
  19. package/dist/formats/d3/index.mjs +5 -3
  20. package/dist/formats/dot/index.d.mts +1 -1
  21. package/dist/formats/dot/index.mjs +24 -8
  22. package/dist/formats/edge-list/index.d.mts +1 -1
  23. package/dist/formats/edge-list/index.mjs +1 -1
  24. package/dist/formats/elk/index.d.mts +1 -1
  25. package/dist/formats/elk/index.mjs +23 -16
  26. package/dist/formats/gexf/index.d.mts +1 -1
  27. package/dist/formats/gexf/index.mjs +30 -17
  28. package/dist/formats/gml/index.d.mts +1 -1
  29. package/dist/formats/gml/index.mjs +22 -13
  30. package/dist/formats/graphml/index.d.mts +1 -1
  31. package/dist/formats/graphml/index.mjs +83 -25
  32. package/dist/formats/jgf/index.d.mts +1 -1
  33. package/dist/formats/jgf/index.mjs +6 -3
  34. package/dist/formats/mermaid/index.d.mts +1 -1
  35. package/dist/formats/mermaid/index.mjs +57 -20
  36. package/dist/formats/tgf/index.d.mts +1 -1
  37. package/dist/formats/tgf/index.mjs +2 -2
  38. package/dist/formats/xyflow/index.d.mts +1 -1
  39. package/dist/formats/xyflow/index.mjs +33 -6
  40. package/dist/index-D51lJnt2.d.mts +61 -0
  41. package/dist/index-DWmo1mIp.d.mts +697 -0
  42. package/dist/index.d.mts +6 -631
  43. package/dist/index.mjs +144 -295
  44. package/dist/mode-D8OnHFBk.mjs +15 -0
  45. package/dist/queries-BfXeTXRf.d.mts +547 -0
  46. package/dist/queries-KirMDR7e.mjs +980 -0
  47. package/dist/queries.d.mts +1 -514
  48. package/dist/queries.mjs +1 -766
  49. package/dist/schemas.d.mts +21 -10
  50. package/dist/schemas.mjs +35 -86
  51. package/dist/{types-CnZ01raw.d.mts → types-DNYdIU21.d.mts} +83 -11
  52. package/dist/validate-TtH-x3JV.mjs +190 -0
  53. package/package.json +14 -3
  54. package/schemas/edge.schema.json +11 -0
  55. package/schemas/graph.schema.json +24 -3
  56. package/schemas/node.schema.json +6 -0
  57. package/dist/indexing-DUl3kTqm.mjs +0 -137
@@ -0,0 +1,547 @@
1
+ import { d as Graph, m as GraphEdge, v as GraphNode, x as GraphPort } from "./types-DNYdIU21.mjs";
2
+
3
+ //#region src/queries.d.ts
4
+
5
+ /**
6
+ * Returns all edges (incoming + outgoing) connected to a node.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const graph = createGraph({
11
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
12
+ * edges: [
13
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
14
+ * { id: 'e2', sourceId: 'c', targetId: 'b' },
15
+ * ],
16
+ * });
17
+ * getEdgesOf(graph, 'b');
18
+ * // => [edge e1, edge e2]
19
+ * ```
20
+ */
21
+ declare function getEdgesOf<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge<E>[];
22
+ /**
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}.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const graph = createGraph({
30
+ * nodes: [{ id: 'a' }, { id: 'b' }],
31
+ * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
32
+ * });
33
+ * getInEdges(graph, 'b');
34
+ * // => [edge e1]
35
+ * getInEdges(graph, 'a');
36
+ * // => []
37
+ * ```
38
+ */
39
+ declare function getInEdges<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge<E>[];
40
+ /**
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}.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const graph = createGraph({
48
+ * nodes: [{ id: 'a' }, { id: 'b' }],
49
+ * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
50
+ * });
51
+ * getOutEdges(graph, 'a');
52
+ * // => [edge e1]
53
+ * getOutEdges(graph, 'b');
54
+ * // => []
55
+ * ```
56
+ */
57
+ declare function getOutEdges<N, E>(graph: Graph<N, E>, nodeId: string): GraphEdge<E>[];
58
+ /**
59
+ * Returns all edges from `sourceId` to `targetId`.
60
+ * Edges whose effective mode is not `'directed'` are matched both ways.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const graph = createGraph({
65
+ * nodes: [{ id: 'a' }, { id: 'b' }],
66
+ * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
67
+ * });
68
+ * getEdgesBetween(graph, 'a', 'b');
69
+ * // => [edge e1]
70
+ * getEdgesBetween(graph, 'b', 'a');
71
+ * // => [] (directed edge)
72
+ * ```
73
+ */
74
+ declare function getEdgesBetween<N, E>(graph: Graph<N, E>, sourceId: string, targetId: string): GraphEdge<E>[];
75
+ /**
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.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const graph = createGraph({
83
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
84
+ * edges: [
85
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
86
+ * { id: 'e2', sourceId: 'a', targetId: 'c' },
87
+ * ],
88
+ * });
89
+ * getSuccessors(graph, 'a');
90
+ * // => [node b, node c]
91
+ * ```
92
+ */
93
+ declare function getSuccessors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
94
+ /**
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.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const graph = createGraph({
102
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
103
+ * edges: [
104
+ * { id: 'e1', sourceId: 'a', targetId: 'c' },
105
+ * { id: 'e2', sourceId: 'b', targetId: 'c' },
106
+ * ],
107
+ * });
108
+ * getPredecessors(graph, 'c');
109
+ * // => [node a, node b]
110
+ * ```
111
+ */
112
+ declare function getPredecessors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
113
+ /**
114
+ * Returns all neighbor nodes (successors + predecessors).
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * const graph = createGraph({
119
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
120
+ * edges: [
121
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
122
+ * { id: 'e2', sourceId: 'c', targetId: 'b' },
123
+ * ],
124
+ * });
125
+ * getNeighbors(graph, 'b');
126
+ * // => [node a, node c]
127
+ * ```
128
+ */
129
+ declare function getNeighbors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
130
+ /**
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).
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * const graph = createGraph({
139
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
140
+ * edges: [
141
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
142
+ * { id: 'e2', sourceId: 'c', targetId: 'b' },
143
+ * ],
144
+ * });
145
+ * getDegree(graph, 'b'); // => 2
146
+ * getDegree(graph, 'a'); // => 1
147
+ * ```
148
+ */
149
+ declare function getDegree(graph: Graph, nodeId: string): number;
150
+ /**
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).
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * const graph = createGraph({
158
+ * nodes: [{ id: 'a' }, { id: 'b' }],
159
+ * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
160
+ * });
161
+ * getInDegree(graph, 'b'); // => 1
162
+ * getInDegree(graph, 'a'); // => 0
163
+ * ```
164
+ */
165
+ declare function getInDegree(graph: Graph, nodeId: string): number;
166
+ /**
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).
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const graph = createGraph({
174
+ * nodes: [{ id: 'a' }, { id: 'b' }],
175
+ * edges: [{ id: 'e1', sourceId: 'a', targetId: 'b' }],
176
+ * });
177
+ * getOutDegree(graph, 'a'); // => 1
178
+ * getOutDegree(graph, 'b'); // => 0
179
+ * ```
180
+ */
181
+ declare function getOutDegree(graph: Graph, nodeId: string): number;
182
+ /**
183
+ * Returns direct children of a node in the hierarchy.
184
+ * Pass `null` to get root-level nodes.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * const graph = createGraph({
189
+ * nodes: [
190
+ * { id: 'parent' },
191
+ * { id: 'child1', parentId: 'parent' },
192
+ * { id: 'child2', parentId: 'parent' },
193
+ * ],
194
+ * });
195
+ * getChildren(graph, 'parent');
196
+ * // => [node child1, node child2]
197
+ * getChildren(graph, null);
198
+ * // => [node parent]
199
+ * ```
200
+ */
201
+ declare function getChildren<N>(graph: Graph<N>, nodeId: string | null): GraphNode<N>[];
202
+ /**
203
+ * Returns the parent node in the hierarchy, or `undefined` if root-level.
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * const graph = createGraph({
208
+ * nodes: [
209
+ * { id: 'parent' },
210
+ * { id: 'child', parentId: 'parent' },
211
+ * ],
212
+ * });
213
+ * getParent(graph, 'child');
214
+ * // => node parent
215
+ * getParent(graph, 'parent');
216
+ * // => undefined
217
+ * ```
218
+ */
219
+ declare function getParent<N>(graph: Graph<N>, nodeId: string): GraphNode<N> | undefined;
220
+ /**
221
+ * Returns all ancestors from the node up to the root (nearest parent first).
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
+ *
227
+ * @example
228
+ * ```ts
229
+ * const graph = createGraph({
230
+ * nodes: [
231
+ * { id: 'root' },
232
+ * { id: 'mid', parentId: 'root' },
233
+ * { id: 'leaf', parentId: 'mid' },
234
+ * ],
235
+ * });
236
+ * getAncestors(graph, 'leaf');
237
+ * // => [node mid, node root]
238
+ * ```
239
+ */
240
+ declare function getAncestors<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
241
+ /**
242
+ * Returns all descendants recursively (depth-first).
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
+ *
248
+ * @example
249
+ * ```ts
250
+ * const graph = createGraph({
251
+ * nodes: [
252
+ * { id: 'root' },
253
+ * { id: 'child', parentId: 'root' },
254
+ * { id: 'grandchild', parentId: 'child' },
255
+ * ],
256
+ * });
257
+ * getDescendants(graph, 'root');
258
+ * // => [node child, node grandchild]
259
+ * ```
260
+ */
261
+ declare function getDescendants<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
262
+ /**
263
+ * Returns all root nodes (nodes with no parent).
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * const graph = createGraph({
268
+ * nodes: [
269
+ * { id: 'root1' },
270
+ * { id: 'root2' },
271
+ * { id: 'child', parentId: 'root1' },
272
+ * ],
273
+ * });
274
+ * getRoots(graph);
275
+ * // => [node root1, node root2]
276
+ * ```
277
+ */
278
+ declare function getRoots<N>(graph: Graph<N>): GraphNode<N>[];
279
+ /**
280
+ * Whether a node has children (is a compound/group node).
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * const graph = createGraph({
285
+ * nodes: [
286
+ * { id: 'parent' },
287
+ * { id: 'child', parentId: 'parent' },
288
+ * ],
289
+ * });
290
+ * isCompound(graph, 'parent'); // => true
291
+ * isCompound(graph, 'child'); // => false
292
+ * ```
293
+ */
294
+ declare function isCompound(graph: Graph, nodeId: string): boolean;
295
+ /**
296
+ * Whether a node has no children (is a leaf/atomic node).
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * const graph = createGraph({
301
+ * nodes: [
302
+ * { id: 'parent' },
303
+ * { id: 'child', parentId: 'parent' },
304
+ * ],
305
+ * });
306
+ * isLeaf(graph, 'child'); // => true
307
+ * isLeaf(graph, 'parent'); // => false
308
+ * ```
309
+ */
310
+ declare function isLeaf(graph: Graph, nodeId: string): boolean;
311
+ /**
312
+ * Depth of a node in the hierarchy (root = 0).
313
+ * Returns -1 if the node is not found.
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
+ *
319
+ * @example
320
+ * ```ts
321
+ * const graph = createGraph({
322
+ * nodes: [
323
+ * { id: 'root' },
324
+ * { id: 'child', parentId: 'root' },
325
+ * { id: 'grandchild', parentId: 'child' },
326
+ * ],
327
+ * });
328
+ * getDepth(graph, 'root'); // => 0
329
+ * getDepth(graph, 'child'); // => 1
330
+ * getDepth(graph, 'grandchild'); // => 2
331
+ * ```
332
+ */
333
+ declare function getDepth(graph: Graph, nodeId: string): number;
334
+ /**
335
+ * Sibling nodes (same parentId, excluding the node itself).
336
+ *
337
+ * @example
338
+ * ```ts
339
+ * const graph = createGraph({
340
+ * nodes: [
341
+ * { id: 'parent' },
342
+ * { id: 'a', parentId: 'parent' },
343
+ * { id: 'b', parentId: 'parent' },
344
+ * { id: 'c', parentId: 'parent' },
345
+ * ],
346
+ * });
347
+ * getSiblings(graph, 'a');
348
+ * // => [node b, node c]
349
+ * ```
350
+ */
351
+ declare function getSiblings<N>(graph: Graph<N>, nodeId: string): GraphNode<N>[];
352
+ /**
353
+ * Least Common Ancestor -- deepest proper ancestor of all given nodes.
354
+ * A proper ancestor excludes the input nodes themselves.
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
+ *
360
+ * @example
361
+ * ```ts
362
+ * const graph = createGraph({
363
+ * nodes: [
364
+ * { id: 'root' },
365
+ * { id: 'a', parentId: 'root' },
366
+ * { id: 'b', parentId: 'root' },
367
+ * { id: 'a1', parentId: 'a' },
368
+ * ],
369
+ * });
370
+ * getLCA(graph, 'a1', 'b');
371
+ * // => node root
372
+ * getLCA(graph, 'a', 'b');
373
+ * // => node root
374
+ * ```
375
+ */
376
+ declare function getLCA<N>(graph: Graph<N>, ...nodeIds: string[]): GraphNode<N> | undefined;
377
+ /**
378
+ * Returns a map of nodeId → shortest-path distance for all sibling nodes
379
+ * (same parentId). Distance is measured from the parent's `initialNodeId`
380
+ * (or `graph.initialNodeId` for root-level nodes).
381
+ *
382
+ * Only follows edges between siblings. Unreachable siblings are omitted.
383
+ *
384
+ * @example Root-level nodes (uses `graph.initialNodeId`):
385
+ * ```ts
386
+ * const graph = createGraph({
387
+ * initialNodeId: 'a',
388
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
389
+ * edges: [
390
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
391
+ * { id: 'e2', sourceId: 'b', targetId: 'c' },
392
+ * ],
393
+ * });
394
+ * getRelativeDistanceMap(graph, null);
395
+ * // => { a: 0, b: 1, c: 2 }
396
+ * ```
397
+ *
398
+ * @example Nested nodes (uses parent's `initialNodeId`):
399
+ * ```ts
400
+ * const graph = createGraph({
401
+ * nodes: [
402
+ * { id: 'parent', initialNodeId: 's1' },
403
+ * { id: 's1', parentId: 'parent' },
404
+ * { id: 's2', parentId: 'parent' },
405
+ * { id: 's3', parentId: 'parent' },
406
+ * ],
407
+ * edges: [
408
+ * { id: 'e1', sourceId: 's1', targetId: 's2' },
409
+ * { id: 'e2', sourceId: 's2', targetId: 's3' },
410
+ * ],
411
+ * });
412
+ * getRelativeDistanceMap(graph, 'parent');
413
+ * // => { s1: 0, s2: 1, s3: 2 }
414
+ * ```
415
+ */
416
+ declare function getRelativeDistanceMap(graph: Graph, parentId: string | null): Record<string, number>;
417
+ /**
418
+ * Returns the shortest-path distance of a node from its parent's initial node.
419
+ * Automatically scopes to the node's sibling group (same `parentId`).
420
+ *
421
+ * Returns `undefined` if the node is not found or unreachable.
422
+ *
423
+ * @example
424
+ * ```ts
425
+ * const graph = createGraph({
426
+ * initialNodeId: 'a',
427
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
428
+ * edges: [
429
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
430
+ * { id: 'e2', sourceId: 'b', targetId: 'c' },
431
+ * ],
432
+ * });
433
+ * getRelativeDistance(graph, 'a'); // => 0
434
+ * getRelativeDistance(graph, 'b'); // => 1
435
+ * getRelativeDistance(graph, 'c'); // => 2
436
+ * ```
437
+ *
438
+ * @example Nested nodes:
439
+ * ```ts
440
+ * const graph = createGraph({
441
+ * nodes: [
442
+ * { id: 'parent', initialNodeId: 's1' },
443
+ * { id: 's1', parentId: 'parent' },
444
+ * { id: 's2', parentId: 'parent' },
445
+ * ],
446
+ * edges: [{ id: 'e1', sourceId: 's1', targetId: 's2' }],
447
+ * });
448
+ * getRelativeDistance(graph, 's1'); // => 0
449
+ * getRelativeDistance(graph, 's2'); // => 1
450
+ * ```
451
+ */
452
+ declare function getRelativeDistance(graph: Graph, nodeId: string): number | undefined;
453
+ /**
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).
456
+ *
457
+ * @example
458
+ * ```ts
459
+ * const graph = createGraph({
460
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
461
+ * edges: [
462
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
463
+ * { id: 'e2', sourceId: 'b', targetId: 'c' },
464
+ * ],
465
+ * });
466
+ * getSources(graph);
467
+ * // => [node a]
468
+ * ```
469
+ */
470
+ declare function getSources<N>(graph: Graph<N>): GraphNode<N>[];
471
+ /**
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).
474
+ *
475
+ * @example
476
+ * ```ts
477
+ * const graph = createGraph({
478
+ * nodes: [{ id: 'a' }, { id: 'b' }, { id: 'c' }],
479
+ * edges: [
480
+ * { id: 'e1', sourceId: 'a', targetId: 'b' },
481
+ * { id: 'e2', sourceId: 'b', targetId: 'c' },
482
+ * ],
483
+ * });
484
+ * getSinks(graph);
485
+ * // => [node c]
486
+ * ```
487
+ */
488
+ declare function getSinks<N>(graph: Graph<N>): GraphNode<N>[];
489
+ /**
490
+ * Get a port by name on a node, or `undefined` if not found.
491
+ *
492
+ * @example
493
+ * ```ts
494
+ * const graph = createGraph({
495
+ * nodes: [{
496
+ * id: 'a',
497
+ * ports: [{ name: 'out', direction: 'out' }],
498
+ * }],
499
+ * });
500
+ * getPort(graph, 'a', 'out'); // => { name: 'out', direction: 'out', ... }
501
+ * getPort(graph, 'a', 'missing'); // => undefined
502
+ * ```
503
+ */
504
+ declare function getPort<N, E, G, P>(graph: Graph<N, E, G, P>, nodeId: string, portName: string): GraphPort<P> | undefined;
505
+ /**
506
+ * Get all ports on a node. Returns `[]` if the node has no ports or doesn't exist.
507
+ *
508
+ * @example
509
+ * ```ts
510
+ * const graph = createGraph({
511
+ * nodes: [{
512
+ * id: 'a',
513
+ * ports: [
514
+ * { name: 'in', direction: 'in' },
515
+ * { name: 'out', direction: 'out' },
516
+ * ],
517
+ * }],
518
+ * });
519
+ * getPorts(graph, 'a'); // => [port in, port out]
520
+ * ```
521
+ */
522
+ declare function getPorts<N, E, G, P>(graph: Graph<N, E, G, P>, nodeId: string): GraphPort<P>[];
523
+ /**
524
+ * Get all edges connected to a specific port on a node.
525
+ *
526
+ * Returns edges where:
527
+ * - `sourceId === nodeId && sourcePort === portName`, or
528
+ * - `targetId === nodeId && targetPort === portName`
529
+ *
530
+ * @example
531
+ * ```ts
532
+ * const graph = createGraph({
533
+ * nodes: [
534
+ * { id: 'a', ports: [{ name: 'out', direction: 'out' }] },
535
+ * { id: 'b', ports: [{ name: 'in', direction: 'in' }] },
536
+ * ],
537
+ * edges: [{
538
+ * id: 'e1', sourceId: 'a', targetId: 'b',
539
+ * sourcePort: 'out', targetPort: 'in',
540
+ * }],
541
+ * });
542
+ * getEdgesByPort(graph, 'a', 'out'); // => [edge e1]
543
+ * ```
544
+ */
545
+ declare function getEdgesByPort<N, E>(graph: Graph<N, E>, nodeId: string, portName: string): GraphEdge<E>[];
546
+ //#endregion
547
+ export { getSinks as C, isLeaf as D, isCompound as E, getSiblings as S, getSuccessors as T, getPorts as _, getDescendants as a, getRelativeDistanceMap as b, getEdgesOf as c, getLCA as d, getNeighbors as f, getPort as g, getParent as h, getDepth as i, getInDegree as l, getOutEdges as m, getChildren as n, getEdgesBetween as o, getOutDegree as p, getDegree as r, getEdgesByPort as s, getAncestors as t, getInEdges as u, getPredecessors as v, getSources as w, getRoots as x, getRelativeDistance as y };