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