code: def degree_prune(graph, max_degree=20):
      
  
      result = graph.tolil()
      for i, row_data in enumerate(result.data):
          if len(row_data) > max_degree:
              cut_value = np.argsort(row_data)[max_degree]
              row_data = [x if x <= cut_value else 0.0 for x in row_data]
              result.data[i] = row_data
      result = result.tocsr()
      result.eliminate_zeros()
      return result
docs: Prune the k-neighbors graph back so that nodes have a maximum
      degree of ``max_degree``.
  
      Parameters
      ----------
      graph: sparse matrix
          The adjacency matrix of the graph
  
      max_degree: int (optional, default 20)
          The maximum degree of any node in the pruned graph
  
      Returns
      -------
      result: sparse matrix
          The pruned graph.