sinistra
Sinistra is a lightweight, generic graph framework for Rust with pluggable storage and topology and streaming traversal algorithms.
It provides composable abstractions for representing graph structure and data separately, allowing algorithms such as BFS, DFS, Dijkstra, and topological sort to operate on many kinds of graph representations.
Why sinistra?
Most graph libraries tightly couple graph storage with connectivity.
Sinistra separates graph data from graph structure: Graph = Storage (vertex/edge data) + Topology (connectivity)
This design allows algorithms to run on different graph backends without modification.
Possible uses include:
- in-memory graphs
- dense/indexed graphs
- implicit graphs
- database-backed graphs
- custom graph views and adapters
Algorithms operate on the Graph trait, making them reusable across different graph representations.
Features
- Generic
GraphandGraphMuttraits BasicGraphimplementation with pluggable storage and topology- Built-in storage and topology implementations:
HashMapStorage+HashMapTopology
- Directed and undirected graph topologies (
Undirected<T>wrapper) - Traversal and shortest-path algorithms:
bfs,bfs_vertices,bfs_tree_edges,bfs_layers,has_pathdfsdijkstra,dijkstra_distancestopological_sort,is_dag
- Streaming algorithms using iterators and events
- Zero required allocations inside algorithms
Getting started
Add sinistra to your Cargo.toml:
[]
= "0.1.0-202603071957"
Create a graph:
use ;
let storage = new;
let topology = new;
let mut graph = new;
let a = graph.add_vertex;
let b = graph.add_vertex;
graph.add_edge;
Examples
Run all examples:
Development
Coverage
Generate an LCOV report locally:
License
Licensed under the MIT License. See LICENSE.