Can miss the minimum, but is enough for our purposes.

def get_min_vertex_distance( coor, guess ):
    """Can miss the minimum, but is enough for our purposes."""
    # Sort by x.
    ix = nm.argsort( coor[:,0] )
    scoor = coor[ix]

    mvd = 1e16
    
    # Get mvd in chunks potentially smaller than guess.
    n_coor = coor.shape[0]
    print n_coor
    
    i0 = i1 = 0
    x0 = scoor[i0,0]
    while 1:
        while ((scoor[i1,0] - x0) < guess) and (i1 < (n_coor - 1)):
            i1 += 1

#        print i0, i1, x0, scoor[i1,0]
        aim, aa1, aa2, aux = get_min_vertex_distance_naive( scoor[i0:i1+1] )
        if aux < mvd:
            im, a1, a2 = aim, aa1 + i0, aa2 + i0
        mvd = min( mvd, aux )
        i0 = i1 = int( 0.5 * (i1 + i0 ) ) + 1
#        i0 += 1
        x0 = scoor[i0,0]
#        print '-', i0

        if i1 == n_coor - 1: break

    print im, ix[a1], ix[a2], a1, a2, scoor[a1], scoor[a2]

    return mvd