Qualcuno può suggerire un algoritmo di tempo lineare che prende in ingresso un diretto aciclico grafo e due vertici s e t e restituisce il numero di semplici percorsi da s a t in G .
Ho un algoritmo in cui eseguirò un DFS (Depth First Search) ma se DFS trova t allora non cambierà il colore (da bianco a grigio) di nessuno dei nodi che arriva nel percorso s ⇝ t$G=(V,E)$$s$$t$$s$$t$$G$

$t$$s\u21ddt$ so that if this is the subpath of any other path then also DFS goes through this subpath again.For example consider the adjacency list where we need to find the number of paths from $p$ to $v$.

Is my algorithm correct? if not, what modifications are needed to make it correct or any other approaches will be greatly appreciated.

**Note**:Here I have considered the DFS algorithm which is given in the book *"Introduction to algorithms by Cormen"* in which it colors the nodes according to its status.So if the node is unvisited , unexplored and explored then the color will be white,grey and black respectively.All other things are standard.

*all*paths in a directed acyclic graph are

*necessarily*simple (by virtue of acyclicity).