图 DFS 深度优先遍历动画

DFS + Code Flow
速度 1.0x
未访问 递归栈中 当前访问 已完成
访问顺序:空
选择起点,然后点击“开始 DFS”。
代码执行流
1 function DFS(node) {
2 if (visited.has(node)) return;
3 visited.add(node);
4 visit(node);
5 for (const next of graph[node]) {
6 if (!visited.has(next)) {
7 DFS(next);
8 }
9 }
10 return;
11 }
DFS 递归栈
递归栈为空
执行日志