/** * Initialize the link force algorithm and start simulation. */ function startLinkSimulation() { console.log("startLinkSimulation") springForce = false; simulation.stop(); p1 = performance.now(); let links = []; // Initialize link array. nodes = simulation.nodes(); for (i = 0; i < nodes.length; i++) { for (j = 0; j < nodes.length; j++) { if (i !== j) { links.push({ source: nodes[i], target: nodes[j], }); } } } // Add the links to the simulation. simulation.force(forceName, d3.forceLink().links(links)); simulation .alphaDecay(1 - Math.pow(0.001, 1 / ITERATIONS)) .force(forceName) // The distance function that will be used to calculate distances // between nodes. .distance(function (n) { return distanceFunction(n.source, n.target, props, norm); }) // Set the parameter for the algorithm (optional). .strength(1); // Restart the simulation. simulation.alpha(1).restart(); }