/// <summary> /// Checks if 'node' can be added to 'link' without /// violating any conditions pertaining to dangling links. /// Returns null if loop is found or length exceeds threshold. /// Otherwise, adds node to link and returns. /// </summary> /// <param name="link">Dangling link.</param> /// <param name="node">Node to be added.</param> /// <param name="reachedErrorEndPoint">Indicates if we have reached end of dangling link.</param> /// <returns>Updated dangling link.</returns> private DeBruijnPath CheckAndAddDanglingNode(DeBruijnPath link, DeBruijnNode node, out bool reachedErrorEndPoint) { if (this.erodeThreshold != -1 && link.PathNodes.Count == 0 && node.KmerCount < this.erodeThreshold) { if (node.IsMarkedForDelete) { // There is a loop in this link. No need to update link. // Set flag for end point reached as true and return. reachedErrorEndPoint = true; return(link); } else { node.MarkNodeForDelete(); reachedErrorEndPoint = false; return(link); } } if (link.PathNodes.Contains(node)) { // There is a loop in this link. No need to update link. // Set flag for end point reached as true and return. reachedErrorEndPoint = true; return(link); } if (link.PathNodes.Count >= this.LengthThreshold) { // Length crosses threshold. Not a dangling link. // So set reached error end point as true and return null. reachedErrorEndPoint = true; return(null); } // No error conditions found. Add node to link. reachedErrorEndPoint = false; link.PathNodes.Add(node); return(link); }