How to create a link that doesn't affect the layout?

I have a LayeredDigraphLayout and I’m generally happy with its default look. I want to now add some links that are only conditionally visible and which do not affect the layout of the diagram at all. How can I do this? I have an example in a jsfiddle: https://jsfiddle.net/cfarmerga/43gmo81r/8/

let links = [ 
	{ from: 'one', to: 'two' },
  { from: 'two', to: 'three' },
  { from: 'two', to: 'four' },
  { from: 'three', to: 'five' },
  { from: 'four', to: 'six' },
  
  // I want the below link to not affect the layout at all.
  // I like the layout when it's commented-out, and I want to retain
  // the same node/link positions when this below link is present.
  { from: 'four', to: 'three', custom: true }	
];

let linkTemplate = $(go.Link, $(go.Shape, {
	},
	new go.Binding('isLayoutPositioned', '', data => !data.custom),
	new go.Binding('visible', '', data => !data.custom),
);

When I comment out the last link, in my example, the node layout is what I prefer. I want to include that last link and show it sometimes, but I just don’t want it to affect any existing positioning. I thought just setting isLayoutPositioned to false for this link would work, but apparently not. How can I include this link without having its presence move my nodes around?

Part.isLayoutPositioned is indeed the relevant property for controlling whether the layout considers the Part (the Link in this case) or not.

I’m wondering, though, since the order in which Bindings are evaluated is not defined, whether changing the visibility of the link to false might happen before isLayoutPositioned is set to false. That order might invalidate the layout. Perhaps you can get around that problem by setting https://gojs.net/latest/api/symbols/Part.html#layoutConditions to flags that exclude Part.LayoutShown and Part.LayoutHidden.

BTW, the Bindings will be more efficient if written:

	new go.Binding('isLayoutPositioned', 'custom', c => !c),
	new go.Binding('visible', 'custom', c => !c),

Ah, thank you. It looks like in my case I was accidentally setting the isLayoutPositioned binding on the shape rather than the link, and when I moved it to the Link, it behaved as I wanted it to.

In that case you should have received warnings in the console output about that incorrect Binding.