Neighbor sampling remove distance threshold

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-24 21:19:56 +00:00
parent 918275ce45
commit 36ddbd13c4
2 changed files with 3 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
*/ */
function startNeighbourSamplingSimulation() { function startNeighbourSamplingSimulation() {
console.log("startNeighbourSamplingSimulation"); console.log("startNeighbourSamplingSimulation");
springForce = true; //springForce = true;
simulation.stop(); simulation.stop();
p1 = performance.now(); p1 = performance.now();
@@ -14,7 +14,6 @@ function startNeighbourSamplingSimulation() {
.neighbourSize(NEIGHBOUR_SIZE) .neighbourSize(NEIGHBOUR_SIZE)
.sampleSize(SAMPLE_SIZE) .sampleSize(SAMPLE_SIZE)
// .freeness(0.5) // .freeness(0.5)
.distanceRange(SELECTED_DISTANCE)
// The distance function that will be used to calculate distances // The distance function that will be used to calculate distances
// between nodes. // between nodes.
.distance(function (s, t) { .distance(function (s, t) {

View File

@@ -23,7 +23,6 @@ export default function () {
neighbours = [], neighbours = [],
samples = new Array(), samples = new Array(),
distance = constant(300), distance = constant(300),
distanceRange = 10,
nodes, nodes,
neighbourSize = 6, neighbourSize = 6,
sampleSize = 3, sampleSize = 3,
@@ -157,11 +156,7 @@ export default function () {
rand = Math.floor((Math.random() * max)); rand = Math.floor((Math.random() * max));
} }
let dist = +distance(nodes[index], nodes[rand]); let dist = +distance(nodes[index], nodes[rand]);
if (dist <= distanceRange) { randElements.set(rand, dist);
randElements.set(rand, dist);
} else {
triedElements++;
}
} }
return randElements; return randElements;
@@ -215,7 +210,7 @@ export default function () {
// Check if a value from sample could be a better neighbour // Check if a value from sample could be a better neighbour
// if so, replace it. // if so, replace it.
if (value < neighbMax[1] && value <= distanceRange) { if (value < neighbMax[1]) {
neighbours[index].delete(neighbMax[0]); neighbours[index].delete(neighbMax[0]);
neighbours[index].set(key, value) neighbours[index].set(key, value)
neighbours[index] = new Map([...neighbours[index].entries()].sort(sortDistances)); neighbours[index] = new Map([...neighbours[index].entries()].sort(sortDistances));
@@ -277,10 +272,6 @@ export default function () {
return arguments.length ? (freeness = +_, force) : freeness; return arguments.length ? (freeness = +_, force) : freeness;
};*/ };*/
force.distanceRange = function (_) {
return arguments.length ? (distanceRange = +_, force) : distanceRange;
};
force.nodeNeighbours = function (_) { force.nodeNeighbours = function (_) {
return arguments.length ? neighbours[+_] : neighbours; return arguments.length ? neighbours[+_] : neighbours;
}; };