def get_graph_hops(graph, num_samples):
c = Counter()
for i in range(0, num_samples):
node = sample(graph.nodes(), 1)[0]
b = nx.bfs_successors(graph, node)
for l, h in hops(b, node):
c[l] += h
hopper = Counter()
for l in c:
hopper[l] = float(c[l]) / float(num_samples)
return hopper
评论列表
文章目录