Rather than storing separate state for the nodes’ fixed positions, just use the
fx and fy properties on the nodes themselves. This is more similar to the 3.x
API which used node.fixed (and node.px, node.py to store the previous position).
This eliminates the need to expose additional APIs for getting, setting,
clearing and iterating over the fixed positions.
Fixes#35.
Related #30. Rather than normalize the total force applied per node, have the
default link strength be inversely proportional to the number of links for the
source and the target. This way, if the source or target is heavily connected,
the strength of the link is reduced. However, we still bias the application of
the link such that the less-connected of the two nodes is moved more.
This feels a bit cleaner since you don’t need to track the name of the fixing
force externally. It also enforces that fixing happens after the application of
any forces.
This lets you set the “desired” alpha for the simulation, and have the
simulation smoothly interpolate towards the desired value. By default, the
target value is zero, such that the simulation cools. However, by setting it to
a non-zero value, such as during a drag interaction, you can also use it to have
the simulation heat. Fixes#26.
This commit also changes simulation.restart so that it no longer resets the
alpha to one, and changes the meaning of simulation.alphaDecay. The new default
alphaDecay now cause the simulation to end after 300 ticks, instead of 345.
It’s tempting to do them independently (in parallel), but this makes convergence
much slower. We’re now moving nodes while they’re in the quadtree, which means
we could miss a few collisions; but since the tree is rebuilt on each iteration
that should probably be fine.
This reverts part of 95354e8470, though it retains
the area-biased resolution and the performance improvements.