rust-igraph
Pure-Rust, high-performance graph and network analysis library. A faithful port of
igraph with 400+ public APIs, zero unsafe, and no C/C++ FFI.
Built for researchers, data scientists, and systems engineers who need production-grade graph algorithms without leaving the Rust ecosystem.
Why rust-igraph?
| rust-igraph | petgraph | igraph (C/Python) | |
|---|---|---|---|
| Algorithm coverage | 400+ APIs (BFS, DFS, shortest paths, community detection, centrality, isomorphism, flows, layouts, graph generators, 60+ graph class recognizers...) | ~30 algorithms | ~850 APIs |
| Safety | Zero unsafe, zero unwrap in library code |
Some unsafe |
C core with FFI |
| Correctness | Cross-validated against igraph C, python-igraph, and R-igraph test suites | Independent | Reference implementation |
| Dependencies | Minimal (1 runtime dep: thiserror) |
Minimal | Large C/C++ toolchain |
| WASM | Designed for wasm32-unknown-unknown |
Yes | No |
Features
- Traversal: BFS, DFS, topological sort, random walks
- Shortest paths: Dijkstra, Bellman-Ford, A*, all-pairs, widest paths
- Centrality: betweenness, closeness, eigenvector, PageRank, HITS, harmonic, constraint
- Community detection: Louvain, Leiden, label propagation, Walktrap, edge betweenness, fast greedy, leading eigenvector, fluid communities, Voronoi
- Connectivity: connected/biconnected components, articulation points, bridges, separators, cohesive blocks, SCC
- Network flow: max-flow (push-relabel), min-cut, Gomory-Hu tree, edge/vertex connectivity, disjoint paths
- Isomorphism: VF2 (graph/subgraph), LAD subgraph, BLISS canonical labeling, automorphism groups
- Graph generators: Erdos-Renyi, Barabasi-Albert, Watts-Strogatz, SBM, forest fire, geometric random, degree sequence, lattices, famous graphs, and 30+ more
- Graph properties: 60+ structural recognizers (
is_bipartite,is_chordal,is_planar,is_perfect,is_cograph,is_series_parallel, ...) - Eigenvalue solvers: Lanczos (symmetric), Arnoldi (general), graph adjacency
- Layout: Fruchterman-Reingold, Kamada-Kawai, DrL, circle, star, grid, tree, bipartite
- Spatial: Delaunay triangulation, Gabriel graph, beta-skeleton, nearest-neighbor graph
- I/O: edge list, adjacency matrix, Prufer sequence, LCF notation
Quick start
Add to your Cargo.toml:
[]
= "0.0.1-alpha"
use ;
Community detection
use ;
let mut g = with_vertices;
// ... add edges forming two clusters ...
let result = louvain.unwrap;
println!;
println!;
Centrality analysis
use ;
let mut g = with_vertices;
g.add_edge.unwrap;
g.add_edge.unwrap;
g.add_edge.unwrap;
g.add_edge.unwrap;
let pr = pagerank.unwrap;
let bc = betweenness.unwrap;
println!;
println!;
Performance
All algorithms are implemented in idiomatic Rust with careful attention to cache locality
and allocation patterns. Benchmarks (via criterion) are included for every major algorithm:
Project status
Alpha (
v0.0.1-alpha) — The API is stabilizing but may change beforev0.1.0. Core algorithms are implemented and tested. Not yet recommended for production use without your own validation.
| Category | Status |
|---|---|
| Core data structures | Stable |
| Traversal (BFS, DFS) | Stable |
| Shortest paths | Stable |
| Centrality | Stable |
| Community detection | Stable |
| Connectivity | Stable |
| Network flow | Stable |
| Isomorphism | Stable |
| Graph generators | Stable |
| Layout algorithms | Beta |
| I/O formats | Partial |
Development
Each algorithm follows a 9-step AWU (Algorithm Work Unit) process tracked in
.codefuse/tracking/ALGORITHMS.md. The engineering
plan is in docs/plans/MASTER_PLAN.md.
License
GPL-2.0-or-later. Same as upstream igraph C, which permits direct reference-translation of the C source. See LICENSE.
Acknowledgements
- igraph by the igraph team (C core)
- python-igraph and rigraph (reference test suites)
- faer (linear algebra backend)