pub struct TaxonomyTree { /* private fields */ }Expand description
A rooted taxonomy tree.
Nodes are stored in a flat vector; parent links encode the tree structure.
Implementations§
Source§impl TaxonomyTree
impl TaxonomyTree
Sourcepub fn add_node(
&mut self,
name: &str,
rank: TaxonRank,
parent: Option<usize>,
) -> usize
pub fn add_node( &mut self, name: &str, rank: TaxonRank, parent: Option<usize>, ) -> usize
Add a node to the tree. Returns the node’s id.
The root node should have parent = None. All other nodes must
reference a valid parent id.
Sourcepub fn lca(&self, ids: &[usize]) -> Result<usize>
pub fn lca(&self, ids: &[usize]) -> Result<usize>
Compute the lowest common ancestor of a set of node ids.
Returns the deepest node that is an ancestor of all input nodes.
§Errors
Returns an error if ids is empty or any id is out of range.
Trait Implementations§
Source§impl Clone for TaxonomyTree
impl Clone for TaxonomyTree
Source§fn clone(&self) -> TaxonomyTree
fn clone(&self) -> TaxonomyTree
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TaxonomyTree
impl Debug for TaxonomyTree
Auto Trait Implementations§
impl Freeze for TaxonomyTree
impl RefUnwindSafe for TaxonomyTree
impl Send for TaxonomyTree
impl Sync for TaxonomyTree
impl Unpin for TaxonomyTree
impl UnsafeUnpin for TaxonomyTree
impl UnwindSafe for TaxonomyTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more