Skip to content

Repository files navigation

Graphlib

Build StatusDiscord BadgeLatest VersionDocumentation

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;letmut graph:Graph<usize> = Graph::new();// Add two vertices to the graphlet 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 pointassert_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.

About

Simple but powerful graph library for Rust

Topics

Resources

Stars

196 stars

Watchers

8 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages