igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph graphml weights


From: Chris Wj
Subject: Re: [igraph] igraph graphml weights
Date: Mon, 15 Dec 2008 15:53:46 -0500

When trying to load the exported graphml file with weights, Python crashes. The file was created using the function write_graphml

Sample code that wrote the file:
G = igraph.Graph(n=len(callers))
G.add_edges(edges)
G.es["weight"]=map(cvrtD,weights)
G.write_graphml("ow2-50-graphml.xml")

Afterwards this causes a crash:
G = igraph.Graph.Read_GraphML("ow2-50-graphml.xml")
and this after renaming the file to ow2-50.graphml:
G = igraph.load("ow2-50.graphml")

This is on Windows, not sure about *nix yet.

igraph version:
In [2]: igraph.__version__
Out[2]: '0.5.1'


On Fri, Dec 12, 2008 at 12:11 PM, Tamas Nepusz <address@hidden> wrote:
> Is there a way to include weights in the output to graphml?
Yes. Assign them to an edge attribute and save the graph.

> Also, does igraph import weights from graphml?
Yes, simple numeric and string attributes are imported.

E.g. (in ipython):

In [1]: g=Graph.GRG(100, 0.2)
In [2]: import random; g.es["weight"] = [random.random() for _ in g.es]
In [3]: g.es["weight"] = [random.random() for _ in g.es]
In [4]: g.save("test.graphml")
In [5]: g2 = load("test.graphml")
In [6]: print g2.es["weight"][0:10]
[0.99729599999999996, 0.013597700000000001, 0.14432700000000001,
0.098399899999999998, 0.30777599999999999, 0.215923,
0.29499399999999998, 0.74816700000000003, 0.435998, 0.40986600000000001]

--
Tamas




_______________________________________________
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]