def _find_neighbor_and_lambda(neighbor_indices, neighbor_distances, core_distances, min_samples):
    '\n    Find the nearest mutual reachability neighbor of a point, and  compute\n    the associated lambda value for the point, given the mutual reachability\n    distance to a nearest neighbor.\n\n    Parameters\n    ----------\n    neighbor_indices : array (2 * min_samples, )\n        An array of raw distance based nearest neighbor indices.\n\n    neighbor_distances : array (2 * min_samples, )\n        An array of raw distances to the nearest neighbors.\n\n    core_distances : array (n_samples, )\n        An array of core distances for all points\n\n    min_samples : int\n        The min_samples value used to generate core distances.\n\n    Returns\n    -------\n    neighbor : int\n        The index into the full raw data set of the nearest mutual reachability\n        distance neighbor of the point.\n\n    lambda_ : float\n        The lambda value at which this point joins/merges with `neighbor`.\n    '
    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.0 / mr_distances[nn_index])
    else:
        lambda_ = np.finfo(np.double).max
    return (nearest_neighbor, lambda_)
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`.
def _find_neighbor_and_lambda(neighbor_indices, neighbor_distances, core_distances, min_samples):
    '\n    Find the nearest mutual reachability neighbor of a point, and  compute\n    the associated lambda value for the point, given the mutual reachability\n    distance to a nearest neighbor.\n\n    Parameters\n    ----------\n    neighbor_indices : array (2 * min_samples, )\n        An array of raw distance based nearest neighbor indices.\n\n    neighbor_distances : array (2 * min_samples, )\n        An array of raw distances to the nearest neighbors.\n\n    core_distances : array (n_samples, )\n        An array of core distances for all points\n\n    min_samples : int\n        The min_samples value used to generate core distances.\n\n    Returns\n    -------\n    neighbor : int\n        The index into the full raw data set of the nearest mutual reachability\n        distance neighbor of the point.\n\n    lambda_ : float\n        The lambda value at which this point joins/merges with `neighbor`.\n    '
    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.0 / mr_distances[nn_index])
    else:
        lambda_ = np.finfo(np.double).max
    return (nearest_neighbor, lambda_)