igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] dict attributes not saved in graphml files?


From: Tamás Nepusz
Subject: Re: [igraph] dict attributes not saved in graphml files?
Date: Fri, 20 Jul 2012 12:25:10 +0200

Hello, 

This is a side effect of trying to bring the behaviour of igraph's GraphML 
exporter closer to the GraphML specifications; more details are to be found in 
this bug report:

https://bugs.launchpad.net/igraph/+bug/918138

Until this bug is resolved, you have to explicitly call str() on your dict 
attributes before saving the graph into GraphML. Alternatively, if you are sure 
that you won't need the graph outside Python, you can simply save it in 
Python's pickled format, which will preserve every single attribute as is. 

All the best,-- 
T.


On Friday, 20 July 2012 at 12:20, Giovanni Marco Dall'Olio wrote:

> Hello,
> I have a problem when storing graphs as graphml files using the python igraph 
> library. 
> It seems that when I store a graph as a graphml file, all the attributes that 
> are based on python dictionaries are lost. 
> 
> Let's say I have a graph like the following:
> 
> >>> import igraph
> >>> g = igraph.Graph()
> >>> g['dict_attribute'] = {1:2, 3:4}
> >>> g['string_attribute'] = 'dsadsadas'
> 
> This graph has two attributes, one is a string and one is a dictionary. But 
> when I try to store it as a graphml file, the dict_attribute is lost:
> 
> >>> g.write_graphml('mygraph.graphml')
> >>> g_loaded = igraph.read('mygraph.graphml')
> >>> g_loaded.attributes()
> ['string_attribute']
> 
> What's happening? Why 'dict_attribute' is missing? It seems that the problem 
> is in the write_graphml function, because if I open the file mygraph.graphml, 
> dict_attribute is not there.
> In the 0.5.4 version, dictionary attributes were stored as strings, and I 
> could retrieve them using the ast.as_literal function.
> 
> I am using igraph 0.6 and the python library python-igraph-0.6, which is the 
> one that is installed automatically by easy_install.
> 
> Thank you very much in advance,
> Gio
> 
> 
> -- 
> Giovanni Dall'Olio, phd student
> IBE, Institut de Biologia Evolutiva, CEXS-UPF (Barcelona, Spain)
> 
> My blog on bioinformatics: http://bioinfoblog.it
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden (mailto:address@hidden)
> https://lists.nongnu.org/mailman/listinfo/igraph-help






reply via email to

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