Graph Traversal
As for Trees,
we can traverse a Graph by using DFS or BFS.
The complexity of the two algorithms is for both time and space, where:
In fact, we need time to build the Adjacency List and
time to push and pop elements to and from the stack, respectively.
Regarding the space,
we need to store edges in the dictionary and Vertices/Nodes in the set.