graphscope.nx.classes.function.density¶ graphscope.nx.classes.function.density(G)[源代码]¶ 返回图的密度。 无向图的密度为 \[d = \frac{2m}{n(n-1)},\] 对于有向图则是 \[d = \frac{m}{n(n-1)},\] 其中n表示节点数量,m表示图G中的边数量。 备注 对于没有边的图,密度为0;对于完全图,密度为1。多重图的密度可以大于1。 自环会被计入边的总数中,因此含有自环的图其密度可能超过1。