当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python NetworkX attribute_mixing_dict用法及代码示例


本文简要介绍 networkx.algorithms.assortativity.attribute_mixing_dict 的用法。

用法:

attribute_mixing_dict(G, attribute, nodes=None, normalized=False)

返回属性混合矩阵的字典表示。

参数

G图形

NetworkX 图形对象。

attributestring

节点属性键。

nodes: list or iterable (optional)

取消容器中的节点以构建字典。默认为所有节点。

normalized布尔(默认=假)

如果为 False,则返回计数,如果为 True,则返回概率。

返回

d字典

属性对出现的计数或联合概率。

例子

>>> G = nx.Graph()
>>> G.add_nodes_from([0, 1], color="red")
>>> G.add_nodes_from([2, 3], color="blue")
>>> G.add_edge(1, 3)
>>> d = nx.attribute_mixing_dict(G, "color")
>>> print(d["red"]["blue"])
1
>>> print(d["blue"]["red"])  # d symmetric for undirected graphs
1

相关用法


注:本文由纯净天空筛选整理自networkx.org大神的英文原创作品 networkx.algorithms.assortativity.attribute_mixing_dict。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。