# How to visualize distances?

I have a list of cities and the distance between each city.

A -> B: 3km
A -> C: 5km
A -> D: 1km
B -> C: 1km
B -> D: 2km
C -> D: 5km


I would like to draw a graph where all cities are shown as points while the distances between the points are as near at the provided distances as possible. I am thinking of an algorithm that draws the points in space and tries to iteratively move the objects closer to the distance.

How can I accomplice that in Python?

• Consider multidimensional scaling if the distance matrix is square symmetric. For rectangular matrix (bipartite graph) consider multidimensional unfolding or correspondence analysis. Mar 15 at 11:36