Depth-First Search (DFS) Depth-First Search (DFS) Interactive Tool Model your graph with an adjacency list, pick a start node, and see the DFS visit order, timestamps, and edge classification. Ideal for studying algorithms, preparing technical interviews, or debugging graph code. 1. Graph input Format: one node per line, use colon then space-separated neighbors. Example: A: B C B: D C: D E D: F E: F: A: B C B: D C: D E D: F E: F: Start node Directed graph Run DFS Clear 2. DFS results Visit order — Node Discovery time (d) Finish time (f) Parent Run DFS to populate Edge classification (directed) We classify edges as tree, back, forward, or cross (for directed graphs). For undirected graphs, non-tree edges are typically back edges. — How DFS works Depth-first search explores a graph “deeply”: from the current node, it visits one unvisited neighbor, then one of its neighbors, and so on, backtracking when no unvisited neighbors remain. This tool follows the classic CLRS-style DFS with discovery and finish timestamps. DFS(G): for each vertex u in G.V: color[u] = WHITE, parent[u] = NIL time = 0 for each vertex u in G.V: if color[u] == WHITE: DFS-Visit(u) DFS is fundamental in algorithms for: Topological sort (on DAGs) Detecting cycles Finding connected components Classifying edges (tree, back, forward, cross) Time complexity With an adjacency list, DFS runs in O(V + E) , which is optimal for a full traversal. Directed vs undirected In directed graphs, edge classification is meaningful (tree/back/forward/cross). In undirected graphs, every non-tree edge is effectively a back edge to an ancestor. Related graph tools Adjacency List Builder Graphing & Visualization Bayesian Network Tips Keep node labels simple (A, B, C or 1, 2, 3). Our parser ignores blank lines and trims spaces. If the start node is missing, DFS will still run on all nodes in alphabetical order.
Calculators in Depth-First Search (DFS) Depth-First Search (DFS) Interactive Tool Model your graph with an adjacency list, pick a start node, and see the DFS visit order, timestamps, and edge classification. Ideal for studying algorithms, preparing technical interviews, or debugging graph code. 1. Graph input Format: one node per line, use colon then space-separated neighbors. Example: A: B C B: D C: D E D: F E: F: A: B C B: D C: D E D: F E: F: Start node Directed graph Run DFS Clear 2. DFS results Visit order — Node Discovery time (d) Finish time (f) Parent Run DFS to populate Edge classification (directed) We classify edges as tree, back, forward, or cross (for directed graphs). For undirected graphs, non-tree edges are typically back edges. — How DFS works Depth-first search explores a graph “deeply”: from the current node, it visits one unvisited neighbor, then one of its neighbors, and so on, backtracking when no unvisited neighbors remain. This tool follows the classic CLRS-style DFS with discovery and finish timestamps. DFS(G): for each vertex u in G.V: color[u] = WHITE, parent[u] = NIL time = 0 for each vertex u in G.V: if color[u] == WHITE: DFS-Visit(u) DFS is fundamental in algorithms for: Topological sort (on DAGs) Detecting cycles Finding connected components Classifying edges (tree, back, forward, cross) Time complexity With an adjacency list, DFS runs in O(V + E) , which is optimal for a full traversal. Directed vs undirected In directed graphs, edge classification is meaningful (tree/back/forward/cross). In undirected graphs, every non-tree edge is effectively a back edge to an ancestor. Related graph tools Adjacency List Builder Graphing & Visualization Bayesian Network Tips Keep node labels simple (A, B, C or 1, 2, 3). Our parser ignores blank lines and trims spaces. If the start node is missing, DFS will still run on all nodes in alphabetical order..