Tree

Struct Tree 

Source
pub struct Tree<Payload, MetaData, Edge> { /* private fields */ }

Implementations§

Source§

impl<P, D, E> Tree<P, D, E>

Source

pub fn to_newick<NodeFormatter, S1, EdgeFormatter, S2>( &self, fmt_node: NodeFormatter, fmt_edge: EdgeFormatter, ) -> String
where NodeFormatter: Fn(&P) -> S1, S1: Display + Default, EdgeFormatter: Fn(&E) -> S2, S2: Display + Default,

Source

pub fn to_string<NodeFormatter, S1, EdgeFormatter, S2>( &self, fmt_node: NodeFormatter, fmt_edge: EdgeFormatter, only_leaves: bool, ) -> String
where NodeFormatter: Fn(&P) -> S1, S1: Display + Default, EdgeFormatter: Fn(&E) -> S2, S2: Display + Default,

Source§

impl<P, D, E> Tree<P, D, E>
where D: Default,

Source

pub fn new() -> Tree<P, D, E>

Source§

impl<P, D, E> Tree<P, D, E>

Source

pub fn with_metadata(metadata: D) -> Tree<P, D, E>

Source

pub fn metadata(&self) -> &D

Source

pub fn metadata_mut(&mut self) -> &mut D

Source

pub fn get(&self, n: usize) -> Result<&Node<P, E>, Error>

Source

pub fn get_mut(&mut self, n: usize) -> Result<&mut Node<P, E>, Error>

Source

pub fn set_root(&mut self, new_root: usize)

Source

pub fn root(&self) -> usize

Source

pub fn is_root(&self, n: usize) -> bool

Source

pub fn nodes(&self) -> impl Iterator<Item = usize>

Source

pub fn leaves(&self) -> impl Iterator<Item = usize>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn nodes_mut(&mut self) -> impl Iterator<Item = &mut Node<P, E>>

Source

pub fn add_node(&mut self, parent: Option<usize>, data: P) -> usize

Source

pub fn plug(&mut self, target: usize, n: usize)

Source

pub fn unplug(&mut self, n: usize)

Source

pub fn delete_node(&mut self, n: usize) -> Option<()>

Source

pub fn delete_nodes(&mut self, ns: &[usize]) -> Option<()>

Source

pub fn move_node(&mut self, n: usize, dest: usize)

Source

pub fn print<NodeFormatter, S1, EdgeFormatter, S2>( &self, f: NodeFormatter, g: EdgeFormatter, )
where NodeFormatter: Fn(&P) -> S1, S1: Default + Display, EdgeFormatter: Fn(&E) -> S2, S2: Default + Display,

Source

pub fn parent(&self, n: usize) -> Option<usize>

Source

pub fn find_leaf<F>(&self, f: F) -> Option<usize>
where F: Fn(&P) -> bool,

Source

pub fn find_node<F>(&self, f: F) -> Option<usize>
where F: Fn(&P) -> bool,

Source

pub fn find_child<F>(&self, n: usize, f: F) -> Result<Option<usize>, Error>
where F: Fn(&P) -> bool,

Source

pub fn mrca( &self, nodes: impl IntoIterator<Item = usize>, ) -> Result<usize, Error>

Compute the Most Recent Common Ancestor of a set of nodes. If the set is empty, return the tree root.

Source

pub fn ascendance(&self, n: usize) -> Vec<usize>

Source

pub fn descendants(&self, n: usize) -> Vec<usize>

Source

pub fn leave_set_of( &self, n: usize, ) -> HashSet<usize, BuildHasherDefault<IdentityHasher<usize>>>

Source

pub fn leaves_of(&self, n: usize) -> Vec<usize>

Source

pub fn cache_descendants(&mut self)

Source

pub fn cache_descendants_of(&mut self, from: usize)

Source

pub fn cached_descendants(&self, n: usize) -> Option<&Vec<usize>>

Source

pub fn cache_leaves(&mut self)

Source

pub fn cached_leaves_of( &self, n: usize, ) -> &HashSet<usize, BuildHasherDefault<IdentityHasher<usize>>>

Source

pub fn cached_leaves_of_vec(&self, n: usize) -> Vec<usize>

Source

pub fn children(&self, n: usize) -> Result<&[usize], Error>

Source

pub fn siblings(&self, n: usize) -> Vec<usize>

Source

pub fn depth(&self) -> f32

Source

pub fn node_depth<Measure>(&self, n: usize, f: &Measure) -> f32
where Measure: Fn(&E) -> f32,

Source

pub fn node_topological_depth(&self, n: usize) -> Result<i64, Error>

Returns the topological depth of the

Source

pub fn topological_depth(&self) -> (usize, usize)

Source

pub fn for_each_leave<F>(&self, f: &mut F)
where F: FnMut(&Node<P, E>),

Source

pub fn for_each_leave_mut<F>(&mut self, f: &mut F)
where F: FnMut(&mut Node<P, E>),

Source

pub fn inners(&self) -> impl Iterator<Item = usize>

Source

pub fn prune_by<U>(&mut self, is_useless: &U)
where U: Fn(&Node<P, E>) -> bool,

Source

pub fn prune(&mut self, is_empty: impl Fn(&P) -> bool)

Source

pub fn sort_by<K>(&mut self, k: impl Fn(&P) -> K)
where K: Debug + Ord + Clone,

Source

pub fn sort_leaves_by<K>(&mut self, k: impl Fn(&P) -> K)
where K: Debug + Ord + Clone,

Source§

impl<'a, P, D, E> Tree<P, D, E>
where P: Ord,

Source

pub fn sort(&'a mut self)

Source

pub fn sort_leaves(&'a mut self)

Trait Implementations§

Source§

impl<P, D, E> Default for Tree<P, D, E>
where D: Default,

Source§

fn default() -> Tree<P, D, E>

Returns the “default value” for a type. Read more
Source§

impl<P, D, E> Index<usize> for Tree<P, D, E>

Source§

type Output = Node<P, E>

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &<Tree<P, D, E> as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<P, D, E> IndexMut<usize> for Tree<P, D, E>

Source§

fn index_mut( &mut self, i: usize, ) -> &mut <Tree<P, D, E> as Index<usize>>::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<Payload, MetaData, Edge> Freeze for Tree<Payload, MetaData, Edge>
where MetaData: Freeze,

§

impl<Payload, MetaData, Edge> RefUnwindSafe for Tree<Payload, MetaData, Edge>
where MetaData: RefUnwindSafe, Payload: RefUnwindSafe, Edge: RefUnwindSafe,

§

impl<Payload, MetaData, Edge> Send for Tree<Payload, MetaData, Edge>
where MetaData: Send, Payload: Send, Edge: Send,

§

impl<Payload, MetaData, Edge> Sync for Tree<Payload, MetaData, Edge>
where MetaData: Sync, Payload: Sync, Edge: Sync,

§

impl<Payload, MetaData, Edge> Unpin for Tree<Payload, MetaData, Edge>
where MetaData: Unpin, Payload: Unpin, Edge: Unpin,

§

impl<Payload, MetaData, Edge> UnwindSafe for Tree<Payload, MetaData, Edge>
where MetaData: UnwindSafe, Payload: UnwindSafe, Edge: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.