pub struct DepthFirstOrder { /* private fields */ }Expand description
用法
use algorithms_fourth::digraph::Digraph;
use algorithms_fourth::digraph::depth_first_order::DepthFirstOrder;
let mut g = Digraph::new(4);
g.add_edge(0, 1);
g.add_edge(2, 3);
let dfo = DepthFirstOrder::new(&g);
assert_eq!(dfo.post(),vec![1,0,3,2]);
assert_eq!(dfo.pre(),vec![0,1,2,3]);
assert_eq!(dfo.reverse_post(),vec![1,0,3,2]);Implementations§
source§impl DepthFirstOrder
impl DepthFirstOrder
pub fn new(g: &Digraph) -> Self
sourcepub fn reverse_post(&self) -> Vec<usize>
pub fn reverse_post(&self) -> Vec<usize>
所有顶点的逆后序排列
使用
use algorithms_fourth::digraph::Digraph;
use algorithms_fourth::digraph::depth_first_order::DepthFirstOrder;
let mut g = Digraph::new(4);
g.add_edge(0, 1);
g.add_edge(2, 3);
let dfo = DepthFirstOrder::new(&g);
assert_eq!(dfo.reverse_post(),vec![1,0,3,2]);
let mut points = dfo.reverse_post();
while let Some(s) = points.pop() {
println!("{}",s);
}Auto Trait Implementations§
impl RefUnwindSafe for DepthFirstOrder
impl Send for DepthFirstOrder
impl Sync for DepthFirstOrder
impl Unpin for DepthFirstOrder
impl UnwindSafe for DepthFirstOrder
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