closeness_vitality#
- closeness_vitality(G, node=None, weight=None, wiener_index=None)[source]#
返回图中节点的紧密活力。
节点的*紧密活力*,定义在[1]的第3.6.2节中,是指在排除该节点时,所有节点对之间距离总和的变化。
- Parameters:
- GNetworkX图
一个强连通图。
- weight字符串
用作权重的边属性的名称。这个参数直接传递给:func:
wiener_index
函数。- node对象
如果指定,则只返回该节点的紧密活力。否则,将返回一个字典,将每个节点映射到其紧密活力。
- Returns:
- 字典或浮点数
如果
node
为None,此函数返回一个字典,以节点为键,紧密活力为值。否则,只返回指定节点的紧密活力。节点的紧密活力可能是负无穷大,如果移除该节点会使图断开连接。
- Other Parameters:
- wiener_index数字
如果你已经计算了图
G
的维纳指数,可以在这里提供该值。否则,将为你计算。
See also
closeness_centrality
References
[1]Ulrik Brandes, Thomas Erlebach (eds.). 网络分析:方法论基础. Springer, 2005. <http://books.google.com/books?id=TTNhSm7HYrIC>
Examples
>>> G = nx.cycle_graph(3) >>> nx.closeness_vitality(G) {0: 2.0, 1: 2.0, 2: 2.0}
Additional backends implement this function
- parallelParallel backend for NetworkX algorithms
The parallel computation is implemented only when the node is not specified. The closeness vitality for each node is computed concurrently.
- Additional parameters:
- get_chunksstr, function (default = “chunks”)
A function that takes in a list of all the nodes as input and returns an iterable
node_chunks
. The default chunking is done by slicing thenodes
inton
chunks, wheren
is the total number of CPU cores.
[Source]