Fixed deallocation error by changing dfs() to accept the Graph by reference.