wolf-graph 0.1.0

Data structures and algorithms for working with graphs with reference or value semantics.
Documentation
use anyhow::Result;

use crate::{EdgeID, NodeID, Nodes, VisitableGraph};

pub trait VisitableForest: VisitableGraph {
    fn in_edge(&self, node: impl AsRef<NodeID>) -> Result<Option<EdgeID>>;
    fn in_edge_with_root(&self, node: impl AsRef<NodeID>) -> Result<Option<EdgeID>>;
    fn parent(&self, node: impl AsRef<NodeID>) -> Result<Option<NodeID>>;
    fn children(&self, node: Option<impl AsRef<NodeID>>) -> Result<Nodes>;
    fn has_children(&self, node: impl AsRef<NodeID>) -> Result<bool>;
    fn child_count(&self, node: impl AsRef<NodeID>) -> Result<usize>;

    fn descendants(&self, nodes: &Nodes) -> Result<Nodes> {
        self.transitive_successors(nodes)
    }

    fn ancestors(&self, nodes: &Nodes) -> Result<Nodes> {
        self.transitive_predecessors(nodes)
    }
}