graph (statelyai/graph)
Searching Database…
What is this?
A TypeScript library providing universal utilities for working with graphs: a plain {nodes, edges} JSON data model plus algorithms, format converters, and layout engines to actually use that data.
Is this a library I import, or a standalone app?
It is a library: every operation is a standalone, tree-shakable function you import, not a framework or GUI tool.
How do I add it to a project?
Install the package from npm and import the specific functions or adapters you need via optional subpath imports.
Do I need anything besides Node/npm to use it?
Just a JS/TS environment; format converters and layout engines (Graphviz, ELK, dagre, etc.) are optional adapters pulled in only if you use them.
Is every format and layout engine bundled in by default?
No, the core package only covers the data model and algorithms; each of the 14 formats and 8 layout engines is a separate optional adapter with its own dependencies.
Who would actually need this?
Developers building diagram editors, node editors, statecharts, or architecture-visualization tools who need a fast, serializable graph model with real algorithms.
Why is it fast compared to libraries like graphology?
It stores graphs as plain JSON with transparent indexed lookups instead of class instances, which the README says makes it 9-15x faster than graphology at building a 100k-node graph.
Can it turn XState state machines into graphs?
Yes, it was built by Stately and includes an adapter to turn XState machines into graphs.
What kinds of algorithms are included?
Shortest paths, centrality, communities, flow, matching, and isomorphism, all tested against edge cases like self-loops and parallel edges, implemented iteratively so deep graphs won't overflow the stack.
Is the graph data strongly typed?
Yes, it uses generic types end to end for nodes, edges, ports, and the graph itself.
Which topics is it in?
state-machine, graph-visualization, diagramming, graph, data-structures, algorithms, visualization, data-visualization, json, browser, benchmark, performance