public void FindNearestPoint()
        {
            var graph = new DirectedGraph(new[] { PointMother.ChannelSt, PointMother.BurchellSt, PointMother.EthelSt });
            var nav = new GraphNavigator(graph, PointMother.ChannelSt, PointMother.ChannelSt, new RoadPathService(GetEmptyRouteCache(), new Mock<ILogService>().Object));

            var nearest = nav.FindNearestPoint(PointMother.ChannelSt);
            Assert.AreEqual(PointMother.EthelSt, nearest);
        }
 protected override void Given()
 {
     var graph = GraphMother.ChannelDelanceyThornlandsBeckwith;
     nav = new GraphNavigator(graph,
         PointMother.ChannelSt, PointMother.ChannelSt,
         new ChannelDelanceyBeckwithThornlandsRoadService());
     cycles = nav.GetCycles();
     //foreach (var c in cycles) { Console.WriteLine(c.ToString()); }
     stitcher = new StitchingService(cycles, graph);
 }
        public void GetCycles_RealRoadService()
        {
            var graph = new DirectedGraph(new[] { PointMother.ChannelSt, PointMother.BurchellSt, PointMother.EthelSt });
            var nav = new GraphNavigator(graph, PointMother.ChannelSt, PointMother.ChannelSt, new RoadPathService(GetEmptyRouteCache(), new Mock<ILogService>().Object));

            var cycles = nav.GetCycles();
            Assert.AreEqual(2, cycles.Count);
            AssertChannelEthelChannelCycle(cycles[0]);
            AssertBurchellBurchellCycle(cycles[1]);
        }
        public void GetCycles_FakeRoadService()
        {
            var graph = new DirectedGraph(new[] { PointMother.ChannelSt, PointMother.BurchellSt, PointMother.EthelSt });
            var nav = new GraphNavigator(graph, PointMother.ChannelSt, PointMother.ChannelSt, new ChannelEthelBurchellRoadService());

            var cycles = nav.GetCycles();
            Assert.AreEqual(2, cycles.Count);
            AssertChannelChannelCycle(cycles[0]);
            AssertBurchellBurchellCycle(cycles[1]);
        }
        public void GetCycles_FakeRoadService_NonCyclic()
        {
            var graph = new DirectedGraph(new[] { PointMother.ChannelSt, PointMother.BurchellSt, PointMother.EthelSt });
            var nav = new GraphNavigator(graph, PointMother.ChannelSt, PointMother.BurchellSt, new ChannelEthelBurchellRoadService());

            var cycles = nav.GetCycles();
            Assert.AreEqual(2, cycles.Count);
            Assert.AreEqual(1, cycles[0].Routes.Count);

            Assert.AreEqual(PointMother.ChannelSt, cycles[0].Routes[0].From);
            Assert.AreEqual(PointMother.BurchellSt, cycles[0].Routes[0].To);
            Assert.AreEqual(PointMother.EthelSt, cycles[1].Routes[0].From);
            Assert.AreEqual(PointMother.EthelSt, cycles[1].Routes[0].To);
        }
        public Directions Optimize(Point[] points)
        {
            DBC.Assert(points.Length > 1, "Unable to optimize a route with less than 2 points.");

            Log(points);

            if (IsSingleRouteDirections(points)) return BuildSingleRouteDirections(points);

            var graph = new DirectedGraph(points);
            var graphNavigator = new GraphNavigator(graph, points.First(), points.Last(), roadPathService);
            IList<Directions> cycles = graphNavigator.GetCycles();
            stitchingService = new StitchingService(cycles, graph);
            var stitched = stitchingService.Stitch();
            stitched.Order(points.First(), points.Last());
            return stitched;
        }
 protected override void Given()
 {
     var graph = GraphMother.ChannelDelanceyThornlandsBeckwith;
     nav = new GraphNavigator(graph,
         PointMother.ChannelSt, PointMother.ChannelSt,
         new ChannelDelanceyBeckwithThornlandsRoadService());
     stitcher = new StitchingService(nav.GetCycles(), graph);
 }
 protected override void Given()
 {
     nav = new GraphNavigator(GraphMother.ChannelDelanceyThornlandsBeckwith,
         PointMother.ChannelSt, PointMother.ChannelSt,
         new ChannelDelanceyBeckwithThornlandsRoadService());
 }
 protected override void Given()
 {
     var graph = new DirectedGraph(new[] { PointMother.ChannelSt, PointMother.BurchellSt, PointMother.EthelSt });
     nav = new GraphNavigator(graph, PointMother.ChannelSt, PointMother.BurchellSt, new ChannelEthelBurchellRoadService());
 }