[Top][All Lists]

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

[igraph] dict attributes not saved in graphml files?

From: Giovanni Marco Dall'Olio
Subject: [igraph] dict attributes not saved in graphml files?
Date: Fri, 20 Jul 2012 12:20:37 +0200

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()

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,

Giovanni Dall'Olio, phd student
IBE, Institut de Biologia Evolutiva, CEXS-UPF (Barcelona, Spain)

My blog on bioinformatics: http://bioinfoblog.it

reply via email to

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