iGraph 直方图对象

iGraph histogram object

我有一个图 G,我要计算它的度数分布。

为此,使用 Python iGraph 的 "degree_distribution()" 似乎很明显。但是,函数 returns 和 "histogram objects" 我觉得很难处理。

我使用以下代码:

dD = G.degree_distribution(bin_width=1)
print(dD)

哪个returns:

N = 104, mean +- sd: 12.0000 +- 2.2382
[ 7,  8): *** (3)
[ 8,  9): ** (2)
[ 9, 10): ****** (6)
[10, 11): ************** (14)
[11, 12): ********************* (21)
[12, 13): ****************** (18)
[13, 14): **************** (16)
[14, 15): ********** (10)
[15, 16): ******* (7)
[16, 17): *** (3)
[17, 18): *** (3)
[18, 19): * (1)

我想将结果导出到 R(与 ggplot2 一起使用)。如何将其转换为可导出的格式?

list(h.bins()) 为您提供一个元组列表,其中每个元组包含直方图 bin 的左右边界以及该 bin 中的项目数。然后您可以将其写入文件并从 R 中读取。