Related data structure**:
AlgorithmData_StructureGraphDFS
Graph Depth-First Search is a traversal method that prioritise going as far as possible and then backtracks when no further paths are available.
Implementation
The “go as far as possible and return” algorithm paradigm is usually implemented based on recursion. Similar to Graph Breadth-First Search (BFS), in DFS, we also use a hash set visited
to record all visited vertices to avoid revisiting.
Time complexity
All vertices will be visited once, using time, all edges will be visited twice for undirected graph using ; with overall time complexity .
Back to parent node: ADT - Graph
Reference: