private void FindAllRoutesCommandExecuted(MapView mapView) { DCGraph.ResetGraph(); //Remove old route graphics RemoveRouteGraphics(mapView); var dijkstraApproxBucket = new DijkstraApproximateBucketPathFinder(DCGraph); var startVertex = dijkstraApproxBucket.FindClosestVertex(StartLocation.ToCoordinates()); var endVertex = dijkstraApproxBucket.FindClosestVertex(EndLocation.ToCoordinates()); var dijkstaKArrayHeap = new DijkstraMinHeapPathFinder(DCGraph); var dikstraList = new DijkstraPathFinder(DCGraph); var astarList = new AStarPathFinder(DCGraph); var astarApproxBucket = new AStarApproximateBucketPathFinder(DCGraph); var astarKarrayHeap = new AStarMinHeapPathFinder(DCGraph); AStarKArrayHeapRunningTime = GetRunningTime(astarKarrayHeap, startVertex, endVertex, mapView); DCGraph.ResetGraph(); AStarApproximateBucketRunningTime = GetRunningTime(astarApproxBucket, startVertex, endVertex, mapView); DCGraph.ResetGraph(); AStarListRunningTime = GetRunningTime(astarList, startVertex, endVertex, mapView); DCGraph.ResetGraph(); DijkstraApproximateBucketRunningTime = GetRunningTime(dijkstraApproxBucket, startVertex, endVertex, mapView); DCGraph.ResetGraph(); DijkstraListRunningTime = GetRunningTime(dikstraList, startVertex, endVertex, mapView); DCGraph.ResetGraph(); DijkstraKArrayHeapRunningTime = GetRunningTime(dijkstaKArrayHeap, startVertex, endVertex, mapView); DCGraph.ResetGraph(); }
private void AStarCommandExecuted(MapView mapView) { var dpf = new AStarApproximateBucketPathFinder(DCGraph); float pathlength = 0; var path = dpf.FindShortestPath(dpf.FindClosestVertex(StartLocation.ToCoordinates()), dpf.FindClosestVertex(EndLocation.ToCoordinates()), ref pathlength); if (path != null && path.Count > 0) { DisplayPath(path, mapView); } else { MessageBox.Show("No Route Found!"); } DCGraph.ResetGraph(); }
/// <summary> /// runs path shortest path algorithm on each implementation /// </summary> /// <param name="graph"></param> internal static void TestPathFinders(RoutingGraph[] graphs) { GraphTestResults[] results = new GraphTestResults[graphs.Length]; //// get all types that inherit PathFinder for (int i = 0; i < graphs.Length; i++) { results[i] = new GraphTestResults(graphs[i].Name); results[i].Graph = graphs[i]; // run TestPathFinder on each type PathFinder ASBA = new AStarApproximateBucketPathFinder(graphs[i]); PathFinder ASH = new AStarMinHeapPathFinder(graphs[i]); PathFinder DIKBA = new DijkstraApproximateBucketPathFinder(graphs[i]); PathFinder DIKH = new DijkstraMinHeapPathFinder(graphs[i]); results[i].AddAlgorithmTestResult(TestPathFinder(ASBA)); results[i].AddAlgorithmTestResult(TestPathFinder(ASH)); results[i].AddAlgorithmTestResult(TestPathFinder(DIKBA)); results[i].AddAlgorithmTestResult(TestPathFinder(DIKH)); } ParseResults(results); }