@not_implemented_for('directed')
def normalized_laplacian_matrix(G, nodelist=None, weight='weight'):
 import scipy
 import scipy.sparse
 if (nodelist is None):
  nodelist = list(G)
 A = nx.to_scipy_sparse_matrix(G, nodelist=nodelist, weight=weight, format='csr')
 (n, m) = A.shape
 diags = A.sum(axis=1).flatten()
 D = scipy.sparse.spdiags(diags, [0], m, n, format='csr')
 L = (D - A)
 with scipy.errstate(divide='ignore'):
  diags_sqrt = (1.0 / scipy.sqrt(diags))
 diags_sqrt[scipy.isinf(diags_sqrt)] = 0
 DH = scipy.sparse.spdiags(diags_sqrt, [0], m, n, format='csr')
 return DH.dot(L.dot(DH))

@ not_implemented_for ( 'directed' ) def normalized_laplacian_matrix ( G , nodelist = None , weight = 'weight' ) : import scipy import scipy . sparse if ( nodelist is None ) : nodelist = list ( G ) A = nx . to_scipy_sparse_matrix ( G , nodelist = nodelist , weight = weight , format = 'csr' ) ( n , m ) = A . shape diags = A . sum ( axis = 1 ) . flatten ( ) D = scipy . sparse . spdiags ( diags , [ 0 ] , m , n , format = 'csr' ) L = ( D - A ) with scipy . errstate ( divide = 'ignore' ) : diags_sqrt = ( 1.0 / scipy . sqrt ( diags ) ) diags_sqrt [ scipy . isinf ( diags_sqrt ) ] = 0 DH = scipy . sparse . spdiags ( diags_sqrt , [ 0 ] , m , n , format = 'csr' ) return DH . dot ( L . dot ( DH ) )
return the normalized laplacian matrix of g .