# Find if *any* path exists between vertices in a directed acyclic graph

Given a directed acyclic (and unweighted) graph and two distinct vertices S and T, is there an algorithm that will tell me if there is any path (not necessarily the shortest one) between the two? If it helps, I don't need the list of vertices on this path, just the fact that path exists.

I sure know of all the graph shortest-path algorithms (Dijsktra/Bellman-Ford/topological sorting/etc.), but I don't actually need the shortest one. Is there a speedy method of finding any arbitrary path in a DAG between two nodes? Pretty sure there is aplenty of specialized algorithms for that, just not sure where to search for.

• Use BFS or DFS. – Yuval Filmus Mar 23 '18 at 8:00

Think of it that way: If given a DAG and two vertices $s,t$ (with no other information) you can't get any better than linear time.