improved calculation of betweenness and closeness