graaf 0.21.0

Functions and types for working with graphs
Documentation

Graaf!Build status Crates.io API reference Coverage Status

Functions and types for working with graphs

Graaf is Dutch for

  1. graph
  2. count
  3. dig

This crate is in alpha, and the API will change. See the changelog for a provisional roadmap.

Installation

Add the following to your Cargo.toml:

[dependencies]
graaf = "0.21.0"

Usage

use graaf::{
    op::{
        AddEdge,
        Indegree,
        Outdegree,
    },
    std::collections::HashSet,
};

let mut graph = [HashSet::new(), HashSet::new(), HashSet::new()];

graph.add_edge(0, 1);
graph.add_edge(0, 2);
graph.add_edge(1, 2);

assert_eq!(graph.indegree(0), 0);
assert_eq!(graph.indegree(1), 1);
assert_eq!(graph.indegree(2), 2);

assert_eq!(graph.outdegree(0), 2);
assert_eq!(graph.outdegree(1), 1);
assert_eq!(graph.outdegree(2), 0);

Overview

Algorithms

Common graph algorithms:

Operations

Graph operation traits and implementations:

Features

  • nightly: required for the adjacency_matrix feature.
  • adjacency_matrix: an adjacency matrix representation stored as a bit array.

To enable the adjacency_matrix feature, add the following to your Cargo.toml:

[dependencies]
graaf = { version = "0.21.0", features = ["adjacency_matrix", "nightly"] }