NetworkX

Previous topic

networkx.algorithms.mixing.degree_mixing_dict

Next topic

Minimum Spanning Tree

networkx.algorithms.mixing.attribute_mixing_dict

networkx.algorithms.mixing.attribute_mixing_dict(G, attribute, normalized=False)

Return dictionary representation of mixing matrix for attribute.

Parameters :

G : graph

NetworkX graph object.

attribute : string

Node attribute key.

normalized : bool (default=False)

Return counts if False or probabilities if True.

Returns :

d : dictionary

Counts or joint probability of occurrence of attribute pairs.

Examples

>>> 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