This commit is contained in:
krahets
2025-03-28 18:08:27 +08:00
parent 5286e8bbc2
commit 38000b2e5e
2 changed files with 2 additions and 2 deletions
@@ -20,7 +20,7 @@ comments: true
BFS 通常藉助佇列來實現,程式碼如下所示。佇列具有“先入先出”的性質,這與 BFS 的“由近及遠”的思想異曲同工。
1. 將走訪起始頂點 `startVet` 加入列,並開啟迴圈。
1. 將走訪起始頂點 `startVet` 加入列,並開啟迴圈。
2. 在迴圈的每輪迭代中,彈出佇列首頂點並記錄訪問,然後將該頂點的所有鄰接頂點加入到佇列尾部。
3. 迴圈步驟 `2.` ,直到所有頂點被訪問完畢後結束。