Line spacing algorithm

I am looking for an algorithm that would be useful for determining the xy coordinates to display the number of objects on the screen. Each object can be associated with another object and there can be any number of relations, and there can be any number of these objects.

There are no restrictions on the total size of the display area of ​​this object.

I am writing this in php and will search to store the coordinates in an array.

+5
source share
2 answers

One way to do this is to use a pseudo-physical model. Your objects have repulsive force and attractive force if attached.

: , , .

:

for each object o1
   force[o1] = 0
   for each object o2
      if o1 and o2 are linked
         force[o1] += attraction_force(o1, o2)
      else
         force[o1] += repulsion_force(o1, o2)

for each object o1
   move(o1, force[o1])

, .

, , . , , . , (, a spring) (- )

, , , , . .

+3

, , strong > . . , planar .

0

All Articles