public void generateChildren(Node parent, string t, Queue<Node> queue) { string s = parent.word; List<string> lstWords = dict.Keys.ToList(); foreach (string word in lstWords) { if (dict[word]) continue; if (IsSimilar(word, s)) { dict[word] = true; Node n = new Node(word, parent); queue.Enqueue(n); if (word == t) { target = n; return; } } } }
public Node(string w, Node p) { this.word = w; this.parent = p; }
public GraphLadder(string source) { root = new Node(source); dict = DictionaryWords.getInstance(source.Length).getDict(); }
private void printLadder(Node n) { while (n != null) { Console.WriteLine(n.word); n = n.parent; } }