How to avoid recursive linking to a node

I have a scenario only “to” or “from” can be done from 1 to 1 relationship. Refer bellow image. Here six and seven have recursive links. I just want to avoid 1 link either “to” or “from” can be done. if i have done to then you can’t do from.

I have tried below code but this is not useful.
this.diagram.validCycle = go.Diagram.CycleDestinationTree;

Reger below image - this is not working with above code.

As shown at GoJS Validation -- Northwoods Software, which also sets Diagram.validCycle to go.Diagram.CycleDestinationTree, I think it does what you want. Did you not observe any change in what links the user could draw between before and after setting that validCycle property?

Hi walter, Thanks for your quick reply, but i have mentioned it in my query right. Refer my 2nd image i have connected two to four and three to four. But with ValidCycle Which is not possible. Please let me know if i misunderstood.

this.diagram.validCycle = go.Diagram.CycleNotUndirected; resolved the issue , Thanks Walter :)