score:1

Accepted answer

The problem is in your addNodeAndEdges function. When you're adding new elements to nodes and links, you're creating new objects, rather than referencing existing ones. For example, when you push a link having a source of {id: 1}, that's not the same as having a source of a. When the force simulation sets the x and y attributes of a, the source node of your new link won't also be updated. So the new paths you're adding have no x and y coordinates.

Here's a fiddle that fixes that, by using consistent references to existing objects in addNodeAndEdges.


Related Query