more memory efficient graph representation + prat of dfs