implementing betweenness