Generalizing Lloyd's algorithm for graph clustering