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.
attachment.html (580 Bytes)
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.
2014-05-23 21:56 GMT+02:00 Flavien Lambert <petit.lepton(a)gmail.com>:
attachment.html (1.48 KB)
Hi! Thanks for the answer! I managed to retrieve the nodes easily but my
main concern is to get the property id in fact...
attachment.html (2.23 KB)
I don't fully understand what the difficulty is. Could you perhaps be
more specific, preferably with a short example?
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 *
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.
Thanks for the great work by the way!
attachment.html (1.67 KB)
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
idx = g.vertex_index[v]
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]
That is perfect! Thanks a lot!
attachment.html (2.12 KB)