Esempio n. 1
0
        public int Weight()
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            Assert.Throws <ArgumentException>(() => matrix.Weight("AA", "BBB"));
            return(-1);
        }
Esempio n. 2
0
        public int Weight(int source_idx, int target_idx)
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            matrix.Weight(source_idx, target_idx);
            return(-1);
        }
Esempio n. 3
0
        public int Weight(string source_name, string target_name)
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            Assert.Equal(5, matrix.Weight(source_name, target_name));
            return(-1);
        }
Esempio n. 4
0
        public string NameOf(int nodeIdx)
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            Assert.Equal("A", matrix.NameOf(nodeIdx));
            return("A");
        }
Esempio n. 5
0
        public int IndexOf(char nodeName)
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            Assert.Equal(0, matrix.IndexOf(nodeName));
            return(-1);
        }
Esempio n. 6
0
        public IEnumerable <int> GetRow(int idx)
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            Assert.NotEmpty(matrix.GetRow(idx));
            return(Enumerable.Empty <int>());
        }
Esempio n. 7
0
        public void ConstructorEdges()
        {
            var edges = new List <Edge>()
            {
                new Edge {
                    Source = 'A', Target = 'B', Weight = 5
                },
                new Edge {
                    Source = 'B', Target = 'C', Weight = 4
                },
            };
            var mat = new StandardMatrix(edges);

            Assert.Equal(3, mat.Count);
        }
Esempio n. 8
0
        public static void Main(string[] args)
        {
            Action <object> cw = (obj) => Console.WriteLine(obj.ToString());

            cw("-----");

            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            // Calculate distances
            cw("#1 " + new Route("ABC", matrix));
            cw("#2 " + new Route("AD", matrix));
            cw("#3 " + new Route("ADC", matrix));
            cw("#4 " + new Route("AEBCD", matrix));
            cw("#5 " + new Route("AED", matrix));
            var finder = new RouteFinder(matrix);

            // Output 6 -> 2
            cw("---");
            var routes = finder.GetRoutesWithLessOrMaxStops("C", "C", 3);

            cw("#6 " + routes.Select(x => x.ToString()).Aggregate((current, next) => current + "\n#6 " + next));
            // Output 7 -> 3
            cw("---");
            routes = finder.GetRoutesWithMaxStops("A", "C", 4);
            cw("#7 " + routes.Select(x => x.ToString()).Aggregate((current, next) => current + "\n#7 " + next));
            cw("---");
            // Output 8,9 -> 9
            var route = finder.GetShortestRoute("A", "C");

            cw("#8 " + route);
            route = finder.GetShortestRoute("B", "B");
            cw("#9 " + route);

            // Output 10
            routes = finder.GetRoutes("C", "C", 30);
            cw("#10 Number of routes C to C with distance 30 " + routes.Count());
        }
Esempio n. 9
0
        public RouteFinderTest()
        {
            IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7");

            finder = new RouteFinder(matrix);
        }