public bool TarjanAlgStep(StoryNode checkedNode, ref string[] colors, bool duplicated, StoryNode duplicatedNode) { bool result = true; colors[checkedNode.GetNumberInSequence()] = "grey"; foreach (StoryNode nextNode in checkedNode.GetLinks()) { if (!result) { return(result); } if (colors[nextNode.GetNumberInSequence()] == "grey") { if (duplicated) { if (duplicatedNode.Equals(nextNode)) { bool test = true; } } if (checkedNode.isChildren(nextNode) && !duplicated) { continue; } else if (duplicated && checkedNode.isChildren(nextNode) && !duplicatedNode.Equals(nextNode)) { continue; } result = false; return(result); } else if (colors[nextNode.GetNumberInSequence()] == "black") { continue; } else { result = TarjanAlgStep(nextNode, ref colors, duplicated, duplicatedNode); if (!result) { return(result); } } } colors[checkedNode.GetNumberInSequence()] = "black"; return(result); }