Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_graphml rounds float values to 4 decimal digits #45

Closed
rajanski opened this issue Oct 22, 2015 · 10 comments
Closed

write_graphml rounds float values to 4 decimal digits #45

rajanski opened this issue Oct 22, 2015 · 10 comments
Assignees

Comments

@rajanski
Copy link

node in gml_file:

node
[
id 822
lat 52.5857663
lon 13.4500575
label "278215038"
]

same node in graphml_file (written after being read in though read_GML)

52.5858 13.4501 822 None 278215038
@rajanski rajanski changed the title read_GML or write_graphml rounds float values to 4 decimal digits write_graphml rounds float values to 4 decimal digits Oct 22, 2015
@rajanski
Copy link
Author

tried write_dot, this doesnt round the values..

@ntamas
Copy link
Member

ntamas commented Oct 22, 2015

Cannot reproduce on my machne; tried with the following test program:

#!/usr/bin/env python

from igraph import Graph, load

g = Graph(1)
g.vs["lat"] = 52.5857663
g.vs["lon"] = 13.4500575
g.write_gml("test.gml")
g2=load("test.gml")
g2.write_graphml("test.graphml")

It works just fine for me. The GraphML writer uses igraph_real_fprintf_precise from types.c in the C layer to ensure that floating-point values are written with the highest possible precision. It could be the case that this function does not work correctly due to some platform-dependent behaviour, but then I would need to know which platform you are working with.

@rajanski
Copy link
Author

Hi Tamas, I am on Ubuntu 14.04 LTS 64 bit

@ntamas
Copy link
Member

ntamas commented Oct 28, 2015

Did you compile the Python interface of igraph on your own or did you install it from a .deb package (via the package manager)? If so, where did you get the package from and which version of the Python interface are you using? (Try printing igraph.__version__ from Python).

@rajanski
Copy link
Author

rajanski commented Nov 2, 2015

Hi, I installed igraph via pip. The interface version is 0.7.1

@ntamas
Copy link
Member

ntamas commented Nov 4, 2015

I'll try to install it soon in a virtual machine and test it.

@ntamas ntamas self-assigned this Nov 5, 2015
@ntamas ntamas added the bug label Nov 5, 2015
@ntamas
Copy link
Member

ntamas commented Nov 5, 2015

Managed to confirm this in an Ubuntu 14.04 VM when installing igraph via pip without pre-installing the C core. Will investigate further.

@ntamas
Copy link
Member

ntamas commented Nov 5, 2015

Okay, it turns out that this has been fixed already in the C core of igraph, but there was no new version released from the C core since the fix.

The commit in the source code of the C core is here: igraph/igraph@fdcaa14 .

@ntamas
Copy link
Member

ntamas commented Nov 5, 2015

Related issue: igraph/igraph#796

@ntamas ntamas closed this as completed Nov 5, 2015
@ntamas
Copy link
Member

ntamas commented Nov 5, 2015

A workaround for the time being is to convert the floating-point attributes of your graph to strings before you save them, and then convert them back after loading. We'll have to wait until the next bugfix release of the C core to fix this properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants