Hi all, I am new here. I looked into the mail archive but I did not get
what I was looking for despite old subjects about id's.
I have extracted the strongly connected component (scc) from a graph that I
built from a transportation network. I want to identify the nodes of the
network that are not connected to the scc. I am able to get the index of
the vertices in the graph but I did not find an obvious way to get the id's
of these vertices to extract them from my original network.
Hello,
I think that one solution may be to use a graphview or a filter: you should
filter out the nodes that belong to the scc, then you can iterate over the
remaining vertices and retrieve any property they have.
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]