code: def prune(
      self, prune_prob: float, prune_trigger: int, rng: random.Random
  ):
      if prune_prob == 0:
          return
  
      total_degree = len(self.edges) + len(self.r_edges)
      if total_degree <= prune_trigger:
          return
  
      # To avoid tie in distances
      counter = itertools.count()
      edge_pool: list[tuple[float, int, Vertex, bool]] = []
      for n, dist in self.edges.items():
          heapq.heappush(edge_pool, (dist, next(counter), n, True))
  
      for rn, dist in self.r_edges.items():
          heapq.heappush(edge_pool, (dist, next(counter), rn, False))
  
      # Start with the best undirected edge
      selected: list[Vertex] = [heapq.heappop(edge_pool)[2]]
      while len(edge_pool) > 0:
          c_dist, _, c, c_isdir = heapq.heappop(edge_pool)
          discarded = False
          for s in selected:
              if s.is_neighbor(c) and rng.random() < prune_prob:
                  orig, dest, dist = s.get_edge(c)
                  if dist < c_dist:
                      if c_isdir:
                          self.rem_edge(c)
                      else:
                          c.rem_edge(self)
                      discarded = True
                      break
                  else:
                      orig.rem_edge(dest)
  
          if not discarded:
              selected.append(c)
  
imports: from __future__ import annotations
  import heapq
  import itertools
  import math
  import random
  from river import base
label_desc: Use image node_id 20 for calling the Vertex obj's underlying member method code with example usage: obj.prune(prune_prob, prune_trigger, rng) without return types