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@skewed.de>