Performing nearest neighbor analysis