If you know the nodes(n), then create adjancency list using the edge list. That is O(n). Then do DFS which is O(V+E).
Having the right data structure makes the difference.