npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@billdaddy/graphkit

v0.1.0

Published

Zero-dependency TypeScript graph library: directed/undirected, weighted edges, DFS/BFS, Dijkstra, topological sort, cycle detection, SCC, MST. Modern replacement for abandoned graphlib.

Downloads

120

Readme

graphkit

All Contributors

npm CI license

Zero-dependency TypeScript graph library — directed & undirected graphs, weighted edges, DFS/BFS, Dijkstra, topological sort, cycle detection, strongly connected components, and minimum spanning tree.

npm install @billdaddy/graphkit

Why?

graphlib (2.1M downloads/week) has been abandoned since 2018 with 127 open GitHub issues. It has no TypeScript types, no Dijkstra, no SCC, and no MST. graphkit is the modern, typed, algorithm-rich replacement.

Inspired by Python's networkx, Go's dominikbraun/graph, Java's JGraphT, and C#'s QuikGraph.

Quick start

import { Graph, digraph, ungraph } from "@billdaddy/graphkit";

// Directed weighted graph
const g = digraph<string, number>();
g.addNode("a", "Alice");
g.addNode("b", "Bob");
g.addNode("c", "Carol");
g.addEdge("a", "b", { weight: 4 });
g.addEdge("a", "c", { weight: 2 });
g.addEdge("b", "c", { weight: 1 });

const result = g.dijkstra("a", "c");
// { distance: 2, path: ["a", "c"] }

API

Creating a graph

import { Graph, digraph, ungraph } from "@billdaddy/graphkit";

const g = new Graph({ directed: true });  // directed (default)
const d = digraph();                       // shorthand for directed
const u = ungraph();                       // shorthand for undirected

Nodes

g.addNode("id");             // add a node
g.addNode("id", label);      // add with label (generic N)
g.removeNode("id");          // remove node + all its edges
g.hasNode("id");             // boolean
g.nodeLabel("id");           // N | undefined
g.nodes();                   // string[]
g.nodeCount;                 // number

Edges

g.addEdge("from", "to");                              // weight = 1
g.addEdge("from", "to", { weight: 5, label: "road" });
g.removeEdge("from", "to");
g.hasEdge("from", "to");                              // boolean
g.edge("from", "to");                                 // Edge<E> | undefined
g.edges();                                            // Edge<E>[]
g.edgeCount;                                          // number

Adjacency

g.successors("id");     // outgoing neighbors (directed)
g.predecessors("id");   // incoming neighbors (directed)
g.neighbors("id");      // all adjacent nodes
g.outDegree("id");
g.inDegree("id");
g.degree("id");

Traversal

g.dfs("start");                      // string[] — DFS order
g.dfs("start", id => console.log(id)); // with visitor callback
g.bfs("start");                      // string[] — BFS order

Shortest path (Dijkstra)

const result = g.dijkstra("a", "b");
// null if no path, or:
// { distance: 7, path: ["a", "c", "b"] }

const allDists = g.dijkstraAll("a");
// Map<string, number> — distances from "a" to every reachable node

Topological sort

const order = g.topologicalSort();  // throws GraphError if graph has a cycle

Cycle detection

g.hasCycle();  // boolean
g.isDAG();     // boolean — true if directed and acyclic

Connected components

g.connectedComponents();           // string[][] — weakly connected
g.stronglyConnectedComponents();   // string[][] — Tarjan's SCC (directed)
g.isConnected();                   // boolean

Minimum spanning tree

g.kruskal();        // Edge<E>[] — Kruskal's MST
g.prim("start");    // Edge<E>[] — Prim's MST

Serialization

const json = g.toJSON();
const g2 = Graph.fromJSON(json);

Examples

Dependency graph with topological sort

import { digraph } from "@billdaddy/graphkit";

const g = digraph();
g.addEdge("lodash", "app");
g.addEdge("axios", "app");
g.addEdge("typescript", "lodash");

const buildOrder = g.topologicalSort();
// ["typescript", "lodash", "axios", "app"]

Network routing with Dijkstra

import { ungraph } from "@billdaddy/graphkit";

const network = ungraph();
network.addEdge("A", "B", { weight: 10 });
network.addEdge("A", "C", { weight: 3 });
network.addEdge("C", "B", { weight: 4 });
network.addEdge("B", "D", { weight: 2 });
network.addEdge("C", "D", { weight: 8 });

const { path, distance } = network.dijkstra("A", "D")!;
// path: ["A", "C", "B", "D"], distance: 9

Detecting circular imports

import { digraph } from "@billdaddy/graphkit";

const deps = digraph();
deps.addEdge("a", "b");
deps.addEdge("b", "c");
deps.addEdge("c", "a"); // circular!

if (deps.hasCycle()) {
  console.error("Circular dependency detected!");
}

Finding clusters (SCC)

import { digraph } from "@billdaddy/graphkit";

const g = digraph();
g.addEdge("user1", "user2"); g.addEdge("user2", "user1"); // mutual
g.addEdge("user2", "user3");                               // user3 only follows user2

const clusters = g.stronglyConnectedComponents();
// [["user1", "user2"], ["user3"]]

Type parameters

const g = new Graph<NodeLabel, EdgeLabel>();
// or
const g = digraph<NodeLabel, EdgeLabel>();
  • N — type of the value stored on each node (optional, defaults to unknown)
  • E — type of the label stored on each edge (optional, defaults to unknown)

Comparison

| Package | Downloads/week | Last release | TypeScript | Algorithms | |---------|---------------|--------------|------------|------------| | graphkit | — | 2024 | ✅ native | DFS/BFS/Dijkstra/Topo/SCC/MST | | graphlib | ~2.1M | 2018 (abandoned) | ❌ | DFS/BFS only | | @dagrejs/graphlib | ~800k | 2022 | partial | DFS/BFS only | | graph-data-structure | ~15k | 2019 | ❌ | Topo only |

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

MIT