Graphina
A graph data science library for Rust 🦀 with Python bindings 🐍
Install / Use
/learn @habedi/GraphinaREADME
Graphina
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.
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.
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).
Graphina Core
| Module | Feature or Algorithm | Notes |
|------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| Types | <ul><li>Directed and undirected graphs</li><li>Weighted and unweighted graphs</li><li>NodeId and EdgeId wrappers</li><li>NodeMap and EdgeMap type aliases</li><li>OrderedNodeMap for deterministic iteration</li></ul> | Base types (graph, node, and edge) that Graphina supports |
| Error Handling | <ul><li>Unified GraphinaError for all Graphina modules</li><li>Result type alias</li><li>Error conversion helpers</li></ul> | Error handling utilities for Graphina |
| Builders | <ul><li>AdvancedGraphBuilder with validation</li><li>TopologyBuilder (path, cycle, star, and complete graph builders)</li><li>Type aliases (DirectedGraphBuilder, UndirectedGraphBuilder)</li></ul> | Ergonomic graph construction utilities |
| IO | <ul><li>Edge list (read and write)</li><li>Adjacency list (read and write)</li></ul> | I/O routines for reading and writing graph data |
| Serialization | <ul><li>JSON serialization</li><li>Binary serialization</li><li>GraphML export</li><li>SerializableGraph format</li></ul> | Multiple serialization formats for interoperability |
| Generators | <ul><li>Erdős–Rényi graph</li><li>Watts–Strogatz graph</li><li>Barabási–Albert graph</li><li>Complete graph (directed and undirected)</li><li>Bipartite graph</li><li>Star graph</li><li>Cycle graph</li><li>Path graph</li><li>Random tree</li></ul> | Graph generators for random and structured graphs |
| Paths | <ul><li>Dijkstra's algorithm</li><li>Bellman-Ford algorithm</li><li>Floyd-Warshall algorithm</li><li>Johnson's algorithm</li><li>A* search algorithm</li><li>Iterative deepening A* (IDA*)</li></ul> | Shortest paths algorithms |
| Validation | <ul><li>Graph connectivity check</li><li>DAG validation</li><li>Bipartite check</li><li>Negative weights detection</li><li>Self-loops detection</li><li>Component counting</li><li>Algorithm precondition validators</li></ul> | Graph property validation utilities |
| Pool | <ul><li>NodeSet pool</li><li>NodeMap pool</li><li>NodeQueue pool</li><li>Thread-local default pools</li></ul> | Experimental memory pooling utilities |
Extensions
| Module | Feature/Algorithm | Notes | |-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------| | Centrality | <ul><li>Degree</li><li>Closeness</li><li>Betweenness (node and edge)</li><li>Eigenvector</li><li>PageRank (standard and personalized)</li><li>Katz</li><li>Harmonic</li><li>Local reaching</li><li>Global reaching</li><li>VoteRank (seed selector)</li><li>Laplacian</li><li><em>Percolation (planned)</em></li></ul> | Centrality and influence measures | | Metrics | <ul><li>Diameter</li><li>Radius</li><li>Average clustering coefficient</li><li>Clustering coefficient (local)</li><li>Average path length</li><li>Transitivity</li><li>Triangles count</li><li>Assortativity coefficient</li></ul> | Graph-level and node-level metrics | | MST | <ul><li>Prim's algorithm</li><li>Kruskal's algorithm</li><li>Borůvka's algorithm</li></ul>
