Function cnetworks::bfs::path

source · []
pub fn path(net: &Network, root: usize, target: usize) -> Result<Path>
Expand description

Perform a breadth-first search over the network, starting with root and looking for target. Returns the Path from target to root.

Returns cn::Err::NoSuchNode if the root or target nodes do not exist.

Examples

let net = Network::new(100, Model::ER { p: 0.05, whole: false }, Weight::default());
match bfs::path(&net, 1, 3)?.as_vec() {
    Some(p) =>  {
        println!("Path from 3 to 1:");
        println!("{:?}", p);
    },
    None => println!("No path from 1 to 3 was found!"),
}