feat: Add glossary and description for "哈希集合" (#1310)

This commit is contained in:
Yudong Jin
2024-04-28 22:00:25 +08:00
committed by GitHub
parent a88c7b9862
commit cfc273783b
28 changed files with 36 additions and 31 deletions

View File

@@ -12,7 +12,7 @@ import { Vertex } from '../modules/Vertex';
function graphBFS(graph: GraphAdjList, startVet: Vertex): Vertex[] {
// 顶点遍历序列
const res: Vertex[] = [];
// 哈希,用于记录已被访问过的顶点
// 哈希集合,用于记录已被访问过的顶点
const visited: Set<Vertex> = new Set();
visited.add(startVet);
// 队列用于实现 BFS

View File

@@ -31,7 +31,7 @@ function dfs(
function graphDFS(graph: GraphAdjList, startVet: Vertex): Vertex[] {
// 顶点遍历序列
const res: Vertex[] = [];
// 哈希,用于记录已被访问过的顶点
// 哈希集合,用于记录已被访问过的顶点
const visited: Set<Vertex> = new Set();
dfs(graph, visited, res, startVet);
return res;