Here is a minimal code that shows this behaviour:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from numpy import array
import graph_tool.all as gt
print 'Graph_tool version : %s' % gt.__version__
def test1():
print ('\n'
'Performing test1:\n'
'-----------------')
graph1 = gt.lattice((2,2), periodic=False)
pos = graph1.new_vertex_property('float')
pos.a = array([0.0,0.1,
1.0, 1.1])
graph1.vertex_properties['pos'] = pos
print ('\n'
'original pos: %s\n'
'reload graph property:\n'
' %s\n') % (str(pos.a),
str(graph1.vertex_properties['pos'].a))
graph1.save("graph_tool_io_test1.xml")
return graph1
def test2():
print ('\n'
'Performing test2:\n'
'-----------------')
graph2 = gt.load_graph("graph_tool_io_test1.xml")
pos = array([0.0,0.1,
1.0, 1.1])
print ('\n'
'original pos: %s\n'
'reload graph property:\n'
' %s\n') % (str(pos),
str(graph2.vertex_properties['pos'].a))
return graph2
def test3():
graph3 = gt.lattice((2,2), periodic=False)
pos = graph3.new_vertex_property('float')
pos.a = array([0.0,0.1,
1.0, 1.1])
graph3.load("graph_tool_io_test1.xml")
print ('\n'
'original graph property: %s\n'
'reload graph property: %s\n') % (str(pos.a),
str(graph3.vertex_properties['pos'].a))
return graph3
if __name__ == '__main__':
switch = sys.argv[1]
if switch == 'all':
graph1 = test1()
graph2 = test2()
graph3 = test3()
elif switch == 'test1':
graph1 = test1()
elif switch == 'test2':
graph2 = test2()
elif switch == 'test3':
graph3 = test3()
elif switch == 'import-only':
print 'Imports only'
else:
print 'Usage: python test.py {all|test1|test2|test3}'
##### End