Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
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 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 the 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.
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 | Notes |
|---|---|---|
| Types | Directed and undirected graphsWeighted and unweighted graphsNodeId and EdgeId wrappersNodeMap and EdgeMap type aliasesOrderedNodeMap for deterministic iteration | Base types (graph, node, and edge) that Graphina supports |
| Error Handling | Unified GraphinaError for all Graphina modulesResult type aliasError conversion helpers | Error handling utilities for Graphina |
| Builders | AdvancedGraphBuilder with validationTopologyBuilder (path, cycle, star, and complete graph builders)Type aliases (DirectedGraphBuilder, UndirectedGraphBuilder) | Ergonomic graph construction utilities |
| IO | Edge list (read and write)Adjacency list (read and write) | I/O routines for reading and writing graph data |
| Serialization | JSON serializationBinary serializationGraphML exportSerializableGraph format | Multiple serialization formats for interoperability |
| Generators | Erdős–Rényi graphWatts–Strogatz graphBarabási–Albert graphComplete graph (directed and undirected)Bipartite graphStar graphCycle graphPath graphRandom tree | Graph generators for random and structured graphs |
| Paths | Dijkstra's algorithmBellman-Ford algorithmFloyd-Warshall algorithmJohnson's algorithmA* search algorithmIterative deepening A* (IDA*) | Shortest paths algorithms |
| Validation | Graph connectivity checkDAG validationBipartite checkNegative weights detectionSelf-loops detectionComponent countingAlgorithm precondition validators | Graph property validation utilities |
| Pool | NodeSet poolNodeMap poolNodeQueue poolThread-local default pools | Experimental memory pooling utilities |
Extensions
| Module | Feature/Algorithm | Notes |
|---|---|---|
| Centrality | DegreeClosenessBetweenness (node and edge)EigenvectorPageRank (standard and personalized)KatzHarmonicLocal reachingGlobal reachingVoteRank (seed selector)LaplacianPercolation (planned) | Centrality and influence measures |
| Metrics | DiameterRadiusAverage clustering coefficientClustering coefficient (local)Average path lengthTransitivityTriangles countAssortativity coefficient | Graph-level and node-level metrics |
| MST | Prim's algorithmKruskal's algorithmBorůvka's algorithm | Minimum spanning tree algorithms |
| Traversal | Breadth-first search (BFS)Depth-first search (DFS)Iterative deepening DFS (IDDFS)Bidirectional search | Graph traversal algorithms |
| Subgraphs | Subgraph extractionInduced subgraphEgo graphK-hop neighborsFilter nodes or edgesConnected component extractionComponent subgraph | Subgraph operations and filtering |
| Links | Resource allocation indexJaccard coefficientAdamic-Adar indexPreferential attachmentCommon neighborsCN Soundarajan-HopcroftRA index Soundarajan-HopcroftWithin-inter-cluster ratioCommon neighbor centrality | Link prediction algorithms |
| Community | Label propagationLouvain methodGirvan-Newman algorithmSpectral clusteringPersonalized PageRankInfomapConnected components | Community detection and clustering algorithms |
| Approximation | Node connectivity (BFS-based)Maximum independent set (greedy)Maximum clique (greedy heuristic)Clique removalLarge clique sizeAverage clustering coefficient (approximate)Densest subgraph (greedy peeling)Diameter lower boundMinimum weighted vertex cover (greedy)Minimum maximal matching (greedy)Ramsey number R(2,t) approximationTSP approximations (greedy, simulated annealing, threshold accepting, and Christofides)Treewidth decompositions (min degree, and min fill-in) | Approximation algorithms for NP-hard problems |
| Parallel | Parallel BFSParallel degree computationParallel clustering coefficientsParallel triangles countingParallel PageRankParallel shortest pathsParallel connected components | Parallel implementations of popular graph algorithms |
| Visualization | ASCII art visualizationForce-directed layoutCircular layoutGrid layoutHierarchical layoutHTML generationSVG exportPNG exportD3.js JSON format | Graph visualization algorithms |
Installation
cargo add graphina
Or add this to your Cargo.toml:
[]
= "0.4.0"
Or this to use Graphina with all the features enabled:
[]
= { = "0.4.0", = ["centrality", "community", "approximation", "mst", "traversal", "subgraphs", "visualization", "parallel", "pool"] }
[!NOTE] Graphina requires Rust 1.86 or later.
Documentation
Check out the docs and docs.rs/graphina for more information, including examples and API references.
Simple Example
use Graph;
Graph Builder API
use UndirectedGraphBuilder;
// Use graph builder API to create an undirected graph
let g = undirected
.with_capacity
.add_node
.add_node
.add_node
.add_edge
.add_edge
.build
.unwrap;
Seeded Generators
use ;
use Undirected;
// Use 42 for pseudo-random seed (for deterministic results)
let er = .unwrap;
let ba = .unwrap;
See the examples and tests directories for more usage examples.
Contributing
See 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)
- Apache License, Version 2.0 (LICENSE-APACHE)
PyGraphina is licensed under the MIT License (LICENSE).