コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
 public Node(string w, Node p)
 {
     this.word = w;
     this.parent = p;
 }
コード例 #3
0
 public GraphLadder(string source)
 {
     root = new Node(source);
     dict = DictionaryWords.getInstance(source.Length).getDict();
 }
コード例 #4
0
 private void printLadder(Node n)
 {
     while (n != null)
     {
         Console.WriteLine(n.word);
         n = n.parent;
     }
 }