#graph-algorithms #graph #mutable

no-std graphlib

Graphlib is a simple and powerful rust library for the graph data-structure

19 releases

0.6.3 Nov 9, 2021
0.6.2 Apr 14, 2020
0.6.1 Feb 18, 2020
0.5.3 Oct 4, 2019
0.2.3 Mar 27, 2019

#2052 in Data structures

Download history 117/week @ 2024-07-21 144/week @ 2024-07-28 6/week @ 2024-08-04 5/week @ 2024-08-11 1/week @ 2024-08-18 9/week @ 2024-08-25 12/week @ 2024-09-01 29/week @ 2024-09-08 109/week @ 2024-09-15 127/week @ 2024-09-22 143/week @ 2024-09-29 189/week @ 2024-10-06 128/week @ 2024-10-13 89/week @ 2024-10-20 32/week @ 2024-10-27 62/week @ 2024-11-03

318 downloads per month
Used in 2 crates

MIT license

105KB
1.5K SLoC

Graphlib

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.

Using Graphlib

use graphlib::Graph;

let mut graph: Graph<usize> = Graph::new();

// Add two vertices to the graph
let id1 = graph.add_vertex(1);
let id2 = graph.add_vertex(2);

// Add an edge between the two vertices
graph.add_edge(&id1, &id2);

assert_eq!(*graph.fetch(&id1).unwrap(), 1);
assert_eq!(*graph.fetch(&id2).unwrap(), 2);

// The graph has 2 vertices and one edge at this point
assert_eq!(graph.vertex_count(), 2);
assert_eq!(graph.edge_count(), 1);

// Remove one of the connected vertices
graph.remove(&id1);

assert_eq!(graph.vertex_count(), 1);
assert_eq!(graph.edge_count(), 0);

Using without std

In Cargo.toml:

[dependencies]
graphlib = { version = "*", features = ["no_std"] }

Contributing

We welcome anyone wishing to contribute to Graphlib! Check out the issues section of the repository before starting out.

License

Graphlib is licensed under the MIT license.

Dependencies

~3MB
~51K SLoC