Graph/dfs library
🧠Depth-First Search (DFS)
Traverses an (unweighted) graph by exploring as far as possible along each
branch before backtracking. Returns the visitation order starting at start.
- Recursive implementation
- Time complexity: O(V + E)
- Space complexity: O(V) due to recursion stack and visited set
Example:
final graph = {
'A': ['B', 'C'],
'B': ['D', 'E'],
'C': ['F'],
'D': [], 'E': ['F'], 'F': []
};
final order = dfs(graph, 'A');
// order: ['A', 'B', 'D', 'E', 'F', 'C']