แก้ coding style ภาค 10

This commit is contained in:
Pitchaya Boonsarngsuk
2018-03-22 16:40:27 +00:00
parent 400eab7e80
commit cd0f3687cb
14 changed files with 104 additions and 109 deletions

View File

@@ -1,10 +1,10 @@
/**
* Initialize the hybrid layout algorithm and start simulation.
*/
function startHybridSimulation() {
console.log("startHybridSimulation");
function startHybridSimulation () {
console.log('startHybridSimulation');
springForce = false;
d3.selectAll(".nodes").remove();
d3.selectAll('.nodes').remove();
manualStop = false;
simulation.stop();
p1 = performance.now();
@@ -17,33 +17,33 @@ function startHybridSimulation() {
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE)
.stableVelocity(0) // Change here
.distance(distance)
.distance(distance);
let forceFull = d3.forceNeighbourSampling()
.neighbourSize(FULL_NEIGHBOUR_SIZE)
.sampleSize(FULL_SAMPLE_SIZE)
.stableVelocity(0) // Change here
.distance(distance)
.distance(distance);
let hybridSimulation = d3.hybridSimulation(simulation, forceSample, forceFull)
.sampleIterations(ITERATIONS)
.fullIterations(FULL_ITERATIONS)
.numPivots(PIVOTS ? NUM_PIVOTS:-1)
.numPivots(PIVOTS ? NUM_PIVOTS : -1)
.interpFindTuneIts(INTERP_ENDING_ITS)
.interpDistanceFn(distance)
.on("sampleTick", ticked)
.on("fullTick", ticked)
.on("startInterp", startedFull)
.on("end", ended);
.on('sampleTick', ticked)
.on('fullTick', ticked)
.on('startInterp', startedFull)
.on('end', ended);
let sample = hybridSimulation.subSet();
addNodesToDOM(sample);
hybridSimulation.restart();
function startedFull() {
console.log("startedFull");
d3.selectAll(".nodes").remove();
function startedFull () {
console.log('startedFull');
d3.selectAll('.nodes').remove();
addNodesToDOM(nodes);
}
}

View File

@@ -1,8 +1,8 @@
/**
* Initialize the link force algorithm and start simulation.
*/
function startLinkSimulation() {
console.log("startLinkSimulation")
function startLinkSimulation () {
console.log('startLinkSimulation');
springForce = false;
alreadyRanIterations = 0;
manualStop = true;
@@ -12,26 +12,25 @@ function startLinkSimulation() {
if (tweakedVerOfLink) {
force = d3.forceLinkCompleteGraph()
.distance(function (n, m) {
return distanceFunction(n, m, props, norm);
})
.stableVelocity(0) // Change here
.onStableVelo(ended);
}
else {
for (i = nodes.length-1; i >= 1; i--) {
for (j = i-1; j >= 0; j--) {
.distance(function (n, m) {
return distanceFunction(n, m, props, norm);
})
.stableVelocity(0) // Change here
.onStableVelo(ended);
} else {
for (i = nodes.length - 1; i >= 1; i--) {
for (j = i - 1; j >= 0; j--) {
links.push({
source: nodes[i],
target: nodes[j],
target: nodes[j]
});
}
}
force = d3.forceLink()
.distance(function (n) {
return distanceFunction(n.source, n.target, props, norm);
})
.links(links);
.distance(function (n) {
return distanceFunction(n.source, n.target, props, norm);
})
.links(links);
}
/* Add force
@@ -51,9 +50,9 @@ function startLinkSimulation() {
simulation
.alphaDecay(0)
.alpha(1)
.on("tick", ticked)
.on("end", ended)
//.velocityDecay(0.8)
.force(forceName,force)
.on('tick', ticked)
.on('end', ended)
// .velocityDecay(0.8)
.force(forceName, force)
.restart();
}

View File

@@ -1,28 +1,28 @@
/**
* Initialize the Chalmers' 1996 algorithm and start simulation.
*/
function startNeighbourSamplingSimulation() {
console.log("startNeighbourSamplingSimulation");
//springForce = true;
function startNeighbourSamplingSimulation () {
console.log('startNeighbourSamplingSimulation');
// springForce = true;
alreadyRanIterations = 0;
manualStop = true;
simulation.stop();
p1 = performance.now();
let force = d3.forceNeighbourSampling()
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE)
.distance(function (s, t) {
return distanceFunction(s, t, props, norm);
})
.stableVelocity(0) // Change here
.onStableVelo(ended);
.neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE)
.distance(function (s, t) {
return distanceFunction(s, t, props, norm);
})
.stableVelocity(0) // Change here
.onStableVelo(ended);
simulation
.alphaDecay(0)
.alpha(1)
.on("tick", ticked)
.on("end", ended)
.on('tick', ticked)
.on('end', ended)
.force(forceName, force);
// Restart the simulation.
simulation.restart();

View File

@@ -1,7 +1,7 @@
/**
* Initialize the t-SNE algorithm and start simulation.
*/
function starttSNE() {
function starttSNE () {
springForce = false;
simulation.stop();
p1 = performance.now();
@@ -25,20 +25,20 @@ function starttSNE() {
/**
* Initialize the Barnes-Hut algorithm and start simulation.
*/
function startBarnesHutSimulation() {
console.log("startBarnesHutSimulation")
function startBarnesHutSimulation () {
console.log('startBarnesHutSimulation');
alreadyRanIterations = 0;
manualStop = false;
springForce = false;
p1 = performance.now();
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); }));
.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();
}