On 17.03.2015 16:25, ob wrote:
The in_degree method returns wrong values if it is called with the weight parameter. As far as I could trace down the issue, it seems the method weighted_in_degree is resposible with C++ signature: boost::python::api::object weighted_in_degree(graph_tool::PythonVertex {lvalue},boost::any). Below is a minimal example.
Let's create a simple directed graph with two vertices and one edge.
In [1]: import graph_tool.all as gt g=gt.Graph() v1 = g.add_vertex() v2 = g.add_vertex() e1 = g.add_edge(v1,v2)
in-degree and out-degree look like expected
In [2]: [[v.in_degree(),v.out_degree()] for v in g.vertices()]
Out[2]: [[0, 1], [1, 0]]
Now, let's add some weight.
In [3]: g.ep['exposure'] = g.new_edge_property("double") g.ep['exposure'][e1] = 1.5
the results for out-degree look ok, however the in-degree array looks like it is shifted
In [4]: [[v.in_degree(weight=g.ep['exposure']),v.out_degree(weight=g.ep['exposure'])] for v in g.vertices()]
Out[4]: [[1.5, 1.5], [0.0, 0.0]]
I am using py27-graph-tool @2.2.36_0+gtk3 and boost @1.57.0_1+no_single+no_static+python27 I wonder if anyone can reproduce this issue. in_degree_issue.json <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026042/in_degree_issue.json>
Thanks for noticing this! It is indeed a bug. I have fixed it now in git. This is rather serious, so I will be making a new release with the fix ASAP. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>