/** * Initialize the Chalmers' 1996 algorithm and start simulation. */ function startNeighbourSamplingSimulation() { console.log("startNeighbourSamplingSimulation"); springForce = true; simulation.stop(); p1 = performance.now(); simulation .alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS)) .force(forceName, d3.forceNeighbourSamplingDistance() // Set the parameters for the algorithm (optional). .neighbourSize(NEIGHBOUR_SIZE) .sampleSize(SAMPLE_SIZE) // .freeness(0.5) .distanceRange(SELECTED_DISTANCE) // The distance function that will be used to calculate distances // between nodes. .distance(function (s, t) { return distanceFunction(s, t, props, norm); }) .stableVelocity(0.004) .stableVeloHandler( function(){simulation.stop(); ended();} ) ); // Restart the simulation. console.log(simulation.force(forceName).neighbourSize(), simulation.force(forceName).sampleSize()); simulation.alpha(1).restart(); }