how to end the BFS traversal at will( RGL)


I am using RGL for some of the graph implementations. My requirements is such that I need to find out all nodes that are at distance less than 3.

For this, I thought of traversing the graph using BFS and stop the traversal when i reach 4th level. But how do I do this?

regards, Sandeep G