btree_graph

Crates.iobtree_graph
lib.rsbtree_graph
version0.2.2
sourcesrc
created_at2021-01-18 23:36:04.06436
updated_at2021-01-22 00:10:03.90065
descriptionA generic graph data structure.
homepagehttps://github.com/jameone/btree_graph
repositoryhttps://github.com/jameone/btree_graph
max_upload_size
id343709
size55,568
James Spears (jameone)

documentation

README

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).

Example

use btree_graph::BTreeGraph;

fn main() {
    let mut graph: BTreeGraph<String, String> = BTreeGraph::new();
    // Add nodes.
    graph.add_vertex(String::from("Tarzan"));
    graph.add_vertex(String::from("Jane"));
    // 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")));
}

Usage

Add the following to your Cargo.toml file:

[dependencies]
btree_graph = "0.2.2"

API

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

License

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

Commit count: 54

cargo fmt