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 > [email protected] (mailto:[email protected]) > https://lists.nongnu.org/mailman/listinfo/igraph-help _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
