@not_implemented_for('undirected')
@not_implemented_for('multigraph')
def directed_modularity_matrix(G, nodelist=None, weight=None):
 if (nodelist is None):
  nodelist = list(G)
 A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, format='csr')
 k_in = A.sum(axis=0)
 k_out = A.sum(axis=1)
 m = k_in.sum()
 X = ((k_out * k_in) / m)
 return (A - X)

@ not_implemented_for ( 'undirected' ) @ not_implemented_for ( 'multigraph' ) def directed_modularity_matrix ( G , nodelist = None , weight = None ) : if ( nodelist is None ) : nodelist = list ( G ) A = nx . to_scipy_sparse_matrix ( G , nodelist = nodelist , weight = weight , format = 'csr' ) k_in = A . sum ( axis = 0 ) k_out = A . sum ( axis = 1 ) m = k_in . sum ( ) X = ( ( k_out * k_in ) / m ) return ( A - X )
return the directed modularity matrix of g .