15 releases (4 breaking)

✓ Uses Rust 2018 edition

0.5.3 Oct 4, 2019
0.5.2 Sep 25, 2019
0.4.0 Aug 17, 2019
0.3.1 May 6, 2019
0.1.3 Mar 16, 2019

#193 in Data structures

Download history 58/week @ 2019-07-22 45/week @ 2019-07-29 58/week @ 2019-08-05 44/week @ 2019-08-12 31/week @ 2019-08-19 97/week @ 2019-08-26 53/week @ 2019-09-02 17/week @ 2019-09-09 122/week @ 2019-09-16 69/week @ 2019-09-23 71/week @ 2019-09-30 74/week @ 2019-10-07 68/week @ 2019-10-14 99/week @ 2019-10-21 51/week @ 2019-10-28

251 downloads per month

MIT license

77KB
1K 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

~2MB
~38K SLoC