pub fn iter_nodes<G, I: IntoIterator<Item: Borrow<NodeId>>>(
graph: &G,
start: I,
) -> NodeVisit<'_, G> ⓘwhere
G: SwhForwardGraph,
Expand description
Iterate on the nodes of the sub-graph rooted at start
, in BFS order.
start
is usually a single node id, passed as &[node]
, but can be a
non-singleton slice or iterator of nodes, to avoid independently re-visiting shared
sub-graphs from multiple starting points.
See NodeVisit documentation for performance considerations.
§Examples
let src = &[1, 2, 3];
for node in iter_nodes(graph, src) {
println!("Visiting: {}", node);
}
let src = 1..4;
for node in iter_nodes(graph, src) {
println!("Visiting: {}", node);
}