Map nodes, edges, stacks, and recursive exploration clearly. Review traversal metrics with practical graph summaries. Turn complex search steps into readable results very fast.
| Example | Nodes | Edges | Start | Target | Order | Expected Traversal |
|---|---|---|---|---|---|---|
| Tree graph | A,B,C,D,E,F | A-B, A-C, B-D, B-E, C-F | A | E | Ascending | A → B → D → E → C → F |
| Directed cycle | 1,2,3,4 | 1->2, 2->3, 3->1, 3->4 | 1 | 4 | Input | 1 → 2 → 3 → 4 |
| Disconnected graph | P,Q,R,S,T | P-Q, Q-R, S-T | P | T | Ascending | P → Q → R → S → T |
Depth progression: depth(child) = depth(parent) + 1
Parent path reconstruction: Follow each node’s parent repeatedly until the start node is reached.
Traversal time complexity: T(V,E) = Θ(V + E), because DFS processes each vertex and edge once in an adjacency-list graph.
Auxiliary space complexity: S(V) = Θ(V), due to the visited map, parent map, recursion stack, and supporting arrays.
Cycle logic: A back edge to an active gray node signals a cycle in directed graphs. In undirected graphs, a gray neighbor that is not the parent also signals a cycle.
It runs depth first search on a graph and reports traversal order, discovery times, finish times, parents, node depths, cycle hints, components, and optional target paths.
Use one edge per line. Accepted styles include A-B, A B, A,B, and A->B. Node names should stay compact, using letters, numbers, or underscores.
Only the entered edge direction is followed. Connectivity is then reported as weak connectivity, because standard connectedness is defined differently for directed graphs.
Discovery time marks when DFS first visits a node. Finish time marks when all of that node’s reachable descendants have been fully processed.
DFS depends on neighbor ordering. Changing input, ascending, or descending order can produce different valid traversals while still using the same graph.
A DFS forest appears when the graph has multiple disconnected parts or when full traversal continues beyond the starting component. Each root starts a new tree.
Yes. Enable the stop option to halt further expansion after the target is reached. This is useful when you only need an early path result.
No. DFS explores deeply before backtracking. It can find a path, but it does not guarantee the shortest path in general graphs.
Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.