[graph-tool] Some clarifications regarding directness
Steve
stsmith at ll.mit.edu
Thu Feb 23 04:35:34 CET 2017
Should not set_directed() redefine the definition of out_neighbours() and
in_neighbours()?
When I created a simple Erdős–Rényi graph, then change it to a directed
graph, out_neighbours() and in_neighbours() do not return the expected
edges:
import graph_tool.all as gt, numpy as np, numpy.random as rand
N = 12
p = 1.5 * np.log(N)/N
g = gt.random_graph(N, deg_sampler=lambda: rand.poisson((N-1)*p),
directed=False, model='erdos')
vroot = g.vertex(0)
g.set_directed(False)
print([g.edge(vroot,v) for v in vroot.out_neighbours()])
print([g.edge(v,vroot) for v in vroot.in_neighbours()])
g.set_directed(True)
print([g.edge(vroot,v) for v in vroot.out_neighbours()])
print([g.edge(v,vroot) for v in vroot.in_neighbours()])
Result:
[<Edge object with source '0' and target '3' at 0x1245b9050>, <Edge object
with source '0' and target '10' at 0x1245bbf28>, <Edge object with source
'0' and target '6' at 0x1245b90e8>]
[]
[None, None, <Edge object with source '0' and target '6' at 0x1245bf050>]
[]
You can see that out_neighbours() returns *all* edges, even ones that are
inward-pointing, and in_neighbours() fails to return any edges.
--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Some-clarifications-regarding-directness-tp4026916p4027059.html
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
More information about the graph-tool
mailing list