On 05/24/2014 05:42 PM, Flavien Lambert wrote:
Hi, I am sorry, I think there is no difficulty. It is just that I did not get how to get the id once you have the node index :
from graph_tool.all import * g=load_graph('nodeNetwork.graphml') l=label_largest_component(g) u=list(l.a)
So from u, I get the indices (for the 0 entries). I would like to know what are the id's of the graph_tool vertices in my original nodeNetwork.graphml.
That depends on what you mean by "id". Each vertex in the graph has an associated index, which is retrieved via the vertex_index attribute of the graph: idx = g.vertex_index[v] or equivalently idx = int(v) However, if you are referring to some property map stored in your graphml file which you call "id", then this resides inside the internal property maps of the graph: id_map = g.vp["id"] id = id_map[v] And finally, if you want the intrinsic ids inside the graphml file if they are not in canonical form, this can be retrieved via: id_map = g.vp["_graphml_vertex_id"] id = id_map[v] Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>