Example #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Hello World!");
            int[ , ] a = Graph.readInputFile (@"../../input.txt");
            Graph gr = new Graph (a);

            string lastLine = "";
            using (StreamReader file = new StreamReader (@"../../input.txt"))
            {
                while (file.EndOfStream == false)
                    lastLine = file.ReadLine();
            }

            string[] mas = lastLine.Split (' ');
            int[] vertices = { int.Parse (mas [0]), int.Parse (mas [1]) };
            gr.Print ();
            Console.WriteLine ("------");
            gr.Connect (vertices [0], vertices [1]);
            gr.Print ();

            Console.WriteLine ("------");

            foreach(int x in gr.GetAdjacentVertices(vertices[0]))
            {
                Console.Write(x + " ");
            }

            Console.WriteLine ();

            foreach(int x in gr.GetAdjacentVertices(vertices[1]))
            {
                Console.Write(x + " ");
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Hello World!");
            string name = "../../input.txt";

            Graph gr = new Graph();
            string[] city_names;
            using (StreamReader file = new StreamReader (name))
            {
                int n = int.Parse (file.ReadLine ());
                city_names = file.ReadLine ().Split(' ');
                int[,] a = new int[n, n];
                for (int i = 0; i < n; i++)
                {
                    string line = file.ReadLine ();
                    string[] mas = line.Split (' ');

                    for (int j = 0; j < mas.Length; j++)
                    {
                        int x = int.Parse (mas [j]);
                        a [i, j] = (x != 0)?x:999;
                    }
                }
                gr.setGraph (a);
            }

            gr.Floyd ();

            int limit = 40;

            foreach(Tuple<int, int, int> r in gr.DistanceLessThan (limit))
            {
                Console.WriteLine("{0} <-> {1}: {2}",city_names [r.Item1], city_names [r.Item2], r.Item3);
            }
        }
Example #3
0
 public static void Main(string[] args)
 {
     Graph g = new Graph (@"/Users/masha/Documents/ssu/c_sharp/Pr16R1ex12/Pr16R1ex12/input.txt");
     g.SearchGm (0);
 }