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); }
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); }
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); }
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"); }
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); }
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>()); }
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); }
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()); }
public RouteFinderTest() { IMatrix matrix = new StandardMatrix("AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7"); finder = new RouteFinder(matrix); }