def degree_mixing_matrix(G, x='out', y='in', weight=None, nodes=None, normalized=True):
 d = degree_mixing_dict(G, x=x, y=y, nodes=nodes, weight=weight)
 s = set(d.keys())
 for (k, v) in d.items():
  s.update(v.keys())
 m = max(s)
 mapping = dict(zip(range((m + 1)), range((m + 1))))
 a = dict_to_numpy_array(d, mapping=mapping)
 if normalized:
  a = (a / a.sum())
 return a

def degree_mixing_matrix ( G , x = 'out' , y = 'in' , weight = None , nodes = None , normalized = True ) : d = degree_mixing_dict ( G , x = x , y = y , nodes = nodes , weight = weight ) s = set ( d . keys ( ) ) for ( k , v ) in d . items ( ) : s . update ( v . keys ( ) ) m = max ( s ) mapping = dict ( zip ( range ( ( m + 1 ) ) , range ( ( m + 1 ) ) ) ) a = dict_to_numpy_array ( d , mapping = mapping ) if normalized : a = ( a / a . sum ( ) ) return a
return mixing matrix for attribute .