I did a trait-based BGL-like graph library for Rust (looking for feedback)

โš“ Rust    ๐Ÿ“… 2026-03-06    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 4      

surdeus

Hi everyone,

I'm fairly new to Rust and recently started working on a graph library called sinistra. I'm posting it here to get feedback on the design and whether the API feels idiomatic.

Crate: crates.io: Rust Package Registry
Repository: GitHub - wintermarstice/sinistra: A library for working with graph structured data. ยท GitHub

The project was inspired mainly by the Boost Graph Library. My goal was to build something that separates graph storage, topology, and algorithms, so algorithms can operate on many different graph representations.

Main ideas

  • Generic Graph and GraphMut traits
  • Separate Storage and Topology abstractions
  • Handle-based graph access (VertexHandle , EdgeHandle )
  • Traversal algorithms implemented as iterators / event streams
  • No dependencies
  • Avoid unnecessary allocations as much as possible (collect etc.)

Right now it includes:

  • BFS
  • DFS
  • Dijkstra

Example usage:

use sinistra::graph::{BasicGraph, GraphMut, HashMapStorage, HashMapTopology}; 

let storage = HashMapStorage::<&'static str, ()>::new(); 
let topology = HashMapTopology::new(); 
let mut graph = BasicGraph::new(storage, topology); 

let a = graph.add_vertex("A"); 
let b = graph.add_vertex("B");
 
graph.add_edge((), a, b);

The algorithms are designed to be generic over any Graph implementation.

For example BFS tree edges:

for (u, _, v) in bfs_tree_edges::<_, HashSet<VertexHandle>>(&graph, start) { 
    println!("v{} -> v{}", u.index(), v.index()); 
}

The library is incomplete, and some parts may be totally broken or unoptimal, although examples work correctly.

Iโ€™m also considering extending the project further (possibly toward a graph query engine or database later on), so I'm trying to get the core abstractions right early.

Any feedback, criticism, or suggestions would be greatly appreciated.

Thanks!

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed