On 09/25/2013 12:47 PM, Guillaume Gay wrote:
I'm using graph tool to represent a mesh of apical junctions (interconnected cells in a tissue). As my simulation goes, positions of the graph nodes change. Positions are stored as 3 vertex property maps with type <double> (i.e. x, y and z). For now, I write a graphxml file (plus possibliy a .png image of the graph) each time I change the nodes positions.
I would like to store the history of each node position, in other terms its trajectory, but I feel that doing so by assigning a property map with type vector<double> to each node would produce big files: I typically have about 5000 vertices, and up to 350 'time points'. I would also need to store other propery maps (describing each vertex and edge state in the simulation). A full static view right now gives a 24 Mb xml file...
The point is I usually only need the static version, which I tend to open and close quite often, and that allready takes quite some time to open. So I thought I could for exemple store the graph's history in a separate h5 file and access only if needed, for exemple, and only store a reference to the file in the graph.
I'd really apreciate to have some insight into that before I go on coding...
Putting it all inside the graph and saving it is the easier thing to program, but there are many other options. If you want to separate the position data from the graph itself, there are simple options. For instance, you could keep the history as a list of numpy arrays (or a large 2d matrix) instead of a property map, which you could then save either by picking or by using numpy's save function. Whenever you need the history, you would load the file and assign the values to the property map. You can do this rather easily: # loading history = pickle.load(open("history", "rb")) h = g.new_vertex_property("vector<double>") for v in g.vertices(): h[v] = history[int(v)] # saving history = [] for v in g.vertices(): history.append(array(h[v].a)) pickle.dump(history, open("history", "wb")) Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>