https://github.com/habedi/graphina
A graph data science library for Rust :crab:
https://github.com/habedi/graphina
crates-io data-mining-algorithms data-science graph-algorithms graph-analytics graph-theory network-analysis rust-lang social-network-analysis
Last synced: 4 months ago
JSON representation
A graph data science library for Rust :crab:
- Host: GitHub
- URL: https://github.com/habedi/graphina
- Owner: habedi
- License: apache-2.0
- Created: 2025-02-19T07:39:00.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-05-06T16:10:18.000Z (7 months ago)
- Last Synced: 2025-06-30T23:15:59.736Z (5 months ago)
- Topics: crates-io, data-mining-algorithms, data-science, graph-algorithms, graph-analytics, graph-theory, network-analysis, rust-lang, social-network-analysis
- Language: Rust
- Homepage:
- Size: 57.6 KB
- Stars: 54
- Watchers: 2
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Graphina
[](https://github.com/habedi/graphina/actions/workflows/tests.yml)
[](https://github.com/habedi/graphina/actions/workflows/lint.yml)
[](https://codecov.io/gh/habedi/graphina)
[](https://www.codefactor.io/repository/github/habedi/graphina)
[](https://crates.io/crates/graphina)
[](https://docs.rs/graphina)
[](https://crates.io/crates/graphina)
[](https://github.com/rust-lang/rust/releases/tag/1.83.0)
[](docs)
[](https://github.com/habedi/graphina)
Graphina is a graph data science library for Rust.
It provides the common data structures and algorithms used for analyzing the graphs of real-world networks such as
social, transportation, and biological networks.
Compared to other Rust graph libraries like [petgraph](https://github.com/petgraph/petgraph)
and [rustworkx](https://www.rustworkx.org/), 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.
The main goal is to make Graphina as feature-rich as [NetworkX](https://networkx.org/),
but with the performance of Rust.
Additionally, [PyGraphina](https://pypi.org/project/pygraphina/) Python library allows users to use Graphina in Python.
Check out [pygraphina](pygraphina/) directory for more details.
> [!IMPORTANT]
> Graphina is in the early stages of development, so breaking changes may occur.
> Bugs and API inconsistencies are also expected, and the algorithms may not yet be optimized for performance.
### Structure
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.
The extensions are independent of each other. However, they depend on the core library for the basic graph operations.
#### Graphina Core
| Module | Feature or Algorithm | Status | Notes |
|------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|---------------------------------------------------|
| [**Types**](src/core/types.rs) |
- Directed and undirected graphs
- Weighted and unweighted graphs
| [**Exceptions**](src/core/exceptions.rs) |
- List of exceptions
| [**IO**](src/core/io.rs) |
- Edge list
- Adjacency list
| [**Generators**](src/core/generators.rs) |
- Erdős–Rényi graph
- Watts–Strogatz graph
- Barabási–Albert graph
- Complete graph
- Bipartite graph
- Star graph
- Cycle graph
| [**Paths**](src/core/paths.rs) |
- Dijkstra’s algorithm
- Bellman–Ford algorithm
- Floyd–Warshall algorithm
- Johnson’s algorithm
- A* search algorithm
- Iterative deepening A*
| [**MST**](src/core/mst.rs) |
- Prim’s algorithm
- Kruskal’s algorithm
- Borůvka’s algorithm
| [**Traversal**](src/core/traversal.rs) |
- Breadth-first search (BFS)
- Depth-first search (DFS)
- Iterative deepening DFS
- Bidirectional search
#### Extensions
| Module | Feature/Algorithm | Status | Notes |
|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|-----------------------------------------------------------|
| [**Centrality**](src/centrality/algorithms.rs) |
- Degree centrality
- Closeness centrality
- Betweenness centrality
- Eigenvector centrality
- PageRank centrality
- Katz centrality
- Harmonic centrality
- Local/global reaching centrality
- Voterank centrality
- Laplacian centrality
| [**Links**](src/links/algorithms.rs) |
- Resource allocation index
- Jaccard coefficient
- Adamic–Adar index
- Preferential attachment
- CN Soundarajan–Hopcroft
- RA index Soundarajan–Hopcroft
- Within–inter-cluster ratio
- Common neighbor centrality
| [**Community**](src/community/algorithms.rs) |
- Label propagation
- Louvain method
- Girvan–Newman algorithm
- Spectral clustering
- Personalized PageRank
- Infomap
- Connected components
| [**Approximation**](src/approximation/algorithms.rs) |
- Local node connectivity (BFS-based)
- Maximum independent set (greedy with neighbor caching)
- Maximum clique (greedy heuristic)
- Clique removal
- Large clique size
- Average clustering coefficient
- Densest subgraph (greedy peeling)
- Diameter lower bound
- Minimum weighted vertex cover (greedy re‑evaluated)
- Minimum maximal matching (greedy)
- Approximate Ramsey R2
- TSP approximations (greedy, simulated annealing, threshold accepting, Christofides placeholder)
- Treewidth decompositions (min degree, min fill-in)
> [!NOTE]
> Status shows whether the module is `Tested` and `Benchmarked`.
> Empty status means the module is implemented but not tested and benchmarked yet.
### Installation
```shell
cargo add graphina
```
Or add this to your `Cargo.toml`:
```toml
[dependencies]
graphina = "0.2"
```
*Graphina requires Rust 1.83 or later.*
### Documentation
See the [docs](docs/README.md) for the latest documentation.
Check out the [docs.rs/graphina](https://docs.rs/graphina) for the latest API documentation.
#### Simple Example
```rust
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());
}
}
```
See the [examples](examples) and [tests](tests) directories for more usage examples.
### Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to make a contribution.
### Logo
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.
### Licensing
Graphina is licensed under either of these:
* MIT License ([LICENSE-MIT](LICENSE-MIT))
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
PyGraphina is licensed under the MIT License ([LICENSE](pygraphina/LICENSE)).