functions to obtain topology distances and to plot the results