![Build Status] ![Discord Badge] ![Latest Version] ![Documentation]
Graphlib is a simple and powerful Rust graph library.
This library attempts to provide a generic api for building, mutating and iterating over graphs that is similar to that of other data-structures found in Rust i.e. Vec
, HashMap
, VecDeque
, etc.
```rust use graphlib::Graph;
let mut graph: Graph
// Add two vertices to the graph let id1 = graph.addvertex(1); let id2 = graph.addvertex(2);
// Add an edge between the two vertices graph.add_edge(&id1, &id2);
asserteq!(*graph.fetch(&id1).unwrap(), 1); asserteq!(*graph.fetch(&id2).unwrap(), 2);
// The graph has 2 vertices and one edge at this point asserteq!(graph.vertexcount(), 2); asserteq!(graph.edgecount(), 1);
// Remove one of the connected vertices graph.remove(&id1);
asserteq!(graph.vertexcount(), 1); asserteq!(graph.edgecount(), 0); ```
std
In Cargo.toml
:
toml
[dependencies]
graphlib = {version = "*", features = ["no_std"]}
We welcome anyone wishing to contribute to Graphlib! Check out the issues section of the repository before starting out.
Graphlib is licensed under the MIT license.