Neighbor stop on little velocity changes

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-17 09:55:43 +00:00
parent 7b6b5e46c6
commit 5ece153651
3 changed files with 97 additions and 77 deletions

View File

@@ -166,51 +166,49 @@ function processData(data, error) {
.nodes(nodes)
.on("tick", ticked)
.on("end", ended);
function ticked() {
// If rendering is selected, then draw at every iteration.
if (rendering === true) {
node // Each sub-circle in the SVG, update cx and cy
.attr("cx", function (d) {
return d.x;
})
.attr("cy", function (d) {
return d.y;
});
}
// Emit the distribution data to allow the drawing of the bar graph
if (springForce) {
intercom.emit("passedData", simulation.force(forceName).distributionData());
}
}
function ended() {
if (rendering !== true) { // Never drawn anything before? Now it's time.
node
.attr("cx", function (d) {
return d.x;
})
.attr("cy", function (d) {
return d.y;
});
}
if (p1 !== 0) {
// Performance time measurement
p2 = performance.now();
console.log("Execution time: " + (p2 - p1));
// Do not calculate stress for data sets bigger than 100 000.
// if (nodes.length <= 100000) {
// console.log("Stress: ", simulation.force(forceName).stress());
// }
// console.log(simulation.force(forceName).nodeNeighbours());
p1 = 0;
p2 = 0;
}
}
};
function ticked() {
// If rendering is selected, then draw at every iteration.
if (rendering === true) {
node // Each sub-circle in the SVG, update cx and cy
.attr("cx", function (d) {
return d.x;
})
.attr("cy", function (d) {
return d.y;
});
}
// Emit the distribution data to allow the drawing of the bar graph
if (springForce) {
intercom.emit("passedData", simulation.force(forceName).distributionData());
}
}
function ended() {
if (rendering !== true) { // Never drawn anything before? Now it's time.
node
.attr("cx", function (d) {
return d.x;
})
.attr("cy", function (d) {
return d.y;
});
}
if (p1 !== 0) {
// Performance time measurement
p2 = performance.now();
console.log("Execution time: " + (p2 - p1));
// Do not calculate stress for data sets bigger than 100 000.
// if (nodes.length <= 100000) {
// console.log("Stress: ", simulation.force(forceName).stress());
// }
// console.log(simulation.force(forceName).nodeNeighbours());
p1 = 0;
p2 = 0;
}
}
function brushEnded() {
var s = d3.event.selection,
@@ -281,7 +279,10 @@ function startNeighbourSamplingSimulation() {
// between nodes.
.distance(function (s, t) {
return distanceFunction(s, t, props, norm) * MULTIPLIER;
}));
})
.stableVelocity(1.2 * MULTIPLIER)
.stableVeloHandler( function(){simulation.stop(); ended();} )
);
// Restart the simulation.
console.log(simulation.force(forceName).neighbourSize(), simulation.force(forceName).sampleSize());
simulation.alpha(1).restart();
@@ -310,7 +311,7 @@ function startHybridSimulation() {
pivots: PIVOTS,
numPivots: NUM_PIVOTS
};
.sampleSize(SAMPLE_SIZE);
console.log(configuration);
hybridSimulation = d3.hybridSimulation(nodes, configuration);
let sample = hybridSimulation.sample();