code: def edgelist_to_weighted_adjacency(g, weights=None):
      """Convert edgelist to weighted adjacency matrix in sparse coo_matrix"""
      import scipy.sparse as ss
      import numpy as np
  
      res = g._edges[[g._source, g._destination]].values.astype(
          np.int64
      )
      rows, cols = res.T[0], res.T[1]
      if weights is None:
          weights = np.ones(len(rows))
      M = ss.coo_matrix((weights, (rows, cols)))
      return M.tocsr()
  
file_path: pygraphistry/graphistry/ai_utils.py
imports: import pandas
  import numpy
  import graphistry
  from .constants import DISTANCE, WEIGHT, BATCH
  from logging import getLogger
label_desc: Use image node_id 6 for calling a global function with example usage: edgelist_to_weighted_adjacency(g, weights) and returns: M