From 474bd677ae11624279f1aeec513406e8063c8e47 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk <2285135b@student.gla.ac.uk> Date: Fri, 2 Feb 2018 12:19:17 +0000 Subject: [PATCH] Enable Remigijus's Barnes-Hut --- .../js/src/example-papaparsing/otherAlgo.js | 21 ++++++++++--------- index.js | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/js/src/example-papaparsing/otherAlgo.js b/examples/js/src/example-papaparsing/otherAlgo.js index 7cadba7..8560e0d 100644 --- a/examples/js/src/example-papaparsing/otherAlgo.js +++ b/examples/js/src/example-papaparsing/otherAlgo.js @@ -15,7 +15,7 @@ function starttSNE() { // The distance function that will be used to calculate distances // between nodes. .distance(function (s, t) { - return distanceFunction(s, t, props, norm) * MULTIPLIER; + return distanceFunction(s, t, props, norm); })); // Restart the simulation. console.log(simulation.force(forceName).perplexity(), simulation.force(forceName).learningRate()); @@ -26,18 +26,19 @@ function starttSNE() { * Initialize the Barnes-Hut algorithm and start simulation. */ function startBarnesHutSimulation() { + console.log("startBarnesHutSimulation") + alreadyRanIterations = 0; + manualStop = false; springForce = false; - simulation.stop(); p1 = performance.now(); - simulation - .alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS)) - .force(forceName, d3.forceBarnesHut() - // The distance function that will be used to calculate distances - // between nodes. - .distance(function (s, t) { - return distanceFunction(s, t, props, norm) * MULTIPLIER; - })); + simulation.alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS)) + .on("tick", ticked) + .on("end", ended) + .force(forceName, d3.forceBarnesHut() + // The distance function that will be used to calculate distances + // between nodes. + .distance(function(s, t) { return distanceFunction(s, t, props, norm); })); // Restart the simulation. simulation.alpha(1).restart(); } diff --git a/index.js b/index.js index 2228c38..19c23ed 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ export {default as forceNeighbourSampling} from "./src/neighbourSampling"; -/* + export { default as forceBarnesHut} from "./src/barnesHut"; - +/* export { default as tSNE} from "./src/t-sne"; */