public int[] GetRouteNumbers(int graphNo, int start, int end) { FindShortestPath find = new FindShortestPath(); int[,] graph, endPoints; int V_No; int[] path; List <int> routeNumbers = new List <int>(); List <int[]> allPaths; switch (graphNo) { case 0: graph = Data.footRoutesGraph; V_No = Data.footGrapheVertices; endPoints = Data.foorRouteEndpoints; break; case 1: graph = Data.vehicleRoutesGraph; V_No = Data.vehicleGrapheVertices; endPoints = Data.vehicleRouteEndpoints; break; case 2: graph = Data.CSDepartmentGraph; V_No = Data.CSDepartmentGrapheVertices; endPoints = Data.CSDepartmentRouteEndpoints; break; default: graph = Data.footRoutesGraph; V_No = Data.footGrapheVertices; endPoints = Data.foorRouteEndpoints; break; } allPaths = find.GetShortestPathList(graph, V_No, start); path = allPaths[end]; for (int j = 0; j < path.Length - 1; j++) { for (int i = 0; i < endPoints.GetLength(0); i++) { if ((endPoints[i, 0] == path[j] && endPoints[i, 1] == path[j + 1]) || (endPoints[i, 1] == path[j] && endPoints[i, 0] == path[j + 1])) { routeNumbers.Add(i); break; } } } return(routeNumbers.ToArray()); }
public int FindEnterenceVertexNo(int noOfVertices, int graphNo, int start, int placeID) { FindShortestPath find = new FindShortestPath(); int[,] graph, innerGraph; int[] dist_1, dist_2, distance, ids; int innerStart, innerEnd = 0, innerVerticesNo; if (graphNo == 0) { graph = Data.footRoutesGraph; } else { graph = Data.vehicleRoutesGraph; } ids = LocationData.GetDepartmentAndFloor(placeID); if (ids[0] == 1) { innerGraph = Data.CSDepartmentGraph; innerVerticesNo = Data.CSDepartmentGrapheVertices; } else { innerGraph = Data.footRoutesGraph; innerVerticesNo = Data.footGrapheVertices; } for (int j = 0; j < Data.CSMainPlaceMatch.Length; j++) { if (Data.CSMainPlaceMatch[j] == placeID) { innerEnd = j; break; } } dist_1 = find.GetShortestDistanceList(graph, noOfVertices, start); distance = new int[Data.EntranceOuterMatch.Length]; for (int i = 0; i < Data.EntranceOuterMatch.Length; i++) { distance[i] = dist_1[Data.EntranceOuterMatch[i]]; innerStart = Data.CSMainEntranceInnerMatch[i]; dist_2 = find.GetShortestDistanceList(innerGraph, innerVerticesNo, innerStart); distance[i] += dist_2[innerEnd]; } //according to the department,Entrance outer match should change return(Data.EntranceOuterMatch[Array.IndexOf(distance, distance.Min())]); }
public double[] FindDistanceAndTime(int graphNo, int start, int end) { FindShortestPath find = new FindShortestPath(); int[,] graph; int V_No; int[] distances; switch (graphNo) { case 0: graph = Data.footRoutesGraph; V_No = Data.footGrapheVertices; break; case 1: graph = Data.vehicleRoutesGraph; V_No = Data.vehicleGrapheVertices; break; case 2: graph = Data.CSDepartmentGraph; V_No = Data.CSDepartmentGrapheVertices; break; default: graph = Data.footRoutesGraph; V_No = Data.footGrapheVertices; break; } distances = find.GetShortestDistanceList(graph, V_No, start); if (graphNo == 1) { return new double[] { distances[end], Math.Round((distances[end] * Data.drivingTimePerMeter) / 60, 2) } } ; else { return new double[] { distances[end], Math.Round((distances[end] * Data.walkingTimePerMeter) / 60, 1) } }; } int Middle { get; set; } }