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

@@ -65,6 +65,6 @@ function calculateDistance(source, target, properties, normArgs) {
sumDiff *= properties.length/cols;
}
console.log(sumDiff);
//console.log(sumDiff);
return sumDiff;
}
}

View File

@@ -25,9 +25,8 @@ var intercom = Intercom.getInstance();
intercom.on("select", unSelectNodes);
var links = [],
nodes,
node,
var nodes, // as in Data points
node, // as in SVG object that have all small circles on screen
props,
norm,
p1 = 0,

View File

@@ -1,11 +1,11 @@
export {
/*export {
default as forceNeighbourSampling
}
from "./src/neighbourSampling";
export {
default as forceNeighbourSamplingPre
}
from "./src/neighbourSamplingPre";
from "./src/neighbourSamplingPre";*/
export {
default as forceNeighbourSamplingDistance
}

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();

View File

@@ -26,9 +26,9 @@ export default function () {
nodes,
neighbourSize = 6,
sampleSize = 3,
freeness = 0.85,
springForce = 0.7,
dampingFactor = 0.3,
//freeness = 0.85,
//springForce = 0.7,
//dampingFactor = 0.3,
velocity,
multiplier = 50;
@@ -99,8 +99,9 @@ export default function () {
neighbs = new Map([...neighbs.entries()].sort(sortDistances));
neighbours[i] = neighbs;
exclude.concat(neighbs);
samples[i] = createRandomSample(i, exclude, n, sampleSize);
//exclude.concat(neighbs);
//samples[i] = createRandomSample(i, exclude, n, sampleSize);
//Samples will be created at the start of each it anyway.
}
}
@@ -276,9 +277,9 @@ export default function () {
return getAvgVelocity();
};
force.freeness = function (_) {
/*force.freeness = function (_) {
return arguments.length ? (freeness = +_, force) : freeness;
};
};*/
force.distanceRange = function (_) {
return arguments.length ? (distanceRange = +_, force) : distanceRange;