Design and analysis of distributed k-nearest neighbors graph algorithms