@kasperski/graphirino
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@kasperski95/graphirino

Type-safe graph data structures.

Example

import { Graph, AdjacencyList } from "@kasperski95/graphirino"

const graph = Graph.graphFromAdjacencyList(
  new AdjacencyList()
    .add({ id: 1, data: {} }, [
      { targetNodeId: 2, data: {} },
      { targetNodeId: 3, data: {} },
    ])
    .add({ id: 2, data: {} }, [{ targetNodeId: 4, data: {} }])
    .add({ id: 3, data: {} }, [])
    .add({ id: 4, data: {} }, [])
    .add({ id: 5, data: {} }, [])
);
const dfsNodeIds = graph
  .findNodeById(1)!
  .searchDepthFirst()
  .map((node) => node.id);

console.log(dfsNodeIds) // [1, 3, 2, 4]

Readme

Keywords

none

Package Sidebar

Install

npm i @kasperski/graphirino

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

50.3 kB

Total Files

59

Last publish

Collaborators

  • kasperski95