正在加载图片...
Algorithm 9. 4 BFS ut: a directed or undirected graph G=(V, E) Output: Numbering of the vertices in breadth-first search order 1.bn←0 for each vertexvE V 3. mark v unvisited en 5. for each vertexvE V 6. if v is marked unvisited then bfs() 1. end for Procedure bfs(v) Q+(vI 12345 ark y visited heQ≠ v←Pop(Q) tin←hfn+1 6. for each edge(,w)∈E 7. if w is marked unvisited then 89 Push(w, Q) ck w visited 10. end if en 12. end while 2/32021 Xiaojuan Cai2/3/2021 Xiaojuan Cai 26
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有