Clean up old codes

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-03 10:32:40 +07:00
parent 1f53efb988
commit 0101245e9e
5 changed files with 27 additions and 22 deletions

View File

@@ -36,9 +36,11 @@ export default function(links) {
}
function force(alpha) {
for (var k = 0, n = links.length; k < iterations; ++k) {
for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) {
link = links[i], source = link.source, target = link.target;
for (var k = 0, n = links.length; k < iterations; ++k) { // Each iteration in a tick
for (var i = 0, link, source, target, x, y, l, b; i < n; ++i) { //For each link
link = links[i];
source = link.source;
target = link.target;
x = target.x + target.vx - source.x - source.vx || jiggle();
y = target.y + target.vy - source.y - source.vy || jiggle();
l = Math.sqrt(x * x + y * y);
@@ -66,14 +68,17 @@ export default function(links) {
}
for (i = 0; i < m; ++i) {
link = links[i], link.index = i;
if (typeof link.source !== "object") link.source = find(nodeById, link.source);
if (typeof link.target !== "object") link.target = find(nodeById, link.target);
++count[link.source.index], ++count[link.target.index];
link = links[i];
link.index = i;
//if (typeof link.source !== "object") link.source = find(nodeById, link.source);
//if (typeof link.target !== "object") link.target = find(nodeById, link.target);
++count[link.source.index];
++count[link.target.index];
}
for (i = 0, bias = new Array(m); i < m; ++i) {
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
link = links[i];
bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
}
strengths = new Array(m), initializeStrength();