code: def laplacian(W, normalized=True):
      """Return graph Laplacian"""
  
      # Degree matrix.
      d = W.sum(axis=0)
  
      # Laplacian matrix.
      if not normalized:
          D = scipy.sparse.diags(d.A.squeeze(), 0)
          L = D - W
      else:
          d += np.spacing(np.array(0, W.dtype))
          d = 1 / np.sqrt(d)
          D = scipy.sparse.diags(d.A.squeeze(), 0)
          I = scipy.sparse.identity(d.size, dtype=W.dtype)
          L = I - D * W * D
  
      assert np.abs(L - L.T).mean() < 1e-9
      assert type(L) is scipy.sparse.csr.csr_matrix
      return L
  
file_path: dgl/examples/pytorch/model_zoo/geometric/coarsening.py
imports: import numpy
  import scipy.sparse
  import sklearn.metrics
label_desc: Use image node_id 1 for calling a global function with example usage: laplacian(W, normalized) and returns: L