network = {
const links = data.links.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));
const simulation = d3.forceSimulation(nodes)
.force("center", d3.forceCenter().x(width/2).y(height/2))
.force("link", d3.forceLink(links).id(d => d.id))
.force("charge", d3.forceManyBody().strength(-edgelength))
.force("x", d3.forceX())
.force("y", d3.forceY());
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.style("font", "14px sans-serif");
const link = svg.append("g")
.attr("fill", "none")
.selectAll("path")
.data(links)
.join("path")
.attr("class", "tooltip")
.attr("stroke", "green")
.attr("stroke-width", d => 2*node_ff*Math.sqrt(d.n))
.attr("stroke-opacity", 0.25)
.attr("data-tippy-content", d => `${d.s} ↔ ${d.t}<br>${d.n} co-occurrences`)
const node = svg.append("g")
.attr("fill", "currentColor")
.attr("stroke-linecap", "round")
.attr("stroke-linejoin", "round")
.selectAll("g")
.data(nodes)
.join("g")
.call(drag(simulation));
node.append("circle")
.attr("class", "tooltip")
.attr("stroke", "none")
.attr("r", d => node_ff*Math.sqrt(d.n))
.attr("data-tippy-content", d => `${d.id}<br>${d.n} issues`)
node.append("text")
.attr("x", d => 15 + 0.6*node_ff*Math.sqrt(d.n))
.attr("y", "0.35em")
.text(d => d.id)
.clone(true).lower()
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-width", 4);
simulation.on("tick", () => {
link.attr("d", linkArc);
node.attr("transform", d => `translate(${d.x},${d.y})`);
});
invalidation.then(() => simulation.stop());
return svg.node();
}