| 136430 | } |
| 136431 | } |
| 136432 | function tick(iterations) { |
| 136433 | var i, n = nodes.length, node; |
| 136434 | if (iterations === undefined) iterations = 1; |
| 136435 | for(var k = 0; k < iterations; ++k){ |
| 136436 | alpha += (alphaTarget - alpha) * alphaDecay; |
| 136437 | forces.forEach(function(force) { |
| 136438 | force(alpha); |
| 136439 | }); |
| 136440 | for(i = 0; i < n; ++i){ |
| 136441 | node = nodes[i]; |
| 136442 | if (node.fx == null) node.x += node.vx *= velocityDecay; |
| 136443 | else node.x = node.fx, node.vx = 0; |
| 136444 | if (node.fy == null) node.y += node.vy *= velocityDecay; |
| 136445 | else node.y = node.fy, node.vy = 0; |
| 136446 | } |
| 136447 | } |
| 136448 | return simulation; |
| 136449 | } |
| 136450 | function initializeNodes() { |
| 136451 | for(var i = 0, n = nodes.length, node; i < n; ++i){ |
| 136452 | node = nodes[i], node.index = i; |