Graph DFS - Visit Order
Description
Given an adjacency-list graph and a start node, return the order in
which nodes are visited by depth-first search starting from `start`.
Visit neighbors in the order they appear in graph[node]. Skip already-
visited nodes. Only nodes reachable from `start` should appear.
Example:
graph = {0: [1, 2], 1: [0, 3, 4], 2: [0], 3: [1], 4: [1]}
start = 0
DFS order: [0, 1, 3, 4, 2] Constraints
- Nodes are integers - Graph may contain cycles - Graph may be disconnected (only return the component reachable from start) - 0 <= number of nodes <= 1000
solution.py
output
Run the cases to see results here.