Function cnetworks::bfs [−][src]
pub fn bfs(
net: &Network,
root: usize,
target: usize
) -> Result<Option<HashSet<usize>>, String>
Perform a breadth-first search over the network, starting with root and looking for target.
Return a HashSet of all nodes discovered in the process or None
if the path is not found.
Returns Err
if the root or target nodes do not exist. Panics if the network is corrupted or
when the queue operations fail.
Examples
let net = Network::new(100, NetworkModel::ER { p: 0.05, whole: false }); println!("{:?}\n", net); match bfs(&net, 1, 3) { Some(n) => println!("Found 3 after discovering {:?}", n), None => println!("No path to 3 found!"), }