Cycle/loop only through a particular node

Hi,
Currently my documents have following property set for not allowing any loop/cycle in the doc.
this.ValidCycle = Northwoods.Go.GoDocumentValidCycle.NotDirected;
How can I allow cycle/loop only through a particular node(ex. loop node) in the document? In other words, only loop node should allow a loop to be formed. All other nodes can be part of the loop but should not allow loop formation.

Either override GoPort.IsValidLink for the port(s) on that node, or override GoToolLinking.IsValidLink, to return true when both ports are in that particular node.
There are some examples of defining custom linking tools, and how to install them in your GoView by replacing the standard ones, in some of the sample applications. Also you can search this forum, for example: http://www.nwoods.com/forum/forum_posts.asp?TID=1558

Thanks for quick reply.
Quick clerification on what I wanted to do.

  1. Allow cycle to form only when toNode is “loop” node otherwise no cycle is allowd. Basically “loop” node controls how many times you can loop. (Basically “loop” node allows to create for/foreach type of constructs…)
    I am overwriting IsValidLink method in linking and relinking. Is there an easy way to find out whether allowing new link will create a cycle? or do I need to traverse through all possible paths from “to node” to determine the cycle?

I’m not sure I understand your requirements, but…
Would it be sufficient for you to override GoToolLinkingNew.IsValidLink to just return true when the toPort argument is in one of your “loop” nodes?

I think it depends on what other checks are performed in the base.IsValidLink method. In short I wanted to do somthing like this.
public override bool IsValidLink(IGoPort fromPort, IGoPort toPort)
{
if (base.IsValidLink(fromPort, toPort) == false)
{
//possible failure is due to cycle/self-cycle.
IGoNode toNode = toPort.Node;
if (((GraphNode)toNode).UserNode.Id == “loop”)
{
//return true if link is causing loop and not self-loop and there is no other
//violations for which base.IsValidLink has returned false
}
else
{
//Link is not valid for all other type of nodes
return false;
}
}
return true;
}