deepcopy of Vertices, Edges and Graphs
Hi, After processing an external text file I create a an object that among other things holds a graph object, properties, vertices etc etc. I would like to save the original copy of the object, so after I can always refer back to it in a speedy fashion without having to re-parse the text file and re-initialize the object, but when I tried to use deepcopy() it complains. I can not even perform a deep copy on a Vertex object. Any idea why this is happening, and most importantly is there a work around? (I tried pickle and shelve and they do not work either). Thanks in advance for the response, Vaggelis -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 12.08.2016 16:58, Evangelos Petsalis wrote:
Hi,
After processing an external text file I create a an object that among other things holds a graph object, properties, vertices etc etc. I would like to save the original copy of the object, so after I can always refer back to it in a speedy fashion without having to re-parse the text file and re-initialize the object, but when I tried to use deepcopy() it complains. I can not even perform a deep copy on a Vertex object.
Any idea why this is happening, and most importantly is there a work around? (I tried pickle and shelve and they do not work either).
It is difficult to be precise, since you have not given a concrete example. But the only general issue I can see is that Vertex and Edge objects are not pickable. You should instead store their integer and pair representations, respectively: v = int(v) e = (int(e.source()), int(e.target())) and pickle that. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Evangelos Petsalis -
Tiago de Paula Peixoto