Graphina is a graph data science library for Rust. It provides common data structures and algorithms for analyzing real-world networks, such as social, transportation, and biological networks.
Compared to other Rust graph libraries like petgraph and rustworkx, Graphina aims to provide a more high-level API and a wide range of ready-to-use algorithms for network analysis and graph mining tasks. Graphina aims to be as feature-rich as NetworkX but with the speed and performance benefits of Rust.
Additionally, PyGraphina Python library allows users to use Graphina in Python. Check out pygraphina directory for more details.
See ROADMAP.md for the list of implemented and planned features.
Important
This project is in early development, so bugs and breaking changes are expected. Please use the issues page to report bugs or request features.
Graphina consists of two main parts: a core library and extensions. The core library provides the basic data structures and algorithms for working with graphs. The extensions are modules outside the core library that contain more advanced algorithms for specific tasks like community detection, link prediction, and calculating node and edge centrality scores.
Extensions are independent of each other but depend on the core library.
To use an extension, you must enable it in your Cargo.toml file as a feature (see Installation section below).
| Module | Feature or Algorithm | Notes |
|---|---|---|
| Types |
|
Base types (graph, node, and edge) that Graphina supports |
| Error Handling |
|
Error handling utilities for Graphina |
| Builders |
|
Ergonomic graph construction utilities |
| IO |
|
I/O routines for reading and writing graph data |
| Serialization |
|
Multiple serialization formats for interoperability |
| Generators |
|
Graph generators for random and structured graphs |
| Paths |
|
Shortest paths algorithms |
| Validation |
|
Graph property validation utilities |
| Pool |
|
Experimental memory pooling utilities |
| Module | Feature/Algorithm | Notes |
|---|---|---|
| Centrality |
|
Centrality and influence measures |
| Metrics |
|
Graph-level and node-level metrics |
| MST |
|
Minimum spanning tree algorithms |
| Traversal |
|
Graph traversal algorithms |
| Subgraphs |
|
Subgraph operations and filtering |
| Links |
|
Link prediction algorithms |
| Community |
|
Community detection and clustering algorithms |
| Approximation |
|
Approximation algorithms for NP-hard problems |
| Parallel |
|
Parallel implementations of popular graph algorithms |
| Visualization |
|
Graph visualization algorithms |
cargo add graphinaOr add this to your Cargo.toml:
[dependencies]
graphina = "0.3.0-alpha.4"Or enable all features with:
[dependencies]
graphina = { version = "0.3.0-alpha.4", features = ["centrality", "community", "approximation", "mst", "traversal", "subgraphs", "visualization", "parallel", "pool"] }Note
Graphina requires Rust 1.86 or later.
See docs and docs.rs/graphina for more information for the detailed documentation including examples and API references.
use graphina::core::types::Graph;
fn main() {
// Create a new undirected graph
let mut graph = Graph::new();
// Add nodes and edges to the graph
let n0 = graph.add_node(1);
let n1 = graph.add_node(1);
let n2 = graph.add_node(2);
let n3 = graph.add_node(3);
graph.add_edge(n0, n1, 1.0);
graph.add_edge(n1, n2, 1.0);
graph.add_edge(n2, n3, 1.0);
// Get the neighbors of node 1
for neighbor in graph.neighbors(n1) {
println!("Node 1 has neighbor: {}", neighbor.index());
}
}use graphina::core::builders::UndirectedGraphBuilder;
// Use graph builder API to create an undirected graph
let g = UndirectedGraphBuilder::<i32, f64>::undirected()
.with_capacity(4, 3)
.add_node(1)
.add_node(2)
.add_node(3)
.add_edge(0, 1, 1.0)
.add_edge(1, 2, 2.0)
.build()
.unwrap();use graphina::core::generators::{erdos_renyi_graph, barabasi_albert_graph};
use graphina::core::types::Undirected;
// Use 42 for pseudo-random seed (for deterministic results)
let er = erdos_renyi_graph::<Undirected>(100, 0.2, 42).unwrap();
let ba = barabasi_albert_graph::<Undirected>(1000, 3, 42).unwrap();See CONTRIBUTING.md for details on how to make a contribution.
The mascot is named "Graphina the Dinosaur". As the name implies, she's a dinosaur, however, she herself thinks she's a dragon.
The logo was created using GIMP, ComfyUI, and a Flux Schnell v2 model.
Graphina is licensed under either of these:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
PyGraphina is licensed under the MIT License (LICENSE).