attribute_mixing_dict#
- attribute_mixing_dict(G, attribute, nodes=None, normalized=False)[源代码]#
返回属性的混合矩阵的字典表示形式。
- 参数
- G图表
NetworkX图形对象。
- attribute字符串
节点属性键。
- nodes: list or iterable (optional)
取消容器中的节点以构建词典。默认为所有节点。
- normalized布尔值(默认值=FALSE)
如果为假,则返回计数;如果为真,则返回概率。
- 返回
- 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