[Top][All Lists]

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

Re: [igraph] reading gml files converts an int attribute into float

From: Tamás Nepusz
Subject: Re: [igraph] reading gml files converts an int attribute into float
Date: Thu, 11 Jul 2013 22:20:52 +0200


> I generate a gml file with nodes having an integer attribute. But when I read 
> it back using igraph.read, the attribute values are floats.
There are two issues here:

1. The GML format has no way of recording what the type of a vertex or edge 
attribute should be, so it is the safest to assume that numeric vertex 
attributes are floats (or, more precisely, doubles).

2. Internally, igraph uses three attribute types: numeric, string or object. 
Numeric attributes are stored as doubles; string attributes are stored as 
strings; object attributes are stored in the native object type of the host 
language of igraph.

So, basically, the behaviour you see is partly a limitation of the GML format 
and partly a limitation of igraph. The only thing you can do is to convert the 
attribute manually to an int after loading your graph; something like this:

g.vs["foo"] = [int(x) for x in g.vs["foo"]]

All the best,

reply via email to

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