简体   繁体   English

用于有向图的Python igraph密度函数

[英]Python igraph density function for directed graphs

Does python igraph function 'G.density()' calculate the density for an undirected graph only? python igraph函数'G.density()'仅计算无向图的密度吗? I want to calculate the density for an directed graph. 我想计算有向图的密度。 Must I divide by 2? 我必须除以2吗? There is an option for 'loop'=True or False but there is no option for directed or undirected graph. 'loop'= True或False有一个选项,但有向图或无向图则没有任何选项。 I know that for an undirected graph, the density is 我知道对于无向图,密度为

2m/n(n-1)

while for directed graph it us 而对于有向图,我们

m/n(n-1)

I am not seeing anything in the documentation. 我在文档中没有看到任何内容。

Yes, it is there : 是的,它在那里

 g.density(loops=False)

The important part comes in defining your graph object g as directed or undirected. 重要的部分在于将图形对象g定义为有向或无向。 The density() method will take that into account for your computation density()方法将在计算时考虑到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM