this can be radically improved by using what I am working on.
Using the distance as the metric for filtering (if distance > 2, filter) is suboptimal, as it limits discover ability.
What's better is a filter based on personalized Pagerank ( if PP < threshold, filter). PP looks both at the distance and at the "flux", meaning how many path exists thay connects you to another npub.
So, PP can be:
- more flexible, because you can choose the threshold in a continuoum
- improves the discovery (by for example allowing npubs at 3 hops if they are "high quality")