Double tree add link


We used double-tree in our project to layout the nodes, which is great and satisfied out needs!
However, after we expand our initial tree, we want to add multiple links by triggering some functionality. And we don’t now how to do that.

Here is the code we try to accomplish it, but it act pretty weird:
It only add the very last link to our graph, and sometimes it will change the nodes layout…

       let $$ = go.GraphObject.make;
       let link = $$(go.Link, $$(go.Shape));
       link.fromNode = this.myDiagram.findNodeForKey(v.from);
       link.toNode = this.myDiagram.findNodeForKey(;
       this.myDiagram.commitTransaction("Double Tree Layout");

Thank you for your help!!!

One error is that there needs to be matching calls to startTransaction and commitTransaction.

Another error is that you should call those methods only once each, before and after the loop.

And the most important problem is that the diagram is using a TreeModel, which inherently limits the graph structure to be a tree. That means there can only be at most one link coming into any node. You don’t show the actual diagram and which links are not created, but that is my guess.