Creating same link between the nodes

I have nodes that needs to be linked once. But the same link is being created over and over. As you can see test1 is linked test2 twice, instead of just once. And when test1 is linked to the test2, there is no need to link test2 to test1 again.

linkDataArray representing this image is;

{ from: 1, to: 2 },
{ from: 1, to: 2 },
{ from: 2, to: 1 }

but I need just one { from: 1, to: 2 } and no { from: 2, to: 1 }.

Can anyone help me about this? Thanks.

You need to make sure there are no undesired data objects in the GraphLinksModel.linkDataArray.

Each object in that Array will result in a separate Link in the Diagram.

Hello walter, thank you for your quick answer.

I’m pushing link data to linkDataArray with a loop (poorly written), I’ve been wondering if there’s a property to avoid this.

Thanks again.

No, sorry – there is no way for GoJS to guess what you want and what you don’t want. Many apps will want to have and show those duplicate and reverse links.

There are ways to control what users can draw.
https://gojs.net/latest/intro/permissions.html
https://gojs.net/latest/intro/validation.html
But there are no restrictions on what your code can do.

Oh, okay. Thanks again, have a nice day.