_calculateSpringForce(node1, node2, edgeLength) {
    const dx = node1.x - node2.x;
    const dy = node1.y - node2.y;
    const distance = Math.max(Math.sqrt(dx * dx + dy * dy), 0.01);

    // the 1/distance is so the fx and fy can be calculated without sine or cosine.
    const springForce =
      (this.options.springConstant * (edgeLength - distance)) / distance;

    const fx = dx * springForce;
    const fy = dy * springForce;

    // handle the case where one node is not part of the physcis
    if (this.physicsBody.forces[node1.id] !== undefined) {
      this.physicsBody.forces[node1.id].x += fx;
      this.physicsBody.forces[node1.id].y += fy;
    }

    if (this.physicsBody.forces[node2.id] !== undefined) {
      this.physicsBody.forces[node2.id].x -= fx;
      this.physicsBody.forces[node2.id].y -= fy;
    }
  }
This is the code actually performing the calculation for the function above.
@param {Node} node1
@param {Node} node2
@param {number} edgeLength
@private