private Boolean TryRelateWithExistPathToEnd(RelatedNode currentNode, String word) { foreach (var startNode in GetStartNodesArriveToEnd(word.Length)) { if (startNode.ExistPathToEnd(word)) { currentNode.RelateWithNext(startNode, word.First()); return(true); } } return(false); }
public void AddBranch(String word) { RelatedNode currentNode = startNode; foreach (var symbol in word) { var nextNode = currentNode.GetRelatedNodeByOutput(symbol); if (nextNode == null) { nextNode = CreateNode(); currentNode.RelateWithNext(nextNode, symbol); } currentNode = nextNode; } }