@kaylum.io/json-graph-ts
Version:
Json Graph implementation in TypeScript
22 lines (15 loc) • 626 B
Markdown
This is a small TypeScript library for working with [json-graph](https://github.com/jsongraph/json-graph-specification) objects in JavaScript/TypeScript.
- Add nodes and edges
- disables re-adding existing nodes and edges
- support for finding nodes according to source/target of edges
```javascript
const { JsonGraph } = require("@kaylum.io/json-graph-ts")
const graph = new JsonGraph();
let author = graph.addNode("Stephen King", { "type": "author" })
let book = graph.addNode("The Shining", { "type": "book" })
graph.addEdge(a.id, b.id, "wrote")
console.log(graph.toString())
```