Crate szyk

Source
Expand description

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"]));

Structs§

Node

Enums§

TopsortError

Functions§

sort
returns values of nodes from domain in topological order, ending on the node with id of target
sort_cb
calls cb with nodes from domain in topological order, ending on the node with id of target