Description
Sets up the internal cycle graph in order to find and label all nodes which cause circular references. The cycle information is kept within the graph, like a cache. An internal dirty bit indicates when the graph has changed, so that the cycle information needs to be updated. So, it is important to call FindCycles() whenever changes might have occured in the graph, before accessing any of the cycle information functions, such as GraphNode.IsCycleNode(). Calling FindCycles() when the graph has not changed simply checks the existing information, and is efficient.
Cycles are detected by trimming away all leaf nodes (with no outgoing references) until there is nothing left in the cycle graph. If all leaf nodes are gone, but there are still nodes in the graph, then those nodes must comprise a cycle.
Normally, callers do not supply any node. This means that the function will examine the entire graph for leaf nodes, and prune it from that list. However, in BreakCycles(), a single reference is cut, so it calls FindCycles() with the node whose outgoing reference was just cut. Since we then know that the node whose outgoing reference was cut is the only possible leaf node in the graph, that node is passed in, so that the search for leaf nodes is skipped. Callers should not supply a node parameter unless it is known that the node passed in is the only leaf in the graph.
Visual Basic
Public virtual Function FindCycles( start As GraphNode ) As bool
C#
public virtual bool FindCycles( GraphNode start );
Parameters
| Parameters | Description |
|---|---|
| GraphNode start | Input node to begin the search for cycles at. Usually defaulted to NULL. |