incremental-topo

Crates.ioincremental-topo
lib.rsincremental-topo
version0.2.1
sourcesrc
created_at2018-09-05 21:46:49.07502
updated_at2022-07-14 16:59:38.008317
descriptionData structure to maintain an incremental topological ordering over a collection of values
homepage
repositoryhttps://github.com/declanvk/incremental-topo/
max_upload_size
id83108
size112,842
Declan Kelly (declanvk)

documentation

https://docs.rs/incremental-topo/

README

Incremental Topo

Crates.io Travis CI Documentation

A data structure for maintaining an topological ordering in an incremental fashion.

Usage

To use incremental-topo, first add this to your Cargo.toml:

[dependencies]
incremental-topo = "0.2.1"

Next, add this to your crate:

use incremental_topo::IncrementalTopo;

let mut dag = IncrementalTopo::new();

let cat = dag.add_node();
let dog = dag.add_node();
let human = dag.add_node();

assert_eq!(dag.len(), 3);

dag.add_dependency(&human, &dog).unwrap();
dag.add_dependency(&human, &cat).unwrap();
dag.add_dependency(&dog, &cat).unwrap();

let animal_order: Vec<_> = dag.descendants(&human).unwrap().collect();

assert_eq!(animal_order, vec![dog, cat]);

See documentation for more details.

License

This project is dual licensed under the MIT license and Apache 2.0 license.

Commit count: 85

cargo fmt