wolf-graph 0.1.0

Data structures and algorithms for working with graphs with reference or value semantics.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use anyhow::Result;

use crate::{MutableForest, NodeID, VisitableTree};

pub trait MutableTree: VisitableTree + MutableForest {
    fn set_root(&mut self, root: impl AsRef<NodeID>) -> Result<()>;

    fn setting_root(&self, root: impl AsRef<NodeID>) -> Result<Self>
    where
        Self: Clone + Sized,
    {
        let mut tree = self.clone();
        tree.set_root(root)?;
        Ok(tree)
    }
}