get_in_neighbours() and get_in_edges() output do not match
I have a directed graph: <Graph object, directed, with 61560 vertices and 42858 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e96d0>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e9710>, False) at 0x11a5e9190> I would like to get all in neighbors of a vertex, using the following codes: for v in g.vertices(): print('') print("vertex id:") print(v) print('all out neighbors') print(g.get_out_neighbours(v)) print('all in neighbors') print(g.get_in_neighbours(v)) print('all in edges') print(g.get_in_edges(v)) raw_input() Here's the console output: vertex id: 0 all out neighbors [18099] all in neighbors [0] all in edges [[1 0 1]] Output from get_in_edges() suggests that the in neighbor should be vertex 1; but get_int_neighbours() suggests that the in neighbors is itself. I am not sure what's going wrong. Any help would be appreciated. Thanks a lot! -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 18.08.2017 19:56, yu.zheng.columbia@gmail.com wrote:
I have a directed graph: <Graph object, directed, with 61560 vertices and 42858 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e96d0>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e9710>, False) at 0x11a5e9190>
I would like to get all in neighbors of a vertex, using the following codes: for v in g.vertices(): print('') print("vertex id:") print(v) print('all out neighbors') print(g.get_out_neighbours(v)) print('all in neighbors') print(g.get_in_neighbours(v)) print('all in edges') print(g.get_in_edges(v)) raw_input()
Here's the console output: vertex id: 0 all out neighbors [18099] all in neighbors [0] all in edges [[1 0 1]]
Output from get_in_edges() suggests that the in neighbor should be vertex 1; but get_int_neighbours() suggests that the in neighbors is itself. I am not sure what's going wrong. Any help would be appreciated. Thanks a lot!
Could you please provide a complete and minimal example that shows the problem? (I.e. both the data *and* the code) Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Sure thing! This is the sample graph I've created, using the code at the end of this message: Here are a couple of observations: 1. get_in_neighbours() worked fine prior to purging the edges. 2. But once the edges are purged, the problem arises. Vertex 2, 3 and 4 should all have in neighbor 5, but g.get_in_neighbour(v) returns their own vertex index. 3. get_in_edges() is working as intended. Thanks a lot! from graph_tool import * # step 1: create a sample graph g = Graph() g.add_vertex(5) eprop_share = g.new_edge_property("double") eprop_majorShare = g.new_edge_property("boolean") i=0.05 for v in g.vertices(): e = g.add_edge(5,v) eprop_share[e]=i i=i+0.. # step 2: purge all edges with <0.2 share for e in g.edges(): if eprop_share[e] >= 0.2: eprop_majorShare[e] = True else: eprop_majorShare[e] = False g.set_edge_filter(eprop_majorShare) g.purge_edges() # step 3: understand why get_in_neighbours and get_in_edges give difference in neighbors for v in g.vertices(): print('') print("vertex id:") print(v) print('all out neighbors') print(g.get_out_neighbours(v)) print('all in neighbors') print(g.get_in_neighbours(v)) print('all in edges') print(g.get_in_edges(v)) raw_input() On Mon, Aug 21, 2017 at 6:21 AM, Tiago de Paula Peixoto <tiago@skewed.de> wrote:
On 18.08.2017 19:56, yu.zheng.columbia@gmail.com wrote:
I have a directed graph: <Graph object, directed, with 61560 vertices and 42858 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e96d0>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x11a5e9190, at 0x11a5e9710>, False) at 0x11a5e9190>
I would like to get all in neighbors of a vertex, using the following codes: for v in g.vertices(): print('') print("vertex id:") print(v) print('all out neighbors') print(g.get_out_neighbours(v)) print('all in neighbors') print(g.get_in_neighbours(v)) print('all in edges') print(g.get_in_edges(v)) raw_input()
Here's the console output: vertex id: 0 all out neighbors [18099] all in neighbors [0] all in edges [[1 0 1]]
Output from get_in_edges() suggests that the in neighbor should be vertex 1; but get_int_neighbours() suggests that the in neighbors is itself. I am not sure what's going wrong. Any help would be appreciated. Thanks a lot!
Could you please provide a complete and minimal example that shows the problem? (I.e. both the data *and* the code)
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de https://lists.skewed.de/mailman/listinfo/graph-tool
On 23.08.2017 20:08, Yu Zheng wrote:
Sure thing! This is the sample graph I've created, using the code at the end of this message:
Here are a couple of observations:
1. get_in_neighbours() worked fine prior to purging the edges. 2. But once the edges are purged, the problem arises. Vertex 2, 3 and 4 should all have in neighbor 5, but g.get_in_neighbour(v) returns their own vertex index. 3. get_in_edges() is working as intended.
Thanks for the example. As it turns out this is a bug that occurs only for filtered graphs. I have now fixed it in git. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
You're welcome. Thanks for the update and this wonderful tool :) On Thu, Aug 24, 2017 at 4:46 PM, Yu Zheng <yz2235@stanford.edu> wrote:
You're welcome. Thanks for the update and this wonderful tool :)
On Thu, Aug 24, 2017 at 3:56 PM, Tiago Peixoto [via Main discussion list for the graph-tool project] <ml+s982480n4027343h43@n3.nabble.com> wrote:
On 23.08.2017 20:08, Yu Zheng wrote:
Sure thing! This is the sample graph I've created, using the code at the end of this message:
Here are a couple of observations:
1. get_in_neighbours() worked fine prior to purging the edges. 2. But once the edges are purged, the problem arises. Vertex 2, 3 and 4 should all have in neighbor 5, but g.get_in_neighbour(v) returns their own vertex index. 3. get_in_edges() is working as intended.
Thanks for the example. As it turns out this is a bug that occurs only for filtered graphs. I have now fixed it in git.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] <http:///user/SendEmail.jtp?type=node&node=4027343&i=0>>
_______________________________________________ graph-tool mailing list [hidden email] <http:///user/SendEmail.jtp?type=node&node=4027343&i=1> https://lists.skewed.de/mailman/listinfo/graph-tool
*signature.asc* (849 bytes) Download Attachment <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/attachment/4027343/0/signature.asc> -- Tiago de Paula Peixoto <tiago@skewed.de>
------------------------------ If you reply to this email, your message will be added to the discussion below: http://main-discussion-list-for-the-graph-tool-project.98248 0.n3.nabble.com/get-in-neighbours-and-get-in-edges-output- do-not-match-tp4027336p4027343.html To unsubscribe from get_in_neighbours() and get_in_edges() output do not match, click here <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4027336&code=eXUuemhlbmcuY29sdW1iaWFAZ21haWwuY29tfDQwMjczMzZ8MTk1MTIzNDE2OQ==> . NAML <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
-- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
participants (4)
-
SunnyTheCavalier -
Tiago de Paula Peixoto -
Yu Zheng -
yu.zheng.columbia@gmail.com