Struct graaf::algo::breadth_first_tree::BreadthFirstTree
source · pub struct BreadthFirstTree { /* private fields */ }Expand description
A breadth-first tree.
Implementations§
source§impl BreadthFirstTree
impl BreadthFirstTree
sourcepub fn search(&self, s: usize, t: usize) -> Option<Vec<usize>>
pub fn search(&self, s: usize, t: usize) -> Option<Vec<usize>>
Searches a breadth-first tree for a path from a source vertex to a target vertex.
§Arguments
s: The source vertex of the path.t: The target vertex of the path.
§Returns
If a path from s to t is found, the function returns it. Otherwise,
returns None.
§Examples
use graaf::algo::breadth_first_tree::BreadthFirstTree;
let pred = BreadthFirstTree::from(vec![Some(1), Some(2), Some(3), None]);
assert!(pred.search(0, 3).into_iter().eq(Some(vec![0, 1, 2, 3])));sourcepub fn search_by<F>(&self, s: usize, is_target: F) -> Option<Vec<usize>>
pub fn search_by<F>(&self, s: usize, is_target: F) -> Option<Vec<usize>>
Searches a breadth-first tree for a path from a source vertex to a target vertex that satisfies a predicate.
§Arguments
s: The source vertex of the path.is_target: A predicate determining whether a vertex is the target.
§Returns
If it finds a target, it returns the path from the source to the target.
Otherwise, it returns None.
§Panics
Panics if s is not in the path.
§Examples
use graaf::algo::breadth_first_tree::BreadthFirstTree;
let pred = BreadthFirstTree::from(vec![Some(1), Some(2), Some(3), None]);
assert!(pred
.search_by(0, |&v, _| v > 1)
.into_iter()
.eq(Some(vec![0, 1, 2])));use graaf::algo::breadth_first_tree::BreadthFirstTree;
let pred = BreadthFirstTree::from(vec![Some(1), Some(2), Some(3), None, Some(0)]);
assert!(pred
.search_by(0, |_, v| v.is_none())
.into_iter()
.eq(Some(vec![0, 1, 2, 3])));Trait Implementations§
source§impl Clone for BreadthFirstTree
impl Clone for BreadthFirstTree
source§fn clone(&self) -> BreadthFirstTree
fn clone(&self) -> BreadthFirstTree
Returns a copy 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 BreadthFirstTree
impl Debug for BreadthFirstTree
source§impl Hash for BreadthFirstTree
impl Hash for BreadthFirstTree
source§impl Index<usize> for BreadthFirstTree
impl Index<usize> for BreadthFirstTree
source§impl IndexMut<usize> for BreadthFirstTree
impl IndexMut<usize> for BreadthFirstTree
source§impl IntoIterator for BreadthFirstTree
impl IntoIterator for BreadthFirstTree
source§impl Ord for BreadthFirstTree
impl Ord for BreadthFirstTree
source§fn cmp(&self, other: &BreadthFirstTree) -> Ordering
fn cmp(&self, other: &BreadthFirstTree) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for BreadthFirstTree
impl PartialEq for BreadthFirstTree
source§fn eq(&self, other: &BreadthFirstTree) -> bool
fn eq(&self, other: &BreadthFirstTree) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl PartialOrd for BreadthFirstTree
impl PartialOrd for BreadthFirstTree
source§fn partial_cmp(&self, other: &BreadthFirstTree) -> Option<Ordering>
fn partial_cmp(&self, other: &BreadthFirstTree) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for BreadthFirstTree
impl StructuralPartialEq for BreadthFirstTree
Auto Trait Implementations§
impl Freeze for BreadthFirstTree
impl RefUnwindSafe for BreadthFirstTree
impl Send for BreadthFirstTree
impl Sync for BreadthFirstTree
impl Unpin for BreadthFirstTree
impl UnwindSafe for BreadthFirstTree
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)