On 10/11/2013 11:02 AM, Tasos Varoudis wrote:
> Hi all,
>
> How can I use a vertex property for search cutoff on graphs that are weighted 
> based on an edge property?
> I want the search to visit the vertex based on the edge weights but the 
> cutoff to be based on a vertex property.

I assume you are referring to Dijkstra's algorithm. If you want to abort
the search at any given point, you have to raise an exception from the
graph visitor. For example:

      class VisitorExample(gt.DijkstraVisitor):
          def __init__(self, prop):
              self.prop = prop

          def discover_vertex(self, u):
              if self.prop[u] > 10:
                  raise gt.StopSearch()


      dist, pred = gt.dijkstra_search(g, g.vertex(0), weight, 
VisitorExample(prop))


I hope this helps.

Cheers,
Tiago

-- 
Tiago de Paula Peixoto <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to