8 releases

0.2.0 Dec 27, 2020
0.1.6 Dec 25, 2020
0.1.5 Jul 9, 2020
Download history 1/week @ 2021-03-17 18/week @ 2021-03-24 17/week @ 2021-03-31 9/week @ 2021-04-07 41/week @ 2021-04-14 6/week @ 2021-04-21 6/week @ 2021-04-28 1/week @ 2021-05-05 11/week @ 2021-05-12 1/week @ 2021-05-19 3/week @ 2021-05-26 1/week @ 2021-06-02 11/week @ 2021-06-09 1/week @ 2021-06-16 2/week @ 2021-06-23 2/week @ 2021-06-30

62 downloads per month
Used in orcs

MIT license

30KB
612 lines

Dependency Graph

This is a rust library to perform iterative operations over dependency graphs.

Usage

[dependencies]
dep-graph = "0.2"

This library supports both sequential and parallel (multi-threaded) operations out of the box. By default, multi-threaded operations will run a number of threads equal to the number of cores.

Parallel operations

Here is a simple example on how to use this library:

use dep_graph::{Node, DepGraph};
#[cfg(feature = "parallel")]
use rayon::prelude::*;

// Create a list of nodes
let mut root = Node::new("root");
let mut dep1 = Node::new("dep1");
let mut dep2 = Node::new("dep2");
let leaf = Node::new("leaf");

// Map their connections
root.add_dep(dep1.id());
root.add_dep(dep2.id());
dep1.add_dep(leaf.id());
dep2.add_dep(leaf.id());

// Create a graph
let nodes = vec![root, dep1, dep2, leaf];

// Print the name of all nodes in the dependency graph.
// This will parse the dependency graph sequentially
{
    let graph = DepGraph::new(&nodes);
    graph
        .into_iter()
        .for_each(|node| {
            println!("{:?}", node)
        });
}

// This is the same as the previous command, excepts it leverages rayon
// to process them in parallel as much as possible.
#[cfg(feature = "parallel")]
{
    let graph = DepGraph::new(&nodes);
    graph
        .into_par_iter()
        .for_each(|node| {
            // The node is a dep_graph::Wrapper object, not a String.
            // We need to use `*node` to get its value.
            println!("{:?}", *node)
        });
}

Dependencies

~15–335KB