szyk

generic topological sort

6 releases (3 stable)

1.0.2 Apr 16, 2021
1.0.1 Apr 7, 2021
0.1.2 Apr 4, 2021
Download history 21/week @ 2024-07-19 115/week @ 2024-07-26 40/week @ 2024-08-02 95/week @ 2024-08-09 462/week @ 2024-08-16 99/week @ 2024-08-23 259/week @ 2024-08-30 18/week @ 2024-09-06 9/week @ 2024-09-13 90/week @ 2024-09-20 36/week @ 2024-09-27 5/week @ 2024-10-04 8/week @ 2024-10-11 105/week @ 2024-10-18 27/week @ 2024-10-25 44/week @ 2024-11-01

184 downloads per month
Used in 3 crates (2 directly)

ISC license

8KB
147 lines

szyk-rs

Generic topsort for Rust

crates.io

Example

use szyk::Node;
use szyk;

let result = szyk::sort(
    &[
        Node::new("wooden pickaxe", vec!["planks", "sticks"], "Pickaxe"),
        Node::new("planks", vec!["wood"], "Planks"),
        Node::new("sticks", vec!["planks"], "Sticks"),
        Node::new("wood", vec![], "Wood"),
    ],
    "wooden pickaxe",
);
assert_eq!(result, Ok(vec!["Wood", "Planks", "Sticks", "Pickaxe"]));

lib.rs:

Generic topological sort algorithm (depth-first)

Examples

    use szyk::Node;
    use szyk;

    let result = szyk::sort(
        &[
            Node::new("wooden pickaxe", vec!["planks", "sticks"], "Pickaxe"),
            Node::new("planks", vec!["wood"], "Planks"),
            Node::new("sticks", vec!["planks"], "Sticks"),
            Node::new("wood", vec![], "Wood"),
        ],
        "wooden pickaxe",
    );
    assert_eq!(result, Ok(vec!["Wood", "Planks", "Sticks", "Pickaxe"]));

No runtime deps