Пример #1
0
        public static void Main()
        {
            /*
             * string str1 = "1 2 2 3 3 4 2 5";
             * Graph graph1 = new Graph(str1.StrToGraph());
             *
             * foreach (var item in graph1.GetNodes())
             *  Console.WriteLine(item);
             *
             * string str2 = "1 2 2 3 2 4 3 6 1 6";
             * Graph graph2 = new Graph(str2.StrToGraph());
             *
             * Graph graph3 = graph1 + graph2;
             *
             * foreach (var item in graph1.GetNodes())
             *  Console.WriteLine(item);
             * foreach (var item in graph1.GetNodes())
             * {
             *  Console.WriteLine(item);
             *  IArc[] arcs;
             *  if (graph1.TryGetArcs(item, out arcs))
             *      foreach (var element in arcs)
             *          Console.WriteLine(element);
             *  else
             *      Console.WriteLine("no arcs");
             * }*/

            Components a = new Components();

            a.AddArc(new Arc(new Node(1), new Node(2)));
            a.AddArc(new Arc(new Node(1), new Node(3)));
            a.RemoveArc(new Arc(new Node(1), new Node(2)));
            a.AddArc(new Arc(new Node(4), new Node(5)));
            var b = a.AllNodes(1);

            foreach (var item in b)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }