We can assume that $q_1 and q_2 $are both 1, then the above formula becomes
F=ker21e
Attractive force
Some particles are entangled by some edges that produce a spring-like Hooker attractive force:
Fs=ks(x−x0)
The repulsive and attractive forces continue to act, the particles tend to balance after continuous displacement, and gradually no longer have relative displacement, and the energy is continuously consumed, and finally tends to zero.
Under the action of attractive force and repulsive force, the coordinates are constantly updated, and after multiple iterations, a stable state is reached, and the convergence is over. Parameters and iterations need to be debugged.
Calculation step
If we want to use code to implement the simplified layout of the force guide diagram, we need several steps.
Set point data nodes, link data links.
Random positioning of points.
Render View
Execution algorithm calculates position, renders view (repeated N times)
Code implementation
In fact, understand the above process, you can fully implement a version of the force-oriented algorithm, I just provide a simple version here, each person to achieve the algorithm and the final effect may be completely different