แก้ coding style ภาค 10
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
* Initialize the hybrid layout algorithm and start simulation.
|
||||
*/
|
||||
function startHybridSimulation () {
|
||||
console.log("startHybridSimulation");
|
||||
console.log('startHybridSimulation');
|
||||
springForce = false;
|
||||
d3.selectAll(".nodes").remove();
|
||||
d3.selectAll('.nodes').remove();
|
||||
manualStop = false;
|
||||
simulation.stop();
|
||||
p1 = performance.now();
|
||||
@@ -17,13 +17,13 @@ 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)
|
||||
@@ -31,10 +31,10 @@ function startHybridSimulation() {
|
||||
.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);
|
||||
@@ -42,8 +42,8 @@ function startHybridSimulation() {
|
||||
hybridSimulation.restart();
|
||||
|
||||
function startedFull () {
|
||||
console.log("startedFull");
|
||||
d3.selectAll(".nodes").remove();
|
||||
console.log('startedFull');
|
||||
d3.selectAll('.nodes').remove();
|
||||
addNodesToDOM(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Initialize the link force algorithm and start simulation.
|
||||
*/
|
||||
function startLinkSimulation () {
|
||||
console.log("startLinkSimulation")
|
||||
console.log('startLinkSimulation');
|
||||
springForce = false;
|
||||
alreadyRanIterations = 0;
|
||||
manualStop = true;
|
||||
@@ -17,13 +17,12 @@ function startLinkSimulation() {
|
||||
})
|
||||
.stableVelocity(0) // Change here
|
||||
.onStableVelo(ended);
|
||||
}
|
||||
else {
|
||||
} 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]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -51,8 +50,8 @@ function startLinkSimulation() {
|
||||
simulation
|
||||
.alphaDecay(0)
|
||||
.alpha(1)
|
||||
.on("tick", ticked)
|
||||
.on("end", ended)
|
||||
.on('tick', ticked)
|
||||
.on('end', ended)
|
||||
// .velocityDecay(0.8)
|
||||
.force(forceName, force)
|
||||
.restart();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Initialize the Chalmers' 1996 algorithm and start simulation.
|
||||
*/
|
||||
function startNeighbourSamplingSimulation () {
|
||||
console.log("startNeighbourSamplingSimulation");
|
||||
console.log('startNeighbourSamplingSimulation');
|
||||
// springForce = true;
|
||||
alreadyRanIterations = 0;
|
||||
manualStop = true;
|
||||
@@ -21,8 +21,8 @@ function startNeighbourSamplingSimulation() {
|
||||
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();
|
||||
|
||||
@@ -26,15 +26,15 @@ function starttSNE() {
|
||||
* Initialize the Barnes-Hut algorithm and start simulation.
|
||||
*/
|
||||
function startBarnesHutSimulation () {
|
||||
console.log("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)
|
||||
.on('tick', ticked)
|
||||
.on('end', ended)
|
||||
.force(forceName, d3.forceBarnesHut()
|
||||
// The distance function that will be used to calculate distances
|
||||
// between nodes.
|
||||
|
||||
@@ -12,7 +12,7 @@ function calculateCosineSimilarity(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (property.toLowerCase() !== "class" && property.toLowerCase() !== "app" && property.toLowerCase() !== "user" && property.toLowerCase() !== "weekday") {
|
||||
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function calculateDiceDissimilarity(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (property.toLowerCase() !== "class" && property.toLowerCase() !== "app" && property.toLowerCase() !== "user" && property.toLowerCase() !== "weekday") {
|
||||
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ function calculateDistance(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (source.hasOwnProperty(property) && target.hasOwnProperty(property)
|
||||
&& property.toLowerCase() !== "index" && property.toLowerCase() !== "type") {
|
||||
if (source.hasOwnProperty(property) && target.hasOwnProperty(property) &&
|
||||
property.toLowerCase() !== 'index' && property.toLowerCase() !== 'type') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
@@ -42,9 +42,8 @@ function calculateDistance(source, target, properties, normArgs) {
|
||||
// Comparing Dates
|
||||
var parsedDateS = Date.parse(s);
|
||||
var parsedDateT = Date.parse(t);
|
||||
if (isNaN(s) && !isNaN(parsedDateS)
|
||||
&& isNaN(t) && !isNaN(parsedDateT)) {
|
||||
|
||||
if (isNaN(s) && !isNaN(parsedDateS) &&
|
||||
isNaN(t) && !isNaN(parsedDateT)) {
|
||||
val1 = parsedDateS.valueOf(),
|
||||
val2 = parsedDateT.valueOf();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ function calculateDistancePoker(source, target) {
|
||||
var sumDiff = 0.0,
|
||||
ordDiff = 1.0,
|
||||
ORD_FACTOR = 1.5,
|
||||
cards = ["C1", "C2", "C3", "C4", "C5"],
|
||||
cards = ['C1', 'C2', 'C3', 'C4', 'C5'],
|
||||
cols = 0;
|
||||
|
||||
// Iterate through cards
|
||||
@@ -26,13 +26,13 @@ function calculateDistancePoker(source, target) {
|
||||
|
||||
// Class of poker hands describes the similarities the best
|
||||
// so give it more priority than checking the differences between cards.
|
||||
if (source.hasOwnProperty("CLASS") && target.hasOwnProperty("CLASS")) {
|
||||
var s = parseInt(source["CLASS"]),
|
||||
t = parseInt(target["CLASS"]);
|
||||
if (source.hasOwnProperty('CLASS') && target.hasOwnProperty('CLASS')) {
|
||||
var s = parseInt(source['CLASS']),
|
||||
t = parseInt(target['CLASS']);
|
||||
|
||||
// If classes differ, then scale them by a factor.
|
||||
if (s !== t) {
|
||||
ordDiff *= (ORD_FACTOR * (Math.abs(s-t)))
|
||||
ordDiff *= (ORD_FACTOR * (Math.abs(s - t)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function calculateEuclideanDistance(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (property.toLowerCase() !== "class" && property.toLowerCase() !== "app" && property.toLowerCase() !== "user" && property.toLowerCase() !== "weekday" && property.toLowerCase() !== "type") {
|
||||
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday' && property.toLowerCase() !== 'type') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ function calculateEuclideanDistanceTSNE(source, target, properties, normArgs) {
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (source.hasOwnProperty(property) && target.hasOwnProperty(property) &&
|
||||
property.toLowerCase() !== "class") {
|
||||
property.toLowerCase() !== 'class') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function calculateJaccardDissimilarity(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (property.toLowerCase() !== "class" && property.toLowerCase() !== "app" && property.toLowerCase() !== "user" && property.toLowerCase() !== "weekday") {
|
||||
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ function calculateManhattanDistance(source, target, properties, normArgs) {
|
||||
// Iterate through every column of data
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
property = properties[i];
|
||||
if (property.toLowerCase() !== "class" && property.toLowerCase() !== "app" && property.toLowerCase() !== "user" && property.toLowerCase() !== "weekday") {
|
||||
if (property.toLowerCase() !== 'class' && property.toLowerCase() !== 'app' && property.toLowerCase() !== 'user' && property.toLowerCase() !== 'weekday') {
|
||||
var s = source[property],
|
||||
t = target[property];
|
||||
|
||||
|
||||
@@ -23,10 +23,8 @@ function calculateNormalization(nodes) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function standardDevation (nodes, properties, avg) {
|
||||
|
||||
var stDev = new Array(properties.length).fill(0)
|
||||
var stDev = new Array(properties.length).fill(0);
|
||||
|
||||
for (var i = 0; i < properties.length; i++) {
|
||||
var sum = 0;
|
||||
@@ -52,7 +50,6 @@ function standardDevation(nodes, properties, avg) {
|
||||
}
|
||||
|
||||
return stDev;
|
||||
|
||||
}
|
||||
|
||||
// Calculate the sum of values and the squared sum
|
||||
|
||||
Reference in New Issue
Block a user