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.
Best, F.
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.
Best, Giuseppe
2014-05-23 21:56 GMT+02:00 Flavien Lambert petit.lepton@gmail.com:
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.
Best, F.
graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
Hi! Thanks for the answer! I managed to retrieve the nodes easily but my main concern is to get the property id in fact... On 23 May 2014 20:09, "Giuseppe Profiti" gamma2@users.sourceforge.net wrote:
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.
Best, Giuseppe
2014-05-23 21:56 GMT+02:00 Flavien Lambert petit.lepton@gmail.com:
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.
Best, F.
graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
On 05/24/2014 04:50 PM, Flavien Lambert wrote:
Hi! Thanks for the answer! I managed to retrieve the nodes easily but my main concern is to get the property id in fact...
I don't fully understand what the difficulty is. Could you perhaps be more specific, preferably with a short example?
Best, Tiago
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.
Thanks for the great work by the way! F.
On 24 May 2014 11:06, Tiago de Paula Peixoto tiago@skewed.de wrote:
On 05/24/2014 04:50 PM, Flavien Lambert wrote:
Hi! Thanks for the answer! I managed to retrieve the nodes easily but my main concern is to get the property id in fact...
I don't fully understand what the difficulty is. Could you perhaps be more specific, preferably with a short example?
Best, Tiago
-- Tiago de Paula Peixoto tiago@skewed.de
graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
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
That is perfect! Thanks a lot!
On 24 May 2014 12:20, Tiago de Paula Peixoto tiago@skewed.de wrote:
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
graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool