avoiding overflow in igraph_closeness and related functions