Interp almost-complete brute-force interpolation
This commit is contained in:
@@ -16,34 +16,34 @@ export default function (nodes, config) {
|
||||
FullneighbourSize = config.hasOwnProperty("fullNeighbourSize") ? config.fullNeighbourSize : 6,
|
||||
FullsampleSize = config.hasOwnProperty("fullSampleSize") ? config.fullSampleSize : 3,
|
||||
FulldistanceRange = config.hasOwnProperty("fullDistanceRange") ? config.fullDistanceRange : 10,
|
||||
distanceFn = config.hasOwnProperty("distanceFn") ? config.distance : constant(300),
|
||||
distanceFn = config.hasOwnProperty("distanceFn") ? config.distanceFn : constant(300),
|
||||
PIVOTS = config.hasOwnProperty("pivots") ? config.pivots : false,
|
||||
NUMPIVOTS = config.hasOwnProperty("numPivots") ? config.numPivots : 3,
|
||||
event = d3.dispatch("sampleTick", "fullTick", "startFull", "end");
|
||||
|
||||
var sets = sampleFromNodes(nodes, nodes.length, Math.sqrt(nodes.length));
|
||||
var sets = sampleFromNodes(nodes, Math.sqrt(nodes.length));
|
||||
var sample = sets.sample;
|
||||
var remainder = sets.remainder;
|
||||
var interpSubset = sampleFromNodes(sample, sample.length, Math.sqrt(sample.length)).sample;
|
||||
var sampleSubset = sampleFromNodes(sample, Math.sqrt(sample.length)).sample;
|
||||
|
||||
var sampleSimulation = d3.forceSimulation(sample)
|
||||
.stop()
|
||||
.alphaDecay(1 - Math.pow(0.001, 1 / SAMPLE_ITERATIONS));
|
||||
|
||||
sampleSimulation
|
||||
.alphaDecay(1 - Math.pow(0.001, 1 / SAMPLE_ITERATIONS))
|
||||
.on("tick", function () {
|
||||
event.call("sampleTick", sampleSimulation);
|
||||
})
|
||||
.on("end", ended)
|
||||
.force("neighbourSampling", neighbourSamplingDistance()
|
||||
.on("end", ended);
|
||||
|
||||
sampleSimulation.force("forces", neighbourSamplingDistance()
|
||||
.neighbourSize(neighbourSize)
|
||||
.sampleSize(sampleSize)
|
||||
.distanceRange(distanceRange)
|
||||
.distance(distanceFn)
|
||||
)
|
||||
.alpha(1).restart();
|
||||
);
|
||||
sampleSimulation.alpha(1).restart();
|
||||
|
||||
function ended() {
|
||||
event.call("startFull");
|
||||
console.log("Ended sample simulation");
|
||||
/*
|
||||
if (PIVOTS) {
|
||||
@@ -52,12 +52,16 @@ export default function (nodes, config) {
|
||||
interpolation(sample, remainder, interpSubset, distance);
|
||||
}
|
||||
*/
|
||||
if (FULL_ITERATIONS==0) return;
|
||||
event.call("fullTick");
|
||||
alert('About to Full run');
|
||||
if (FULL_ITERATIONS==0) {
|
||||
event.call("end");
|
||||
return;
|
||||
}
|
||||
fullSimulation = d3.forceSimulation()
|
||||
.stop()
|
||||
.alphaDecay(1 - Math.pow(0.001, 1 / FULL_ITERATIONS));
|
||||
|
||||
event.call("startFull", fullSimulation);
|
||||
|
||||
fullSimulation
|
||||
.force("neighbourSampling", neighbourSamplingDistance()
|
||||
@@ -139,8 +143,9 @@ export default function (nodes, config) {
|
||||
}
|
||||
|
||||
|
||||
function sampleFromNodes(nodes, max, size) {
|
||||
var randElements = [];
|
||||
function sampleFromNodes(nodes, size) {
|
||||
let randElements = [],
|
||||
max = nodes.length;
|
||||
|
||||
for (var i = 0; i < size; ++i) {
|
||||
var rand = nodes[Math.floor((Math.random() * max))];
|
||||
|
||||
Reference in New Issue
Block a user