breath first search algorithm
fn bfs(graph: &Graph, start: usize, end: usize) -> Option<usize> { let mut q = VecDeque::new(); let mut visited = vec![false; graph.len()]; q.push_back(start); visited[start] = true; while !q.is_empty() { let node = q.pop_front().unwrap(); if node == end { return Some(node); } for &neighbour in &graph[node] { if !visited[neighbour] { visited[neighbour] = true; q.push_back(neighbour); } } } None }