[graph-tool] Speeding up graph copy?

Zouhair zoohair at gmail.com
Wed Jan 22 17:32:11 CET 2020


Sorry I wasn't clear: I was calling add_vertex and remove_vertex with
arguments

On Wed, Jan 22, 2020, 07:11 Tiago de Paula Peixoto <tiago at skewed.de> wrote:

> Am 22.01.20 um 06:54 schrieb Zouhair:
> >
> >     How are you doing steps 3.a and 3.e exactly?
> >
> >     Are you calling g.add_vertex() and g.remove_vertex() repeatedly?
> >
> >
> > Yes I am. I assumed that's not the best thing but compared to copying
> > the graph, adding then removing the vertices was performing better.
>
> The point here is that this is sub-optimal and can be avoided. Both the
> g.add_vertex() and g.remove_vertex() functions should not be called
> repeatedly. Graph.add_vertex() can be called with an optional argument
> specifying the number of vertices to be added, which happens much faster
> than calling it multiple times. Likewise, Graph.remove_vertex() can be
> called with a list of vertices that need to be removed, which is
> performed in a much more efficient way, specially if the vertices
> removed happen to be the ones with the largest indexes.
>
> --
> Tiago de Paula Peixoto <tiago at skewed.de>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20200122/5c8c5e6e/attachment.htm>


More information about the graph-tool mailing list