Problem with ValidCycle and SubGraph

Hello,

I have the following problem : In a document, I have a subgraph with a port on its frontier. There can be no links between the inside and the outside of the subgraph, all links must pass through this frontier port.

All worked fine, until I set the ValidCycle property to GoDocumentValidCycle.NotDirected so as to prevent cycles in my graph.

If I have two components A and B inside my subgraph, I can link B output to this frontier port. However, as soon as I connect A output with B input, I can no longer link B output to the subgraph port. It looks like A being part of the subgraph, linking B to the subgraph too would produce an cycle.

Is there any way to correct this behaviour ?

Regards,

I just tried what I think is your situation, and didn’t have a problem. I must not be understanding the circumstances you have.
It is true that all ports on nodes contained by a subgraph are considered to be part of the subgraph. Furthermore, links going from a port on a node to a port (whether the same port or a different port doesn’t matter) on the same node would constitute a cycle.
So I could see if there were already a link from the GoSubGraph.Port to node A, and from node A to node B, that you then couldn’t link from node B to the GoSubGraph.Port.
I suppose you could override GoPort.IsValidLink to do the cycle check yourself, rather than depending on the implementation of GoDocument.MakesDirectedCycle.
An alternative that I haven’t tried would be to override GoSubGraph.Destinations to just return the value of GoSubGraph.ExternalDestinations. Same thing for the Sources and Nodes properties, to return the “External” enumerators. You could do this just because your application makes sure there are never any links directly between subgraph nodes and nodes outside that subgraph. I’m not certain this will work, but it would be trivial for you to try.

Here is the picture to explain my problem better:




When I try to link B output to the subgraph output, it fails.
When I try to link the subgraph input to A input, it works.
When I try to link A output to the subgraph output, it works.
When I remove the link between A and B, linking B output to the subgraph output works, as well as when I remove the ValidCycle = GoDocumentValidCycle.NotDirected; in my code.

I tried overloading GoSubGraph.XXX with GoSubGraph.ExternalXXX, but it did not change anything in this matter.

I'd like to avoid having to reimplement GoDocument.MakesDirectedCycle completely if possible, do you have any idea what could be done ?

I think you need to reimplement the GoPort.IsValidLink check, because the following two situations are precisely the same with respect to graph cycles. The only difference is that in the bottom case the two nodes aren’t children of the subgraph.

I’ll send you our code, to make it easy for you to override GoPort.IsValidLink.

I achieved implementing an algorithm that suits our definition of what is a cycle, thanks to your help.

Regards,