2013/1/11 Va Sa <[email protected]>

> Greetings,
>
> Is it possible to somehow enter a list of vertices to be removed all at
> once?
>
> My naive approach
>
> for v in g.vertices():
>   if v.in_degree() == 0 and v.out_degree()==0:
>     g.remove_vertex(v)
>
> is taking a while to run on a 3M Vertices graph, i.e.  ~9 trillion memory
> shifts..
>
> If one could avoid the memory shifting after each removal, the complexity
> would go down to just O(g.num_vertices)
>
> Sincerely,
>   Val
>
>
Instead of iterating, you could use a filter on the vertices, by using a
GraphView (and maybe building a graph from the view using the prune
parameter) like that

gv = gt.GraphView(g,vfilt=lambda x: x.in_degree()>0 or x.out_degree()>0)
g2 = gt.Graph(gv,prune=True)

However I don't know if with this approach the complexity would go down.

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

Reply via email to