Example #1
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);
            }
        }