Skip to content

graphrsGraph Algorithms at Native Speed

The igraph for JavaScript — 400+ graph algorithms powered by Rust/WASM. Community detection, centrality, layout, flow, isomorphism. Tree-shakable. TypeScript. Browser & Node.js.

graphrs logographrs logo

Quick Start

bash
npm install @graphrs/core @graphrs/community @graphrs/centrality
typescript
import { Graph } from '@graphrs/core';
import { louvain } from '@graphrs/community';
import { pagerank } from '@graphrs/centrality';

const graph = Graph.fromEdges([
  [0, 1], [1, 2], [2, 0],   // cluster A
  [3, 4], [4, 5], [5, 3],   // cluster B
  [2, 3],                    // bridge
]);

const communities = await louvain(graph);
// → { membership: [0,0,0,1,1,1], modularity: 0.357 }

const pr = await pagerank(graph);
// → { scores: [0.12, 0.15, 0.23, 0.18, 0.16, 0.16] }

Why graphrs?

Python has igraph (C core, fast) and networkx (pure Python, slow). JavaScript had nothing in the fast category — until now.

graphologycytoscape.js@graphrs
Community detection2 algorithms010+
Centrality measures7215+
Layout algorithms3ext16
Network flow00Full
Isomorphism00VF2
10k nodes PageRank~5–10 sN/A~100 ms

Framework Integration

bash
# AntV G6 — layout + community detection + centrality
npm install @graphrs/g6

# React Flow — auto-layout hook (React Flow has ZERO built-in layout)
npm install @graphrs/react-flow
typescript
// G6: plug-and-play layout
import { createGraphrsLayout } from '@graphrs/g6';
new G6Graph({ layout: createGraphrsLayout({ algorithm: 'fruchterman-reingold' }) });

// React Flow: one-line auto-layout
import { useGraphrsLayout } from '@graphrs/react-flow';
const { nodes, edges } = useGraphrsLayout(initialNodes, initialEdges);

MIT License (TS code) · GPL-2.0 (WASM binary)