add closest pair algorithm