code: def clustering_coefficient_weighted(user, interaction=None):
      
      matrix = matrix_undirected_weighted(user, interaction=interaction)
      weights = [weight for g in matrix for weight in g if weight is not None]
  
      if len(weights) == 0:
          return None
      max_weight = max(weights)
      triplet_weight = 0
  
      for a, b in combinations(range(len(matrix)), 2):
          a_b, a_c, b_c = matrix[a][b], matrix[a][0], matrix[b][0]
  
          if a_b is None or a_c is None or b_c is None:
              continue
  
          if a_b and a_c and b_c:
              triplet_weight += (a_b * a_c * b_c) ** (1 / 3) / max_weight
  
      d_ego = sum(1 for i in matrix[0] if i > 0)
      return 2 * triplet_weight / (d_ego * (d_ego - 1)) if d_ego > 1 else 0
docs: The clustering coefficient of the user's weighted, undirected network.
  
      It is defined the same way as :meth`~bandicoot.network.clustering_coefficient_unweighted`,
      except that closed triplets are weighted by the number of interactions. For
      each triplet (A, B, C), we compute the geometric mean of the number of
      interactions, using the undirected weighted matrix:
  
      .. math::
          weight_{abc} = (m_{ab} \; m_{bc} \; m_{ac})^{1/3}
  
      The weight is normalized, between 0 and 1, by the maximum value in the
      matrix.