igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] write to file problem


From: Tamas Nepusz
Subject: Re: [igraph] write to file problem
Date: Thu, 20 Jan 2011 15:53:32 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7

Your code should work; actually, it works fine for me on Linux. Which OS
are you using?

Just one comment, though: the time required by add_edges() is almost the
same for one edge as for many edges, so I'd probably generate a list of
edges to be added and then pass that list to add_edges() at once:

g.add_edges([(v.index, ...) for v in random.sample(...)])

-- 
T.

On 01/20/2011 03:49 PM, Simone Gabbriellini wrote:
> Hello list,
>
> I am trying to write to file a graph that I have just generated with:
>
> # build graph
> g = igraph.Graph(top+bottom, directed = False)
> # add attributes
> g.vs["type"] = [int(i >= top) for i in xrange(top+bottom)]
> g.vs["name"] = [v.index for v in g.vs]
> # add some random edges between top and bottom nodes
> [g.add_edges((v.index, random.choice(g.vs(type=1)).index)) for v in
> random.sample(g.vs(type=0), bottom)]
> # write file
> g.write_graphml('test.graphml')
>
> but nothing happens... is there something I am missing in the writing method?
>
> Best regards,
> Simone
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]