applyForceRepulsion = () => {
for (let i = 0; i < nodes.length; i++) {
if (check(i) == false) continue;
for (let j = i+1; j < nodes.length; j++) {
if (check(j) == false) continue;
if(i == j) continue;
let n1 = nodes[i]
let n2 = nodes[j]
let dx = n2.x - n1.x
let dy = n2.y - n1.y
if(dx==0 && dy==0) continue;
let a = Math.atan2(dy, dx)
let dist = Math.hypot(dx, dy)
let forceRepulsion = kRepulsion / dist**2
if (forceRepulsion > 1)
forceRepulsion = 1
n1.x -= forceRepulsion * Math.cos(a)
n1.y -= forceRepulsion * Math.sin(a)
n2.x += forceRepulsion * Math.cos(a)
n2.y += forceRepulsion * Math.sin(a)
}
}
}