Find longest path by number of edges, excluding cycles
The problem you are defining is called Longest Path (and occasionally Longest $s$-$t$-Path) and is NP-complete.

That is, there is an algorithm for solving it, but you shouldn't keep you hopes up when it comes to the running time of the algorithm: it's unlikely to run in polynomial time.

The trivial algorithm is to check for every permutation of the graph, in time $O(d! \cdot 2^{dn})$, but this becomes intractable extremely quickly.  It is possible to bring this down to $O(2^n \cdot \text{poly}(n))$.

You have three options as far as I can see it:


limit the length of the path you need to some reasonable integer $k$ and solve with FPT techniques
use an approximation algorithm
limit the type of input graph to certain smaller and easier graph classes.


Note 1: As Yuval Filmus points out, the problem Longest Path is usually referring to the undirected version.  However, the problem remains NP-complete also in its directed version by a reduction from Directed Hamiltonian Path (Between Two Vertices) (Garey &amp; Johnson, 1979).

Note 2: Yuval Filmus also pointed out that it is solvable in single-exponential time.

Note 3: The problem is solvable in linear time on DAGs, and if you allow repeating edges, the answer is always infinite when your graph has a cycle.