dep-graph

Crates.iodep-graph
lib.rsdep-graph
version0.2.0
sourcesrc
created_at2020-07-05 16:55:30.165192
updated_at2020-12-27 19:17:06.493478
descriptionDependency graph resolver library
homepage
repositoryhttps://github.com/nmoutschen/dep-graph
max_upload_size
id261654
size35,541
Nicolas Moutschen (nmoutschen)

documentation

README

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)
        });
}
Commit count: 12

cargo fmt