def calculate_indegree(graph):
# will only work on DiGraph (directed graph)
print "\tCalculating Indegree..."
g = graph
indeg = g.in_degree()
nx.set_node_attributes(g, 'indegree', indeg)
indeg_sorted = sorted(indeg.items(), key=itemgetter(1), reverse=True)
for key, value in indeg_sorted[0:10]:
print "\t > ", key, value
return g, indeg
评论列表
文章目录