用pythonnetworkx计算图的指数集中度

2024-09-28 22:35:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一张图,想计算它的绝对集中度和超度集中度。我试图通过使用python networkx来实现这一点,但是在那里我只能找到一种方法来计算每个节点的索引度和出度中心度。有没有一种方法可以计算出networkx中图的内、外集中度?在


Tags: 方法networkx节点中心集中度超度
2条回答

这是密码。我假设在学位集中的定义如下。。。在

N=G.order()
indegrees = G.in_degree().values()
max_in = max(indegrees)
centralization = float((N*max_in - sum(indegrees)))/(N-1)**2

注意,我在编写本文时假设它是python2,而不是3。所以我在除法中使用了float。你可以根据需要进行调整。在


开始定义

给定一个网络G,定义让y是阶数最大的节点,并使用d_i(u)表示节点u的入度。将H_G定义为(我不知道在stackoverflow上编写数学公式的更好的方法-希望任何知道的人编辑此内容或给出评论)

^{pr2}$

其中u迭代G中的所有节点,N是{}的节点数。在

当存在所有其他节点指向的单个节点且没有其他节点具有其边时,N节点上的图形的最大可能值出现。那么这个H_G就是(N-1)^2。在

因此,对于一个给定的网络,我们将集中度定义为它相对于最大值的H_G的值。所以C(G) = H_G/ (N-1)^2。在

结束定义

这个答案来自于一个关于这个问题的Google小组(在使用R的上下文中),它有助于澄清与上述答案相关的数学问题:

Freeman's approach measures "the average difference in centrality between the most central actor and all others".

This 'centralization' is exactly captured in the mathematical formula

sum(max(x)-x)/(length(x)-1)

x refers to any centrality measure! That is, if you want to calculate the degree centralization of a network, x has simply to capture the vector of all degree values in the network. To compare various centralization measures, it is best to use standardized centrality measures, i.e. the centrality values should always be smaller than 1 (best position in any possible network) and greater than 0 (worst position)... if you do so, the centralization will also be in the range of [0,1].

For degree, e.g., the 'best position' is to have an edge to all other nodes (i.e. incident edges = number of nodes minus 1) and the 'worst position' is to have no incident edge at all.

相关问题 更多 >