On 20.10.2014 18:01, Smith, Steven - 1004 - MITLL wrote: > The Vertex methods in_neighbours() and all_neighbours() throw an error for > undirected graphs. Is this behavior intended? Code: > >> import numpy as np >> import numpy.random as rand >> import graph_tool.all as gt >> >> n = 1000; p = 2.0*np.log(n)/n >> g = gt.random_graph(n, lambda: rand.poisson((n - 1) * p), directed=False, >> model="erdos") >> v = [v for v in g.vertices() if g.vertex_index[v] == 0][0] >> [u.__int__() for u in v.out_neighbours()] >> >> # Fail: >> [u.__int__() for u in v.in_neighbours()] >> # Fail: >> [u.__int__() for u in v.all_neighbours()] >> >> # Correct by setting direction >> g.is_directed() >> g.set_directed(True) >> g.is_directed() >> [u.__int__() for u in v.in_neighbours()] >> [u.__int__() for u in v.out_neighbours()] > > > Error: > >> File "gt_test.py", line 11, in <module> >> [u.__int__() for u in v.in_neighbours()] >> File >> "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/__init__.py", >> line 2327, in _in_neighbours >> yield e.source() >> ValueError: invalid edge descriptor
I can't reproduce this. The script above works just fine for me. What version of graph-tool are you using? Best, Tiago -- Tiago de Paula Peixoto <[email protected]>
signature.asc
Description: OpenPGP digital signature
_______________________________________________ graph-tool mailing list [email protected] http://lists.skewed.de/mailman/listinfo/graph-tool
