Esempio n. 1
0
        public static bool LogicTest_NotOk()
        {
            var            ts = new TopologicalSort <string>();
            Queue <string> outQueue;

            bool returnValue;

            ts.Edge("a", "b");
            ts.Edge("a", "c");

            ts.Edge("c", "d");
            ts.Edge("c", "e");

            ts.Edge("e", "a");

            returnValue = ts.Sort(out outQueue);

            Console.WriteLine(" should get a cycle of (a c e)");

            while (outQueue.Count != 0)
            {
                Console.WriteLine(" > {0}", outQueue.Dequeue());
            }

            Console.WriteLine("Expected false, got {0}, success = {1}",
                              returnValue, !returnValue);

            return(returnValue);
        }
Esempio n. 2
0
        /*
         * a = b + c
         * c = d + e
         *
         * should get b d e c a (or d e c b a)
         */
        public static bool LogicTest_OK()
        {
            var            ts = new TopologicalSort <string>();
            Queue <string> outQueue;

            bool returnValue;

            ts.Edge("a", "b");
            ts.Edge("a", "c");

            ts.Edge("c", "d");
            ts.Edge("c", "e");

            returnValue = ts.Sort(out outQueue);

            Console.WriteLine(" should get (b d e c a) or (d e c b a)");

            while (outQueue.Count != 0)
            {
                Console.WriteLine(" > {0}", outQueue.Dequeue());
            }

            Console.WriteLine("Expected true, got {0}, success = {1}",
                              returnValue, returnValue);

            return(returnValue);
        }