Connected components


I'm new to using this library. It seems there is nog direct support for
calculating the connected components of a graph, is this correct?


attachment.html (220 Bytes)

Yes there is:



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

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

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():
     pickle.dump(history, open("history", "wb"))