// // }))
// // .force("charge", d3.forceManyBody().strength(0))
// // .force('y', d3.forceY().y(d => d.y))
// // .alphaDecay(0.0002)
// // .nodes(data2)
// // .on("tick", ticked);
// if (kf >= 10) {
// simulation.force("x", d3.forceX(0).strength(1))
// .force("y", d3.forceY(0).strength(1));
// // simulation.nodes().map(function(d){
// // d.x = -100; // Set fixed x-coordinate
// // d.y = -100; // Set fixed y-coordinate
// // // simulation.alpha(1).restart();
// // });
// }
// // Select the already existing nodes ("g") and edges ("line") if they exist
// // Set their data to the new, updated dynamicData
// let node = svg.selectAll(".node")
// .data(data2)
// // .data(simulation.nodes())
// let g = node.enter()
// .append("g")
// .attr("class", "node")
// .attr("transform", d => `translate(${d.x},${d.y})`);
// // g.append("circle")
// // .attr("r", d => d.r)
// // .style("fill", "#d9d9d9");
// g.append("path")
// .attr('class','child-path')
// .attr('d', function (d) {
// var arc = 2 * Math.PI / d.children.length,//Point spacing along circle
// data = d.children
// .map(function (t, i) {
// return [i * arc, d.r * t.length];
// })
// return line(data);
// })
// .attr("stroke","black")
// .attr("stroke-width", strokeWidth);
// // Create a text element for displaying alpha
// const alphaText = svg.append("text")
// .attr("id", "alphaText")
// .attr("x", 10)
// .attr("y", 20)
// .style("font-size", "14px")
// .style("fill", "black")
// .text(`Alpha: ${simulation.alpha().toFixed(3)}`);
// // simulation.on('tick', ticked);
// // setInterval(() => {
// // // simulation.tick();
// // // ticked();
// // // setTimeout(() => {
// // // let i = data2.length;
// // if (data2.length < 700) {
// // for (let i=0; i<5; i++){
// // let j = Math.round(Math.random() * (data.length-1))
// // data2.push(data[j]);
// // };
// // };
// // // console.log(data2.slice(-5))
// // node = node.data(data2);
// // simulation.nodes(data2);
// // // // Enter any new nodes
// // let nodeEnter = node.enter()
// // .append("g")
// // .attr('class', 'node');
// // nodeEnter.append("path")
// // .attr('class','child-path')
// // .attr('d', function (d) {
// // var arc = 2 * Math.PI / d.children.length,//Point spacing along circle
// // data = d.children
// // .map(function (t, i) {
// // return [i * arc, d.r * t];
// // })
// // return line(data);
// // })
// // .attr("stroke","black")
// // .attr("stroke-width", strokeWidth);
// // // nodeEnter.append('circle')
// // // .style("fill", "#d9d9d9")
// // // .transition().ease(d3.easeElasticOut)
// // // .attr("r", d => d.r)
// // node = nodeEnter.merge(node);
// // // nodeEnter.exit().remove();
// // // console.log(simulation.alpha())
// // simulation.alpha(0.3).restart();
// // }, 50)
// // console.log(simulation.alpha())
// // update each node upon simulation tick
// // simulation.on("tick", () => {
// // d3.select("#alphaText").text(`Alpha: ${simulation.alpha().toFixed(3)}`);
// // svg.selectAll(".node")
// // // .attr("transform", d => `translate(${d.x},${d.y}) skewX(30)`)
// // .attr("transform", d => `translate(${d.x},${d.y})`);
// // // .attr("cx", d => d.x)
// // // .attr("cy", d => d.y);
// // svg.selectAll(".child-path")
// // .attr('d', function (d) {
// // var arc = 2 * Math.PI / d.children.length,//Point spacing along circle
// // data = d.children.map(function (t, i) {
// // return [i * arc, d.r * t.length];
// // });
// // return line(data);
// // });
// // })
// // merge the new edges with the existing edges
// // edges = edges.merge(enterEdges);
// // function ticked() {
// // // console.log(simulation.alpha())
// // // tick++
// // // console.log(tick)
// // // edges
// // // .attr("x1", d => d.source.x)
// // // .attr("y1", d => d.source.y)
// // // .attr("x2", d => d.target.x)
// // // .attr("y2", d => d.target.y);
// // // dynamicData.forEach(d => {
// // // // You can adjust the rate of movement by changing the factor (e.g., 0.05)
// // // d.targetY = d.targetY ? d.targetY - 0.5 : d.y;
// // // });
// // // simulation.force('y', d3.forceY().y(d => d.targetY));
// // });
// // };
// return svg.node();
// }