Hi,

What you want is achieved by the Python built-in filter() function:

   https://docs.python.org/3.8/library/functions.html#filter

Best,
Tiago

Am 30.10.19 um 14:45 schrieb Gerion Entrup:
> Hi,
> 
> I often have this pattern in Python:
> 
> ```
> for vertex in mygraph.vertices():
>     if not mygraph.vp.is_foo[vertex]:
>         continue
>     do_stuff_that_uses_all_vertices()
> ```
> 
> `is_foo` is a boolean property.
> 
> I know that there a vertex filters and GraphViews but in the loop body I
> need access to all vertices. Only the iterator should be filtered.
> 
> Is there a way to specify a vertex filter only in the vertices iterator?
> Something like:
> ```
> for vertex in mygraph.vertices(vfilt=mygraph.vp.is_foo):
>     do_stuff_that_uses_all_vertices()
> ```
> 
> Of course, this would be nice in all iterators (edges(), out_edges(),
> ...) ;).
> 
> 
> Best,
> Gerion
> 
> 
> _______________________________________________
> graph-tool mailing list
> [email protected]
> https://lists.skewed.de/mailman/listinfo/graph-tool
> 


-- 
Tiago de Paula Peixoto <[email protected]>
_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to