mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-01 03:24:24 +08:00
@ -22,8 +22,7 @@ fn graph_bfs(graph: GraphAdjList, start_vet: Vertex) -> Vec<Vertex> {
|
||||
let mut que = VecDeque::new();
|
||||
que.push_back(start_vet);
|
||||
// 以顶点 vet 为起点,循环直至访问完所有顶点
|
||||
while !que.is_empty() {
|
||||
let vet = que.pop_front().unwrap(); // 队首顶点出队
|
||||
while let Some(vet) = que.pop_front() {
|
||||
res.push(vet); // 记录访问顶点
|
||||
|
||||
// 遍历该顶点的所有邻接顶点
|
||||
|
||||
Reference in New Issue
Block a user