Connected components

Hi,

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?

Thanks!

attachment.html (220 Bytes)

Yes there is:

    http://graph-tool.skewed.de/static/doc/topology.html#graph_tool.topology.label_components

Cheers,
Tiago

Hi,

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...

Cheers,

Guillaume

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