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("x", d3.forceX().strength(xStrength))
.force("y", d3.forceY().strength(yStrength));
for(let i = 0; i < numTicks; i++) {
simulation.tick()
steps.push({
nodes: nodes.map(({x, y, id, group}) => ({x, y, id, group})),
links: links.map(({source,target, value}) => {
return {
value,
source: {x:source.x , y:source.y},
target: {x:target.x , y:target.y}
}
})
})
}
simulation.stop()
return steps
}