#topological #incremental #graph #dag

incremental-topo

Data structure to maintain an incremental topological ordering over a collection of values

5 releases

0.2.1 Jul 14, 2022
0.2.0 Jul 10, 2022
0.1.2 Aug 2, 2019
0.1.1 Sep 19, 2018
0.1.0 Sep 5, 2018

#1541 in Data structures

Download history 67/week @ 2024-07-21 121/week @ 2024-07-28 93/week @ 2024-08-04 501/week @ 2024-08-11 617/week @ 2024-08-18 644/week @ 2024-08-25 612/week @ 2024-09-01 562/week @ 2024-09-08 598/week @ 2024-09-15 659/week @ 2024-09-22 650/week @ 2024-09-29 599/week @ 2024-10-06 653/week @ 2024-10-13 701/week @ 2024-10-20 670/week @ 2024-10-27 571/week @ 2024-11-03

2,666 downloads per month
Used in p2panda-rs

MIT/Apache

43KB
548 lines

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.

Dependencies

~160KB