图的遍历
function dfs(graph, visited, res, vet) {
res.push(vet);
visited.add(vet);
const adjVets = graph.adjList.get(vet);
for (const adjVet of adjVets) {
if (visited.has(adjVet)) {
continue;
}
dfs(graph, visited, res, adjVet);
}
}
function graphDFS(graph, startVet) {
const res = [];
const vis = new Set();
dfs(graph, vis, res, startVet);
return res;
}