示例#1
0
 private static void FindWay(string path)
 {
     var graph = new GraphProvider().Load<DijkstraGraph>(path);
     graph.Validate();
     graph.Markup();
     var way = new Dijkstra.Dijkstra()
                           .Compute(graph)
                           .GetShortestWay(graph);
     PrintResults(way);
 }
        public void Validate_Failure_Test(string xml)
        {
            // Arrange
            var graph = new GraphProvider().Load<DijkstraGraph>(xml);
            graph.Validate();
            graph.Markup();
            var dijkstra = new ShortestWay.Dijkstra.Dijkstra();

            // Assert
            dijkstra.Compute(graph).GetShortestWay(graph);
        }
        public void SimpleSample_Test()
        {
            // Arrange
            var graph = new GraphProvider().Load<DijkstraGraph>(@"xml\simple-valid.xml");
            graph.Validate();
            graph.Markup();
            var dijkstra = new ShortestWay.Dijkstra.Dijkstra();

            // Act
            var way = dijkstra.Compute(graph)
                              .GetShortestWay(graph);

            // Assert
            Assert.AreEqual(way[0].Id, 1);
            Assert.AreEqual(way[1].Id, 3);
            Assert.AreEqual(way[2].Id, 5);

            Assert.AreEqual(way.Count, 3);
            Assert.AreEqual((way[2] as DijkstraNode).TotalWeigth, 20);
        }
        public void AcceptanceSample_Test()
        {
            // Arrange
            var graph = new GraphProvider().Load<DijkstraGraph>(@"xml\shortestway-sample.xml");
            graph.Validate();
            graph.Markup();
            var dijkstra = new ShortestWay.Dijkstra.Dijkstra();

            // Act
            var way = dijkstra.Compute(graph)
                              .GetShortestWay(graph);

            // Assert
            Assert.AreEqual(way[0].Id, 1);
            Assert.AreEqual(way[1].Id, 6);
            Assert.AreEqual(way[2].Id, 8);
            Assert.AreEqual(way[3].Id, 9);
            Assert.AreEqual(way[4].Id, 10);

            Assert.AreEqual(way.Count, 5);
            Assert.AreEqual((way[4] as DijkstraNode).TotalWeigth, 22);
        }