On 10/14/2013 10:49 AM, Tasos wrote:
Hi and thanks,
The difference between the solution below and that I need is that in order to compute the "cutoff prop" you need to follow the path that the visitor took and if the sum of the prop of the vertices that the visitor past is >X stop.
How would you do that?
If you notice in the documentation, you'll see that the visitor object can specify all sorts of event points callbacks, which you can use to gather information during the run of the algorithm. The point where we distance of a vertex has been computed is the "examine_vertex" event point. Hence: class VisitorExample(gt.DijkstraVisitor): def __init__(self, dist, thresh): self.dist = dist self.thresh = thresh def examine_vertex(self, u): if self.dist[u] > self.thresh: raise gt.StopSearch() dist = g.new_vertex_property("double") visitor = VisitorExample(dist, 10) # don't forget to pass the same 'dist' property to the search # function as well dist, pred = gt.dijkstra_search(g, g.vertex(0), weight, visitor, dist_map=dist) Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>