Find all Paths of a bounded (Minimum and Maximum) length

For a mario party-esque movement system, I’m trying to find all nodes that can be reached starting from a seed node on a Point Graph with a path of exactly X number of nodes. I’m aware that BFS can achieve something similar, but I’d like to allow for the path to loop around on itself, i.e. if I have six nodes that form a circle, and want to find a path that takes six nodes, the original node will be found as a possible path. My first thought had been to use BFS to find all nodes within the maximum possible distance, and then reduce to those that can find a path of X length, but I’m unsure of what may be the best way to go about achieving that (or even if this is a good way to go about it).

As an example of a situation this would be used in:


The player is at Node 1, and has rolled a 5. Nodes 2, 5, and 8 would be possible moves that the player could make. (1->4->5->6->3->2), (1->2->3->6->5), and (1->2->3->6->7->8) for the possible paths. To my knowledge, a BFS that then removed every node that is less than 5 nodes away would only show Node 8 as a possible move.


This is not possible to solve with any built-in tools because everything in this package essentially uses the definition of a path as a sequence of unique and adjacent nodes. Instead you have to use a custom dynamic programming solution for this. It will work sort of like a BFS, but you allow it to visit previously visited nodes.