finds edges from all paths using a DFS