private void RecursiveSearch(Node node, List<Dna> rtn, Dna word, uint d) { var curDist = LevenshteinDistance(node.Word, word); var minDist = Math.Max(0,(int)curDist - (int)d); var maxDist = curDist + d; if (curDist <= d) rtn.Add(node.Word); foreach (var key in node.Keys.Cast<uint>().Where(key => minDist <= key && key <= maxDist)) { RecursiveSearch(node[key], rtn, word, d); } }
public void Add(Dna word) { if (_root == null) { _root = new Node(word); return; } var curNode = _root; var dist = LevenshteinDistance(curNode.Word, word); while (curNode.ContainsKey(dist)) { if (dist == 0) return; curNode = curNode[dist]; dist = LevenshteinDistance(curNode.Word, word); } curNode.AddChild(dist, word); }
public void AddChild(uint key, Dna word) { if (Children == null) Children = new HybridDictionary(); Children[key] = new Node(word); }