What is an algorithm to minimize some distances D between N elements?

A classmate printed a database diagram for a class, a type with lines representing relationships between tables. However, its lines intersected everywhere and looked ugly.

So, I thought of a way to move the tables to minimize the overall distance of the line, and I could not figure out how to do this, except to just move them to each other. So, basically: considering the N elements on some 2-coordinate space and the number of connections between the pairs of these elements, how do you move the elements so that the total distance between the pairs is minimal, but the distance is not less than S? (so that the tables are not too close to each other) Is there any algorithm for this?

(I understand that the smallest total distance will not necessarily make the layout less ugly, the lines may still intersect. But the location of the table is what made me think)

+4
source share
1 answer

Some tips:

http://en.wikipedia.org/wiki/Graph_drawing

http://en.wikipedia.org/wiki/Force-based_algorithms

A database schema schema is an example of a graph (or may be a tree depending on your schema).

Greetings

+3
source

Source: https://habr.com/ru/post/1306879/


All Articles