编程语言
首页 > 编程语言> > Python的graph_tool中的加权度分布

Python的graph_tool中的加权度分布

作者:互联网

Pythons graph_tool中,是否有一种简单的方法来计算加权度分布(出射,进入或所有边缘的权重之和)?

在Stats包中,vertex_hist给出了未加权的in-degree,out-degree和total-degree直方图,但似乎没有办法获得这些的加权版本.

注意:我正在处理31,000个顶点和> 1000万个边缘.我正在寻找一种方法来尽可能地利用graph_tool.

解决方法:

是的,这很容易.您必须获取加权度数的属性映射,然后执行直方图:

d = g.degree_property_map("out", weight)   # weight is an edge property map
bins = linspace(d.a.min(), d.a.max(), 40)  # linear bins
h = vertex_hist(g, d, bins)

标签:python,graph-tool
来源: https://codeday.me/bug/20190609/1206235.html