แก้ coding style ภาค 4

This commit is contained in:
Pitchaya Boonsarngsuk
2018-03-22 16:22:43 +00:00
parent f3a6656c8f
commit 8e34697d89
3 changed files with 8 additions and 7 deletions

View File

@@ -1,17 +1,17 @@
export {default as forceNeighbourSampling} export {default as forceNeighbourSampling}
from './src/neighbourSampling'; from './src/neighbourSampling';
export { default as forceBarnesHut} export {default as forceBarnesHut}
from './src/barnesHut'; from './src/barnesHut';
export { default as tSNE} export {default as tSNE}
from './src/t-sne'; from './src/t-sne';
export { default as forceLinkCompleteGraph} export {default as forceLinkCompleteGraph}
from './src/link'; from './src/link';
export { default as hybridSimulation} export {default as hybridSimulation}
from './src/hybridSimulation'; from './src/hybridSimulation';
export { getStress as calculateStress } export {getStress as calculateStress}
from './src/stress'; from './src/stress';

View File

@@ -41,7 +41,7 @@ export default function () {
y = target.y + target.vy - source.y - source.vy || jiggle(); y = target.y + target.vy - source.y - source.vy || jiggle();
l = Math.sqrt(x * x + y * y); l = Math.sqrt(x * x + y * y);
l = (l - distances[i * (i - 1) / 2 + j]) / l * dataSizeFactor * alpha; l = (l - distances[i * (i - 1) / 2 + j]) / l * dataSizeFactor * alpha;
x *= l, y *= l; x *= l; y *= l;
target.vx -= x; target.vx -= x;
target.vy -= y; target.vy -= y;
source.vx += x; source.vx += x;

View File

@@ -9,7 +9,8 @@ export function getStress (nodes, distance) {
let sumLowDDistSq = 0; let sumLowDDistSq = 0;
for (let j = nodes.length - 1; j >= 1; j--) { for (let j = nodes.length - 1; j >= 1; j--) {
for (let i = 0; i < j; i++) { for (let i = 0; i < j; i++) {
let source = nodes[i], target = nodes[j]; let source = nodes[i];
let target = nodes[j];
let lowDDist = Math.hypot(target.x - source.x, target.y - source.y); let lowDDist = Math.hypot(target.x - source.x, target.y - source.y);
let highDDist = distance(source, target); let highDDist = distance(source, target);
sumDiffSq += Math.pow(highDDist - lowDDist, 2); sumDiffSq += Math.pow(highDDist - lowDDist, 2);