deconstructed = {
let steps = []
const links = data.links.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));
const simulation = d3.forceSimulation(nodes)
.force("link", d3.forceLink(links).id(d => d.id)
.distance(linkDistance)
)
.force("charge", d3.forceManyBody()
.strength(manyBodyStrength)
.distanceMax(distanceMax)
)
.force("center", d3.forceCenter(width / 2, height / 2));
for(let i = 0; i < numTicks; i++) {
simulation.tick()
const copies = new Map(nodes.map(n => [n, {x: n.x, y: n.y, id: n.id, group: n.group}]));
steps.push({
nodes: Array.from(copies.values()),
links: links.map(({source, target, value}) => {
return {
value,
source: copies.get(source),
target: copies.get(target),
}
})
})
}
simulation.stop()
return steps
}