igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph graphml weights


From: Tamas Nepusz
Subject: Re: [igraph] igraph graphml weights
Date: Fri, 12 Dec 2008 17:11:53 +0000

> 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






reply via email to

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