wting / python-graph

Automatically exported from code.google.com/p/python-graph
Other
5 stars 4 forks source link

Limiting breath first search to a radius #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a gigantic graph and I'd like to look at smaller sub-graphs by limiting 
a 
breadth first search to a certain radius. I noticed the radius search filter, 
but 
the documentation was a bit unclear as to how to use this filter. Is the radius 
filter used to limit a search to a certain radius? If so, how is it used? If 
not, is 
there another way to accomplish what I'm looking to do?

Original issue reported on code.google.com by john.p...@gmail.com on 13 Feb 2010 at 5:33

GoogleCodeExporter commented 9 years ago
Sorry for the lack of documentation. We hope to be able to fix this sometime.

The radius filter can indeed be used to limit the search radius of DFS and BFS 
(in
terms of edge weight). Something like this (plus the relevant imports) should 
do the
trick:

breadth_first_search(gr, root=0, filter=radius(30))

Replace 30 with your desired maximum distance, of course. And gr and root as 
necessary.

I'm marking this issue as Invalid as it's not really an issue after all. Despite
that, feel free to add any comments to this thread.

Original comment by pmatiello on 13 Feb 2010 at 7:45