| Crates.io | sssp-lib |
| lib.rs | sssp-lib |
| version | 0.1.0 |
| created_at | 2026-01-17 10:51:10.479328+00 |
| updated_at | 2026-01-17 10:51:10.479328+00 |
| description | A library for Single Source Shortest Path (SSSP) algorithms in graphs |
| homepage | |
| repository | https://github.com/jc4st3lls/sssp-algorithm |
| max_upload_size | |
| id | 2050247 |
| size | 12,210 |
A Rust library for Single Source Shortest Path (SSSP) algorithms in graphs.
This crate provides an efficient implementation of SSSP using a bounded-memory shortest path algorithm, suitable for large graphs with constraints on memory and computation.
Add this to your Cargo.toml:
[dependencies]
sssp-lib = "0.1.0"
use sssp_lib::SSSPAlgorithm;
fn main() {
// Create a new algorithm instance with 5 nodes
let mut algo = SSSPAlgorithm::new(5);
// Add some edges
algo.graph.add_edge(0, 1, 1.0);
algo.graph.add_edge(1, 2, 2.0);
algo.graph.add_edge(2, 3, 1.0);
algo.graph.add_edge(0, 3, 4.0);
// Run SSSP from node 0
let distances = algo.run(0);
// Print distances
for (node, dist) in distances {
println!("Distance to node {}: {}", node, dist);
}
}
use sssp_lib::SSSPAlgorithm;
fn main() {
// Generate a large random graph with 1000 nodes, 5 edges per node
let algo = SSSPAlgorithm::generate_large_random(1000, 5);
// Run SSSP
let distances = algo.run(0);
println!("Reached {} nodes", distances.len());
}
Full API documentation is available at docs.rs/sssp-lib.
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributions are welcome! Please open an issue or submit a pull request.