logo
  • 教程列表
  • SO官方文檔
  • 圖遍歷
    • 深度優先搜尋
    • 廣度優先搜尋
  1. StackOverflow 文件
  2. data-structures 教程
  3. 圖遍歷
  4. 廣度優先搜尋

廣度優先搜尋

Created: November-22, 2018

演算法 BFS(G)

輸入圖 G

**** G 的頂點邊緣和分割槽的輸出標記 ****

    for all u ∈ G.vertices()
        setLabel(u, UNEXPLORED)
    for all e ∈ G.edges()
    setLabel
    (e, UNEXPLORED)
    for all v ∈ G.vertices()
        if getLabel(v) = UNEXPLORED
            BFS(G, v)

https://i.stack.imgur.com/enrF5.jpg

https://i.stack.imgur.com/er6az.jpg

https://i.stack.imgur.com/VBk5F.jpg

  • 深度優先搜尋

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明