On 06/21/2011 03:15 PM, Sebastian Weber wrote:
The more elegant solution
gPath_ind = [ eg2id[e] for e in egPath ] gPath_filt = g.new_vertex_property("bool") gPath_filt.a[:] = False gPath_filt.a[gPath_ind] = True gp = GraphView(g, vfilt=gPath_filt) gpl = GraphView(gp, vfilt=label_largest_component(gp)) path_lc = [ int(v) for v in gpl.vertices() ]
fails for some reason I don't see.
I guess the problem is a small quirk with label_largest_component(). The code above removes all but one vertex, which has index gPath_ind, from the graph (is this really what you want, BTW?). The function label_largest_component() marks all the vertices which have the same index as the largest component. Since there is only one vertex, the component index is zero. However, the _unfiltered_ vertices will also have an index of zero, and they will get labelled as well... So your GraphView in the end will contain all the vertices. I have fixed this now in the git version (now label_largest_component() never labels filtered graphs).
BTW, in the end I want the vertex indices in the very original graph, which is what I hope to get here, but I am not really sure about that as I could not find anything about how to obtain vertex identifiers of filtered graphs which are good for referring to nodes in the original un-filtered graph. Or I overlooked it somewhere...
The vertex index is preserved by filtering. So you could do something like: v = g.vertex(int(u)) where u belongs to the filtered graph, and g is the unfiltered graph.
BTW, the newest graph-tool seems to compile and install just fine on MacOS. At least it brings its own DLFCN.py and hence installing out of the box.
What do you mean? I haven't included DLFCN.py anywhere... (I can't anyway, since it is platform-dependent code) Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>