DFS uses an hashset instead of hashmap to know visited nodes