code: def prune(graph, prune_level=0, n_neighbors=10):
      
  
      max_degree = max(5, 3 * n_neighbors - prune_level)
      n_iters = max(3, n_neighbors - prune_level)
      reduced_graph = degree_prune(graph, max_degree=max_degree)
      result_graph = lil_matrix((graph.shape[0], graph.shape[0])).tocsr()
  
      for _ in range(n_iters):
          mst = minimum_spanning_tree(reduced_graph)
          result_graph = result_graph.maximum(mst)
          reduced_graph -= mst
          reduced_graph.eliminate_zeros()
  
      return result_graph
docs: Perform pruning on the graph so that there are fewer edges to
      be followed. In practice this operates in two passes. The first pass
      removes edges such that no node has degree more than ``3 * n_neighbors -
      prune_level``. The second pass builds up a graph out of spanning trees;
      each iteration constructs a minimum panning tree of a graph and then
      removes those edges from the graph. The result is spanning trees that
      take various paths through the graph. All these spanning trees are merged
      into the resulting graph. In practice this prunes away a limited number
      of edges as long as enough iterations are performed. By default we will
      do ``n_neighbors - prune_level``iterations.
  
      Parameters
      ----------
      graph: sparse matrix
          The adjacency matrix of the graph
  
      prune_level: int (optional default 0)
          How aggressively to prune the graph, larger values perform more
          aggressive pruning.
  
      n_neighbors: int (optional 10)
          The number of neighbors of the k-neighbor graph that was constructed.
  
      Returns
      -------
      result: sparse matrix
          The pruned graph