Given a DAG (directed acyclic graph), a start and end vertex, enumerate all path lengths between them. What is the fastest algorithm? The best I've seen is to use matrix multiplication which is O(n^e(logn)) where e is the exponent for matrix multiplication. Is there a O(n^2 logn) solution? n is number of vertices. BFS seem to take O(n^3) times on this problem.
Note this is different from counting the number of paths between the two vertices, which can be done in O(E) time with topological sort.
DAG path enumeration
Moderator: Board moderators
Re: DAG path enumeration
I think DFS(depth first search) is the best, if you use adjacent list.bugzpodder wrote:Given a DAG (directed acyclic graph), a start and end vertex, enumerate all path lengths between them. What is the fastest algorithm?
-
- Experienced poster
- Posts: 147
- Joined: Fri Jun 13, 2003 10:46 pm