#graph #generic

no-std btree_graph

A generic graph data structure

7 releases

0.2.2 Jan 22, 2021
0.2.1 Jan 21, 2021
0.1.4 Jan 21, 2021

#1051 in Data structures

36 downloads per month
Used in try_encoding_from


528 lines

Binary Tree Graph (btree_graph)

CodeBuild Version badge Docs badge

This library is a minimal implementation of a graph (abstract data structure) by way of two binary tree maps (BTreeMap). This implementation is often referred to as an adjacency list.

The primary goals of this implementation are to be minimal and idiomatic to the Rust language. The alloc crate is the only dependency when compiled with default features and is not optional. As one might assume, alloc is required for reason the implementation relies on BTreeMap (and the BTreeSet wrapper).


use btree_graph::BTreeGraph;

fn main() {
    let mut graph: BTreeGraph<String, String> = BTreeGraph::new();
    // Add nodes.
    // Add a relationship.
    graph.add_edge(String::from("Tarzan"), String::from("Jane"), String::from("Loves"));
    // Assert relationship now exists.
    assert!(graph.adjacdent(String::from("Tarzan"), String::from("Jane")));


Add the following to your Cargo.toml file:

btree_graph = "0.2.2"


Please see the API for a full list of available methods.


This work is dually licensed under MIT OR Apache-2.0.


~11K SLoC