Add closest pair algorithm