Given a directed graph, count the total number of paths of ANY length Given a directed graph, how to count the total number of paths of ANY possible length in it?
I was able to compute the answer using the adjacency matrix $A$, in which the number of paths of the length $n$ is the sum of elements $A^n$. But I have to calculate all $A^n$ for all possible $n$.
So is there any easier way, without computing large sparse matrix multiplication?
Sample graph:


Is it specifically a DAG? If so, process nodes in topological order, keeping count of how many different paths end at each node.
