public static void Main()
        {
            Lab05TestModule tests = new Lab05TestModule();

            tests.PrepareTestSets();
            foreach (var ts in tests.TestSets)
            {
                ts.Value.PerformTests(false);
            }
        }
예제 #2
0
        public static void Main()
        {
            DateTime startTime = DateTime.Now;

            Lab05TestModule tests = new Lab05TestModule();

            tests.PrepareTestSets();
            foreach (var ts in tests.TestSets)
            {
                ts.Value.PerformTests(false);
            }

            DateTime stopTime = DateTime.Now;
            TimeSpan roznica  = stopTime - startTime;

            Console.WriteLine("Czas pracy:" + roznica.TotalMilliseconds);
        }
예제 #3
0
        public static void Main()
        {
            //1
            //var g = new AdjacencyMatrixGraph(true, 4);
            //g.AddEdge(0, 1);
            //g.AddEdge(1, 3);
            //g.AddEdge(3, 0);
            //g.AddEdge(1, 2);

            //4
            //var g = new AdjacencyMatrixGraph(true, 5);
            //g.AddEdge(0, 1);
            //g.AddEdge(1, 2);
            //g.AddEdge(2, 0);
            //g.AddEdge(1, 3);
            //g.AddEdge(3, 4);
            //g.AddEdge(4, 1);

            //2
            var g = new AdjacencyMatrixGraph(true, 4);

            //g.AddEdge(0, 1);
            //g.AddEdge(1, 4);
            //g.AddEdge(4, 5);
            //g.AddEdge(5, 6);
            //g.AddEdge(5, 7);
            //g.AddEdge(1, 2);
            //g.AddEdge(2, 3);
            //g.AddEdge(3, 1);

            g.AddEdge(0, 1);
            g.AddEdge(1, 2);
            g.AddEdge(2, 3);
            g.AddEdge(0, 2);
            g.AddEdge(0, 3);
            g.AddEdge(1, 3);
            g.AddEdge(3, 1);

            var st = new Stack <int>();

            g.GeneralSearchAll <EdgesStack>(
                v => {
                st.Push(v);

                Console.WriteLine($"Pre: {v}, Stack Size: {st.Count}");
                return(true);
            },
                v =>
            {
                var tmpp = st.Pop();

                Console.WriteLine($"Post: {v}, Stack Size: {st.Count}, Popped: {tmpp}");
                return(true);
            }
                ,
                e =>
            {
                Console.WriteLine($"({e.From}, {e.To})");

                if (st.Contains(e.To))
                {
                    return(false);
                }

                return(true);
            }, out int cc);

            RoutePlanner.print(st.ToArray());

            //5
            //var g = new AdjacencyListsGraph<HashTableAdjacencyList>(true, 4);
            //g.AddEdge(0, 1);
            //g.AddEdge(1, 2);
            //g.AddEdge(2, 3);
            //g.AddEdge(0, 2);
            //g.AddEdge(0, 3);
            //g.AddEdge(1, 3);
            //g.AddEdge(3, 1);

            //wisząca krawedź
            //var g = new AdjacencyMatrixGraph(true, 6);
            //g.AddEdge(0, 1);
            //g.AddEdge(1, 2);
            //g.AddEdge(2, 4);
            //g.AddEdge(4, 0);
            //g.AddEdge(2, 3);
            //g.AddEdge(3, 5);


            //
            //var g = new AdjacencyListsGraph<HashTableAdjacencyList>(true, 7);
            //g.AddEdge(0, 2);
            //g.AddEdge(2, 3);
            //g.AddEdge(3, 5);
            //g.AddEdge(5, 6);
            //g.AddEdge(6, 1);
            //g.AddEdge(1, 2);
            //g.AddEdge(1, 3);
            //g.AddEdge(3, 4);
            //g.AddEdge(4, 1);
            //g.AddEdge(2, 6);
            //g.AddEdge(6, 0);
            //g.AddEdge(6, 2);

            var a = new RoutePlanner();

            //int[] cycle = a.FindCycle(g);

            //RoutePlanner.print(cycle);

            //for (int i = 0; i < cycle.GetLength(0); i++)
            //{
            //    RoutePlanner.print(cycle[i]);
            //}
            //Console.WriteLine("");

            //foreach (int i in cycle)
            //{
            //    Console.Write($"{i}, ");
            //}
            //Console.WriteLine("");


            //int[] a = null;
            //if(a == null)
            //{
            //    Console.WriteLine("jest null");
            //}


            //var d = new int[] { 1,2,4,6,5,3 };

            //var b = new int[] { 7,2,8,6,9 };


            var d = new int[] { 3, 5, 6, 1, 3, 4, 1, 2, };

            var b = new int[] { 0, 2, 6 };

            //var merged = a.MergeCycles(d, b);



            //foreach (var i in merged)
            //{
            //    Console.Write($"{i}, ");
            //}
            //Console.WriteLine();

            //var c = d.Intersect(b);

            //foreach(var i in c)
            //{
            //    Console.Write($"{i}, ");
            //}
            //Console.WriteLine();


            //for(int i = 0; i<5; i++)
            //{
            //    for (int j = 0; j < 5; j++)
            //    {
            //        if(i == 4)
            //        {
            //            continue;
            //        }

            //        Console.WriteLine($"Current i: {i}, j: {j}");

            //    }
            //}


            Lab05TestModule tests = new Lab05TestModule();

            tests.PrepareTestSets();
            foreach (var ts in tests.TestSets)
            {
                ts.Value.PerformTests(false);
            }



            //var z = new Stack<int>();

            //z.Push(1);
            //z.Push(2);
            //z.Push(3);
            //z.Push(4);
            //z.Push(5);
            //Console.WriteLine($"First {z.First()}, last: {z.Last()}");
            //z.Pop();
            //Console.WriteLine($"First {z.First()}, last: {z.Last()}");
        }