/** * Initialize the hybrid layout algorithm and start simulation. */ function startHybridSimulation () { console.log('startHybridSimulation'); springForce = false; d3.selectAll('.nodes').remove(); manualStop = false; simulation.stop(); p1 = performance.now(); function distance (s, t) { return distanceFunction(s, t, props, norm); } let forceSample = d3.forceNeighbourSampling() .neighbourSize(NEIGHBOUR_SIZE) .sampleSize(SAMPLE_SIZE) .stableVelocity(0) // Change here .distance(distance); let forceFull = d3.forceNeighbourSampling() .neighbourSize(FULL_NEIGHBOUR_SIZE) .sampleSize(FULL_SAMPLE_SIZE) .stableVelocity(0) // Change here .distance(distance); let hybridSimulation = d3.hybridSimulation(simulation, forceSample, forceFull) .sampleIterations(ITERATIONS) .fullIterations(FULL_ITERATIONS) .numPivots(PIVOTS ? NUM_PIVOTS : -1) .interpFindTuneIts(INTERP_ENDING_ITS) .interpDistanceFn(distance) .on('sampleTick', ticked) .on('fullTick', ticked) .on('startInterp', startedFull) .on('end', ended); let sample = hybridSimulation.subSet(); addNodesToDOM(sample); hybridSimulation.restart(); function startedFull () { console.log('startedFull'); d3.selectAll('.nodes').remove(); addNodesToDOM(nodes); } }