You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document that Bfs.stack stores node in the order reverse to adding them and does not add the start node to the stack, as revealed during debugging of the following code:
use std::iter::once;// TODO: Somebody, adopt this code (and DFS) to `petgraph`.use petgraph::{data::DataMap, visit::{Bfs,IntoNeighbors,VisitMap}};pubstructBfsFiltered<NodeId,VM>{base:Bfs<NodeId,VM>,// node_filter: P,}impl<NodeId,VM>BfsFiltered<NodeId,VM>{pubfnnew(base:Bfs<NodeId,VM>) -> Self{Self{
base
}}pubfntraverse<G,P,C,NodeWeight>(&mutself,graph:G,mutpredicate:P,mutcall:C)whereC:FnMut(&NodeId,&NodeId) -> (),G:IntoNeighbors<NodeId = NodeId> + DataMap<NodeWeight = NodeWeight>,P:FnMut(&NodeId) -> bool,NodeId:Copy + Eq,VM:VisitMap<NodeId>,{ifletSome(first_id) = self.base.next(graph){whileletSome(source_child_id) = &self.base.next(graph){if(&mut predicate)(source_child_id){// TODO: Create a `petgraph` issue asking to explain the next line of code workings.let source_parent_id = self.base.stack.iter().map(|e| *e).chain(once(first_id)).find(&mut predicate);ifletSome(source_parent_id) = &source_parent_id {(&mut call)(source_parent_id,&source_child_id);}}}}}}
Also document the similar Dfs behavior.
The text was updated successfully, but these errors were encountered:
Document that
Bfs.stack
stores node in the order reverse to adding them and does not add the start node to the stack, as revealed during debugging of the following code:Also document the similar
Dfs
behavior.The text was updated successfully, but these errors were encountered: