rust-igraph
Pure-Rust, high-performance graph and network analysis library. A faithful port of
igraph with 1,297 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 | 1,297 APIs (BFS, DFS, shortest paths, community detection, centrality, isomorphism, flows, layouts, graph generators, 60+ graph class recognizers...) | ~50 (composable) | ~850 APIs (reference) |
| Safety | Zero unsafe, zero unwrap in library code |
Minimal unsafe |
C core + bindings |
| 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, Katz, harmonic, constraint
- Community detection: Louvain, Leiden, Infomap, Spinglass, 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, Sugiyama, GEM, Davidson-Harel, GraphOpt, MDS, LGL, UMAP, Reingold-Tilford, circle, star, grid, bipartite (16 engines, 2D+3D)
- Spatial: Delaunay triangulation, Gabriel graph, beta-skeleton, nearest-neighbor graph
- I/O: GML, GraphML, Pajek, DOT/Graphviz, LEDA, UCINET DL, DIMACS, edge list, NCOL, LGL, GraphDB (15 read/write functions)
Quick start
Add to your Cargo.toml:
[]
= "0.7"
use ;
Graph construction
use ;
// Fluent builder pattern
let g = undirected
.vertices
.edges
.cycle
.build
.unwrap;
// From an edge list (auto-infers vertex count)
let g = from_edges.unwrap;
// From a slice via TryFrom
let g = try_from.unwrap;
// From a string (great for tests)
let g = from_edge_list_str.unwrap;
// Classic generators
let k5 = full_graph.unwrap;
let ring = cycle_graph.unwrap;
Graph algebra (operator overloading)
use Graph;
let a = from_edges.unwrap;
let b = from_edges.unwrap;
let union = &a | &b; // edges in either graph
let intersection = &a & &b; // edges in both graphs
let difference = &a - &b; // edges in a but not b
let complement = !&a; // all missing edges
let disjoint = &a + &b; // concatenated (6 vertices)
Community detection
use ;
let mut g = with_vertices;
// ... add edges forming two clusters ...
let result = louvain.unwrap;
println!;
println!;
Centrality analysis
use ;
let g = from_edges.unwrap;
let pr = pagerank.unwrap;
let bc = betweenness.unwrap;
let katz = katz_centrality.unwrap;
println!;
println!;
println!;
Method-style API
The most common operations are available directly on Graph:
use Graph;
let g = from_edges.unwrap;
// Structural queries
assert!;
println!;
println!;
println!;
// Centrality
let pr = g.pagerank.unwrap;
let bc = g.betweenness.unwrap;
let hc = g.harmonic_centrality.unwrap;
// Community detection
let communities = g.louvain.unwrap;
println!;
// Graph construction
let er = erdos_renyi.unwrap;
let ws = watts_strogatz.unwrap;
let ba = barabasi_albert.unwrap;
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
v0.7.0 — 315 algorithm work units complete, 1,297 public functions, 1,100 tests, 1,850 conformance fixtures. API stabilizing toward
v1.0.0.
| 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 | Stable (16 engines) |
| I/O formats | Stable (15 functions) |
| Spatial algorithms | Stable |
Releases
This repository produces two independent release artifacts:
| Package | Registry | Tag pattern | Trigger |
|---|---|---|---|
rust-igraph |
crates.io | v* (e.g. v0.6.0) |
Rust library release |
@graphrs/igraph-wasm |
npm | wasm-v* (e.g. wasm-v0.1.4) |
WASM binary release |
They follow independent version schedules. WASM builds are published via npm Trusted Publishing (OIDC) — zero static tokens, cryptographically signed provenance.
Documentation
- Tutorial & Guide — mdBook with getting started, cookbook, and architecture overview
- API Reference — full rustdoc for all 1,297 public items
- docs.rs — auto-published on every crates.io release
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.
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
Whether you want to fix a bug, add an algorithm, improve docs, or optimize performance — we'd love your help. Open an issue to discuss larger changes before starting.
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)