Exemple #1
0
        public void ToString_error()
        {
            Graph1 g = new Graph1();

            g.AddNode("Kyiv");
            g.AddNode("Lviv");
            Assert.AreEqual("Kyiv Lviv ", g.ToString());
        }
Exemple #2
0
        private static void TremauxExecution()
        {
            Graph1 <char> Tremaux = new Graph1 <char>();

            Tremaux.AddEdge('A', 'B', true);
            Tremaux.AddEdge('A', 'C', true);
            Tremaux.AddEdge('A', 'E', true);
            Tremaux.AddEdge('B', 'D', true);
            Tremaux.AddEdge('B', 'F', true);
            Tremaux.AddEdge('C', 'G', true);
            Tremaux.AddEdge('E', 'F', true);

            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("Printing Whole Graph:\n" + Tremaux.ToString());
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");

            Console.WriteLine("\n**** DFS iterative ****\n");
            Tremaux.DFS('A');
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("\n**** DFS recursive ****\n");
            Tremaux.DFS('A', true);
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("\n**** BFS ****\n");
            Tremaux.BFS('A');
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("\n**** Spanning Tree ****\n");
            Tremaux.FindSpanningTree();
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.Write("Is it cyclic? ");
            var i = Tremaux.IsCyclic();

            if (i)
            {
                Console.Write("Yes.");
            }
            else
            {
                Console.Write("No.");
            }
            Console.WriteLine("\nLast Line");
            Console.ReadLine();
        }
Exemple #3
0
        public void ToStringEmpty_error()
        {
            Graph1 g = new Graph1();

            Assert.Throws(typeof(InvalidOperationException), () => g.ToString());
        }
Exemple #4
0
        public void ToStringNull_error()
        {
            Graph1 g = null;

            Assert.Throws(typeof(NullReferenceException), () => g.ToString());
        }