thumpkidd9
Programmer
Hello,
I want to find all the paths from 1 vertex to another in an acyclic directed graph. I feel as though this has to be done recursively but I cant figure out just how. I'm using an adjacency list not a matrix. So for example f you have a graph
A-B
A-C
B-C
C-D
Then all paths from A-D should be A-B-C-D and A-C-D
I can find one path with no problem using DFS, but somehow when I hit a dead end, I need to contruct another path, starting at source vertex. Any ideas?
I want to find all the paths from 1 vertex to another in an acyclic directed graph. I feel as though this has to be done recursively but I cant figure out just how. I'm using an adjacency list not a matrix. So for example f you have a graph
A-B
A-C
B-C
C-D
Then all paths from A-D should be A-B-C-D and A-C-D
I can find one path with no problem using DFS, but somehow when I hit a dead end, I need to contruct another path, starting at source vertex. Any ideas?