This commit is contained in:
krahets
2023-07-19 01:45:14 +08:00
parent 03cbf5b972
commit c68f18e480
8 changed files with 10 additions and 10 deletions

View File

@ -23,9 +23,9 @@ def dfs(graph: GraphAdjList, visited: set[Vertex], res: list[Vertex], vet: Verte
dfs(graph, visited, res, adjVet)
# 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
def graph_dfs(graph: GraphAdjList, start_vet: Vertex) -> list[Vertex]:
"""深度优先遍历 DFS"""
# 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
# 顶点遍历序列
res = []
# 哈希表,用于记录已被访问过的顶点