public void Finds_shortest_paths_in_complex_maps(Map map, string startId, string endId, string expectedPath, int expectedDistance) { var shortestPath = new ShortestPathAlgorithm(); Path path = shortestPath.Find(map, startId, endId); if (expectedPath == null) { Assert.Null(path); } else { Assert.Equal(expectedPath, string.Join(',', path.NodeIds)); Assert.Equal(expectedDistance, path.Distance); } }
public void Finds_shortest_path_between_two_points_with_one_edge() { Map map = new Map("t1", new Node("a"), new Node("b")); map.AddEdge("a", "b", 1); var shortestPath = new ShortestPathAlgorithm(); Path p = shortestPath.Find(map, "a", "b"); Assert.Equal(2, p.NodeIds.Length); Assert.Equal("a", p.NodeIds.ElementAt(0)); Assert.Equal("b", p.NodeIds.ElementAt(1)); Assert.Equal(1, p.Distance); }