Esempio n. 1
0
        static void Main(string[] args)
        {
            String input  = Console.ReadLine(),
                   output = Console.ReadLine();

            try {
                Str[][] origin = new MatrixReader <Str>(input).GetResult(),
                result = FloydWarshallExecutor <Str> .Execute(new Matrix <Str>(origin), new StrSemigroup()).GetTable();

                MatrixWriter <Str> .WriteMatrix(result, output);
            } catch (ArgumentException exception) {
                Console.WriteLine(exception.Message);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            String input   = Console.ReadLine(),
                   output  = Console.ReadLine(),
                   dotfile = output + ".tmp";

            try {
                Boolean[][] origin = new MatrixReader <Boolean>(input).GetResult(),
                result = FloydWarshallExecutor <Boolean> .Execute(new Matrix <Boolean>(origin), new BooleanSemigroup()).GetTable();

                DotMediator.CreateDot(origin, result, dotfile);
                DotMediator.ProcessDot(dotfile, output);
                File.Delete(dotfile);
            } catch (Exception exception) {
                Console.WriteLine(exception.Message);
            }
        }
        public void TestFW()
        {
            Matrix <Str> origin = new Matrix <Str>(new Str[][] {
                new Str[] { new Str("infty"), new Str("bb"), new Str("lool") },
                new Str[] { new Str("infty"), new Str("infty"), new Str("a") },
                new Str[] { new Str("lool"), new Str("a"), new Str("infty") }
            }),
                         result = FloydWarshallExecutor <Str> .Execute(origin, new StrSemigroup());

            Str[][] expected = new Str[][] {
                new Str[] { new Str("infty"), new Str("bb"), new Str("bba") },
                new Str[] { new Str("infty"), new Str("aa"), new Str("a") },
                new Str[] { new Str("lool"), new Str("a"), new Str("aa") }
            };
            int i, j;

            for (i = 0; i < expected.Length; ++i)
            {
                for (j = 0; j < expected.Length; ++j)
                {
                    Assert.AreEqual(expected[i][j].value, result[i, j].value);
                }
            }
        }