Hi,

> 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,
-- 
T.


_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to