Graph Algorithms
in Pure Rust

1,297 APIs. Zero unsafe. One dependency. Runs natively and in the browser via WASM.

cargo add rust-igraph
1,297Public APIs
315Algorithms
8,287Tests
0unsafe blocks
1Dependency

Simple, Expressive API

Graph Construction & Analysis
use rust_igraph::{Graph, pagerank, louvain};

fn main() {
    let g = Graph::from_edges(
        &[(0,1), (1,2), (2,0), (2,3), (3,4), (4,5), (5,3)],
        false, None
    ).unwrap();

    // Centrality analysis
    let pr = pagerank(&g).unwrap();
    println!("PageRank: {:?}", pr);

    // Community detection
    let communities = louvain(&g).unwrap();
    println!("Modularity: {:.4}", communities.modularity);
}
Method-style API
use rust_igraph::Graph;

let g = Graph::erdos_renyi(1000, 0.01, 42).unwrap();

// Structural queries
assert!(g.is_connected().unwrap());
println!("Diameter: {:?}", g.diameter().unwrap());
println!("Triangles: {}", g.count_triangles().unwrap());

// Centrality & community
let pr = g.pagerank().unwrap();
let communities = g.louvain().unwrap();

// Graph algebra
let a = Graph::from_edges(&[(0,1)], false, None).unwrap();
let b = Graph::from_edges(&[(1,2)], false, None).unwrap();
let union = &a | &b; // edge union

Comprehensive Algorithm Coverage

Traversal & Paths

BFS, DFS, Dijkstra, Bellman-Ford, A*, all-pairs shortest paths, widest paths, topological sort

Centrality

PageRank, betweenness, closeness, eigenvector, HITS, Katz, harmonic, constraint — 15+ measures

Community Detection

Louvain, Leiden, Infomap, Spinglass, label propagation, Walktrap, edge betweenness, fast greedy, fluid, Voronoi

Network Flow

Max-flow (push-relabel), min-cut, Gomory-Hu tree, edge/vertex connectivity, disjoint paths

Isomorphism

VF2 graph/subgraph matching, LAD subgraph, canonical labeling (BLISS), automorphism groups

Generators & Layout

30+ graph generators, 16 layout engines (FR, KK, DrL, Sugiyama, MDS, UMAP...), spatial algorithms

How Does It Compare?

rust-igraph petgraph igraph (C/Python) NetworkX
Algorithm scope 1,297 APIs ~50 (composable) ~850 (reference) ~500
Safety Zero unsafe Minimal unsafe C core + bindings Memory-safe (Python)
Validation Cross-validated vs igraph C/py/R Independent tests Reference impl Independent tests
WASM Native Native Not available Via Pyodide
Dependencies 1 (thiserror) Minimal C/C++ build toolchain NumPy + SciPy

Runs in the Browser

Compile to WASM and run graph algorithms client-side — no server needed. Try it live in the playground.

Open Playground

Ecosystem

crates.io docs.rs CI codecov license MSRV PRs Welcome