mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
Update the book based on the revised second edition (#1014)
* Revised the book * Update the book with the second revised edition * Revise base on the manuscript of the first edition
This commit is contained in:
@ -14,7 +14,7 @@ from graph_adjacency_list import GraphAdjList
|
||||
|
||||
|
||||
def graph_bfs(graph: GraphAdjList, start_vet: Vertex) -> list[Vertex]:
|
||||
"""广度优先遍历 BFS"""
|
||||
"""广度优先遍历"""
|
||||
# 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
|
||||
# 顶点遍历序列
|
||||
res = []
|
||||
@ -58,7 +58,7 @@ if __name__ == "__main__":
|
||||
print("\n初始化后,图为")
|
||||
graph.print()
|
||||
|
||||
# 广度优先遍历 BFS
|
||||
# 广度优先遍历
|
||||
res = graph_bfs(graph, v[0])
|
||||
print("\n广度优先遍历(BFS)顶点序列为")
|
||||
print(vets_to_vals(res))
|
||||
|
||||
Reference in New Issue
Block a user