Exemple #1
0
        static void Main(string[] args)
        {
            string fileTwoWords   = "input.txt";
            string fileDictionary = "dictionary.txt";

            StreamReader sr = new StreamReader(fileTwoWords, Encoding.GetEncoding(1251));

            string[] readedResult = sr.ReadToEnd().Split('\n');

            string wordFirst  = readedResult[0].Trim();
            string wordSecond = readedResult[1].Trim();

            sr = new StreamReader(fileDictionary, Encoding.GetEncoding(1251));

            readedResult = sr.ReadToEnd().Split('\n');
            sr.Close();

            List <Node> nodes = new List <Node>();

            foreach (string word in readedResult)
            {
                NodesFabric.getInstance().createNewNode(word.Trim());
            }

            NodesFabric.getInstance().transformNodesByRelations();

            RelationsCombainer.findPaths(wordFirst, wordSecond);

            Console.ReadKey();
        }
        public static NodesFabric getInstance()
        {
            if (instance == null)
            {
                instance = new NodesFabric();
            }

            return(instance);
        }
Exemple #3
0
        public static NodesFabric getInstance()
        {
            if(instance == null)
            {
                instance = new NodesFabric();
            }

            return instance;
        }
Exemple #4
0
        public static void findPaths(string wordFirth, string wordSecond)
        {
            var nodeStart = NodesFabric.getInstance().find(wordFirth); //.GetHashCode()];

            var nodeEnd = NodesFabric.getInstance().find(wordSecond);  //.GetHashCode()];

            if (nodeStart == null || nodeEnd == null)
            {
                throw new Exception("Ошибочка в поиске");
            }

            var tmpPath    = new Path();
            var removePath = new Path();

            start(ref nodeStart, nodeStart, ref nodeEnd, tmpPath);
        }