[graph-tool] Fast initialization of graph

Jonas Arnfred jonas at ifany.org
Tue Mar 19 14:35:54 CET 2013


Thanks a lot, I'll try it out!


On 19 March 2013 18:51, Tiago de Paula Peixoto <tiago at skewed.de> wrote:

> Hi,
>
> On 03/19/2013 09:39 AM, arnfred wrote:
> > I'm currently trying to instantiate a fully connected graph with some 600
> > vertices, but I find that adding all the edges usually takes around 10
> > seconds on my system. The fastest way of doing it that I have come up
> with
> > so far is to write:
> >
> > from itertools import combinations
> > edges = [g.add_edge(v1,v2) for (v1,v2) in combinations(g.vertices(),2)]
> >
> > But I'm wondering if there is a faster method?
>
> You can create a "random" graph with all degrees equal to N - 1:
>
>     g = random_graph(600, lambda: 600 - 1, directed=False, random=False)
>
> This should be much faster. Note the option 'random=False' which avoids
> the random placement of the edges, which would be completely pointless
> in this case.
>
> I'm planning to include a complete graph generator, as well as some
> other simple generators, which would make this more straightforward.
>
> Cheers,
> Tiago
>
> --
> Tiago de Paula Peixoto <tiago at skewed.de>
>
>
> _______________________________________________
> graph-tool mailing list
> graph-tool at skewed.de
> http://lists.skewed.de/mailman/listinfo/graph-tool
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20130319/ee31f459/attachment.htm>


More information about the graph-tool mailing list