code: def _get_Voronoi_edges(vor):
      r
      edges = [[], []]
      for facet in vor.ridge_vertices:
          # Create a closed cycle of vertices that define the facet
          edges[0].extend(facet[:-1]+[facet[-1]])
          edges[1].extend(facet[1:]+[facet[0]])
      edges = sp.vstack(edges).T  # Convert to scipy-friendly format
      mask = sp.any(edges == -1, axis=1)  # Identify edges at infinity
      edges = edges[~mask]  # Remove edges at infinity
      edges = sp.sort(edges, axis=1)  # Move all points to upper triangle
      # Remove duplicate pairs
      edges = edges[:, 0] + 1j*edges[:, 1]  # Convert to imaginary
      edges = sp.unique(edges)  # Remove duplicates
      edges = sp.vstack((sp.real(edges), sp.imag(edges))).T  # Back to real
      edges = sp.array(edges, dtype=int)
      return edges
docs: r"""
      Given a Voronoi object as produced by the scipy.spatial.Voronoi class,
      this function calculates the start and end points of eeach edge in the
      Voronoi diagram, in terms of the vertex indices used by the received
      Voronoi object.
  
      Parameters
      ----------
      vor : scipy.spatial.Voronoi object
  
      Returns
      -------
      A 2-by-N array of vertex indices, indicating the start and end points of
      each vertex in the Voronoi diagram.  These vertex indices can be used to
      index straight into the ``vor.vertices`` array to get spatial positions.