How to preserve graph layout for future use?
Is there any way to preserve graph layout for future use and restore when required?
I had tried to use pickle but did not worked after restore. Below is the demo python code.
import graph_tool.all as gt
g = gt.collection.data["karate"]
pos = gt.fruchterman_reingold_layout(g, n_iter=1000)
plt = gt.graph_draw(g, pos = pos)
import pickle
pkl_file = "g_pos.pkl"
# Save to file in the current working directory
with open(pkl_file, 'wb') as file:
pickle.dump(pos, file)
# Load from file
with open(pkl_file, 'rb') as file:
pos2 = pickle.load(file)
## ERROR: AttributeError: 'NoneType' object has no attribute 'new_vertex_property'
plt = gt.graph_draw(g, pos = pos2)
The error at graph_draw function is "AttributeError: 'NoneType' object has no attribute 'new_vertex_property'"