code: def _find_neighbor_and_lambda(neighbor_indices, neighbor_distances,
                                core_distances, min_samples):
      
      neighbor_core_distances = core_distances[neighbor_indices]
      point_core_distances = neighbor_distances[min_samples] * np.ones(
          neighbor_indices.shape[0])
      mr_distances = np.vstack((
          neighbor_core_distances,
          point_core_distances,
          neighbor_distances
      )).max(axis=0)
  
      nn_index = mr_distances.argmin()
  
      nearest_neighbor = neighbor_indices[nn_index]
      if mr_distances[nn_index] > 0.0:
          lambda_ = 1. / mr_distances[nn_index]
      else:
          lambda_ = np.finfo(np.double).max
  
      return nearest_neighbor, lambda_
docs: Find the nearest mutual reachability neighbor of a point, and  compute
      the associated lambda value for the point, given the mutual reachability
      distance to a nearest neighbor.
  
      Parameters
      ----------
      neighbor_indices : array (2 * min_samples, )
          An array of raw distance based nearest neighbor indices.
  
      neighbor_distances : array (2 * min_samples, )
          An array of raw distances to the nearest neighbors.
  
      core_distances : array (n_samples, )
          An array of core distances for all points
  
      min_samples : int
          The min_samples value used to generate core distances.
  
      Returns
      -------
      neighbor : int
          The index into the full raw data set of the nearest mutual reachability
          distance neighbor of the point.
  
      lambda_ : float
          The lambda value at which this point joins/merges with `neighbor`.