# How to find all paths of length up to k between two nodes in a directed graph?

Let’s say I have a directed graph represented as an adjacency matrix, and I’m given two nodes $$u,v$$ and a parameter $$k$$. Let’s also say that the maximal degree of a node in the graph is $$d$$.

What is the most efficient algorithm to find all paths of length $$<=k$$ from $$u$$ to $$v$$?

I know the number of such paths can be calculated efficiently using Dynamic Programming approach, but I’m looking for an algorithm that allows to get a set of actual paths.

It’s clear that such algorithm would have a factor of the number of paths in its time complexity, which has $$k$$ in the exponent, but still, I would like to know what is the best approach for such a problem.