CN109726262B - Bus route query method and device, terminal device and readable storage medium - Google Patents

Bus route query method and device, terminal device and readable storage medium Download PDF

Info

Publication number
CN109726262B
CN109726262B CN201910025306.5A CN201910025306A CN109726262B CN 109726262 B CN109726262 B CN 109726262B CN 201910025306 A CN201910025306 A CN 201910025306A CN 109726262 B CN109726262 B CN 109726262B
Authority
CN
China
Prior art keywords
station
preset
matrix
site
route
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201910025306.5A
Other languages
Chinese (zh)
Other versions
CN109726262A (en
Inventor
王防修
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Polytechnic University
Original Assignee
Wuhan Polytechnic University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Polytechnic University filed Critical Wuhan Polytechnic University
Priority to CN201910025306.5A priority Critical patent/CN109726262B/en
Publication of CN109726262A publication Critical patent/CN109726262A/en
Application granted granted Critical
Publication of CN109726262B publication Critical patent/CN109726262B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a bus route query method, a bus route query device, terminal equipment and a readable storage medium. The method comprises the steps of firstly responding to a bus route query instruction of a user, extracting a starting station and a target station in the bus route query instruction, then searching the shortest path length between each intermediate station in a route from the starting station to the target station from a preset external memory, then taking the shortest path from the starting station to the target station as a route scheme to be selected, finally selecting an optimal route scheme from the route scheme to be selected, and displaying the optimal route scheme. The invention stores the preset site matrix in the preset external memory without leading the matrix into the memory, thereby saving a large amount of memory space, saving the time consumed for storing the memory and greatly improving the user experience.

Description

Bus route query method and device, terminal device and readable storage medium
Technical Field
The invention relates to the technical field of information processing, in particular to a bus route query method, a bus route query device, a bus route terminal device and a readable storage medium.
Background
With the development of economy and the acceleration of urbanization, the population of super-huge cities is more and more, and the cities are larger and larger, so that citizens can conveniently go out by means of transportation. The extensive investigation on citizens finds that the public transport and subway trip are the first choice of people. Therefore, in order to facilitate the inquiry of the public transport and subway lines when the user goes out, the intelligent public transport inquiry system becomes a research hotspot.
When a riding scheme is recommended for a passenger, the current various intelligent bus inquiry systems only consider the riding scheme with the least riding time or the least transfer times of the passenger generally, but do not consider the problem that the space of a memory used by a device terminal when the bus inquiry is executed is too large.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide a bus route query method, a bus route query device, terminal equipment and a readable storage medium, and aims to solve the technical problems that in the prior art, a large amount of memory space is occupied by matrix import and a large amount of time is consumed.
In order to achieve the purpose, the invention provides a bus route query method, which comprises the following steps:
responding to a bus route query instruction input by a user, and extracting a starting station and a target station from the bus route query instruction;
searching for the shortest path length between each intermediate station in the line from the starting station to the target station from a preset external memory, wherein the preset external memory stores the path length between each station;
taking the shortest path from the starting station to the target station as a scheme to be selected;
and selecting an optimal line scheme from the line schemes to be selected, and displaying the optimal line scheme.
Preferably, the searching for the shortest path length between each intermediate station in the line from the starting station to the destination station from the preset external memory specifically includes:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from the preset external memory by using a preset element positioning reading algorithm.
Preferably, before the searching for the shortest path length between each intermediate station in the route from the starting station to the destination station from the preset external memory by using a preset element positioning reading algorithm, the bus route query method further includes:
importing a preset site matrix into the preset external memory, wherein the path length among the sites is stored in the preset site matrix;
the finding, by using a preset element positioning reading algorithm, a shortest path length between each intermediate station in a line from the starting station to the destination station from the preset external memory specifically includes:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm.
Preferably, the preset site matrix is an n × n matrix;
searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm according to the following formula,
d=[(i-1)n+j-1]size,
the size is the space size of each element in the preset site matrix, i is a row element of the preset site matrix, j is a column element of the preset site matrix, and d is the shortest path length.
Preferably, the bus route query method according to claim 1, wherein the using dijkstra algorithm to use the shortest path from the starting station to the destination station as a candidate route scheme specifically includes:
and searching all shortest paths between the starting station and the target station from the preset external memory by utilizing the Dijj Tesla algorithm, circularly calculating the shortest paths from the starting station to each intermediate station, and taking the shortest paths from the starting station to the target station as a scheme of a line to be selected.
Preferably, the using the froude algorithm to use the shortest path from the starting station to the destination station as a candidate route scheme specifically includes:
and traversing the shortest paths from the starting station to all stations in the target station by utilizing the Flouard algorithm, and taking the shortest path from the starting station to the target station as a scheme of a route to be selected.
Preferably, the selecting an optimal route scheme from the route schemes to be selected and displaying the optimal route scheme specifically includes:
and taking the line scheme to be selected with the shortest total path length as the optimal line scheme, and displaying the optimal line scheme.
In addition, in order to achieve the above object, the present invention further provides a bus route inquiry apparatus, including:
the acquisition module is used for responding to a line inquiry instruction triggered by a user and acquiring an initial site and a target site input by the user;
the searching module is used for searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset external memory, and the preset external memory stores the path length between each station;
the determining module is used for taking the shortest path from the starting station to the target station as an optimal circuit scheme;
and the display module is used for selecting at least one optimal line scheme from the optimal line schemes and displaying the selected optimal line scheme.
In addition, to achieve the above object, the present invention further provides a terminal device, including: the inquiry system comprises a memory, a processor and an inquiry program of the bus line, wherein the inquiry program of the bus line is stored on the memory and can be operated on the processor, and the inquiry program of the bus line is configured to realize the steps of the inquiry method of the bus line.
In addition, in order to achieve the above object, the present invention further provides a readable storage medium, where the readable storage medium is a computer readable storage medium, the computer readable storage medium stores an inquiry program of a bus route, and the inquiry program of the bus route, when executed by a processor, implements the steps of the inquiry method of the bus route.
The invention discloses a bus route query method, a bus route query device, terminal equipment and a readable storage medium. The method comprises the steps of firstly responding to a bus route query instruction of a user, extracting a starting station and a target station in the bus route query instruction, then searching the shortest path length between each intermediate station in a route from the starting station to the target station from a preset external memory, then taking the shortest path from the starting station to the target station as a route scheme to be selected, finally selecting an optimal route scheme from the route scheme to be selected, and displaying the optimal route scheme. The invention stores the preset site matrix in the preset external memory without leading the matrix into the memory, thereby saving a large amount of memory space, saving the time consumed for storing the memory and greatly improving the user experience.
Drawings
Fig. 1 is a schematic structural diagram of a terminal device in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a bus route query method according to a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating a bus route query method according to a second embodiment of the present invention;
fig. 4 is a functional module diagram of the inquiry apparatus for bus routes according to the first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a terminal device in a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the terminal device may include: a processor 1001, such as a Central Processing Unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), a touch screen (touch screen), an input unit such as a Keyboard (Keyboard), a Mouse (Mouse), and optionally, the user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration shown in fig. 1 does not constitute a limitation of the terminal device, and that in actual implementations the terminal device may include more or less components than those shown, or some components may be combined, or a different arrangement of components.
Thus, as shown in FIG. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a query program for a bus line.
In the terminal device shown in fig. 1, the network interface 1004 is mainly used for establishing a communication connection between the terminal device and a server storing all data required in the intelligent bus inquiry system; the user interface 1003 is mainly used for data interaction with a user; the terminal device calls the inquiry program of the bus route stored in the memory 1005 through the processor 1001, and executes the following operations:
responding to a bus route query instruction input by a user, and extracting a starting station and a target station from the bus route query instruction;
searching for the shortest path length between each intermediate station in the line from the starting station to the target station from a preset external memory, wherein the preset external memory stores the path length between each station;
taking the shortest path from the starting station to the target station as a scheme to be selected;
and selecting an optimal line scheme from the line schemes to be selected, and displaying the optimal line scheme.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from the preset external memory by using a preset element positioning reading algorithm.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
importing a preset site matrix into the preset external memory, wherein the path length among the sites is stored in the preset site matrix;
the finding, by using a preset element positioning reading algorithm, a shortest path length between each intermediate station in a line from the starting station to the destination station from the preset external memory specifically includes:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm according to the following formula,
d=[(i-1)n+j-1]size,
the size is the space size of each element in the preset site matrix, i is a row element of the preset site matrix, j is a column element of the preset site matrix, and d is the shortest path length.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
and searching all shortest paths between the starting station and the target station from the preset external memory by utilizing the Dijj Tesla algorithm, circularly calculating the shortest paths from the starting station to each intermediate station, and taking the shortest paths from the starting station to the target station as a scheme of a line to be selected.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
and traversing the shortest paths from the starting station to all stations in the target station by utilizing the Flouard algorithm, and taking the shortest path from the starting station to the target station as a scheme of a route to be selected.
Further, the processor 1001 may call the query program of the bus route stored in the memory 1005, and further perform the following operations:
and taking the line scheme to be selected with the shortest total path length as the optimal line scheme, and displaying the optimal line scheme.
According to the embodiment, through the scheme, the shortest path length between the starting station and each intermediate station in the line from the target station is found out from the preset station matrix in the preset external memory by using an element positioning reading algorithm, then the shortest path between each intermediate station is screened based on a Dijjkstra algorithm or a Floend algorithm, the selected shortest path is used as a path scheme to be selected, and the path scheme to be selected with the shortest total path length is used as an optimal path scheme.
Based on the hardware structure, the embodiment of the bus route query method is provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of a bus route query method according to the present invention.
In a first embodiment, the bus route query method includes the following steps:
s10: responding to a bus route inquiry instruction input by a user, and extracting a starting station and a target station from the bus route inquiry instruction.
It can be understood that, in order to enable the user to input the bus route query instruction, in this embodiment, the user may select the starting station and the target station of the bus route by touching the device screen or the mouse, and extract the starting station and the target station from the bus route query system after the bus route query system receives the confirmation instruction.
S20: and searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset external memory, wherein the preset external memory stores the path length between each station.
Correspondingly, in this embodiment, a station direct matrix or a routing matrix is stored in the preset external memory, and the station direct matrix or the routing matrix stores distances between the starting station and all stations of the target station.
It should be understood that in particular embodiments, any two sites, such as site a and site B, are said to be mutually transparent if there is a line L passing through both sites, and otherwise are opaque. Research shows that in specific application, more than one line passing through the conditions of the station A and the station B at the same time is often satisfied, so that a matrix formed by constructing all lines capable of direct transmission between the station A and the station B is a station direct matrix, and a minimum station direct matrix is formed by constructing the shortest line capable of direct transmission between the station A and the station B.
It should be understood that, in the embodiment, as the optical transmission channel is developed, when the capacity of the router is not enough, it is best to superpose a new router whenever the capacity of the router is short, and thus the router grows gradually. This eliminates the time consuming transfer of data. Therefore, when the capacity of the router is in short supply, the method of expanding the capacity of the router by superposing a new router on the original router is the routing matrix.
In addition, in a specific embodiment, in this embodiment, a preset element location reading algorithm is used to search, from a preset external memory, a shortest path length between intermediate stations in a line from the starting station to the destination station.
That is, the finding of the shortest path length between each intermediate station in the line from the starting station to the destination station from the preset external memory specifically includes:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm.
For convenience of understanding, the following specifically describes the finding of the shortest path length between each intermediate station in the line from the starting station to the destination station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm:
in the specific implementation, assuming that a user needs to query a shortest path from an initial station to a target station, the initial station needs to find an intermediate station that can reach the target station, after the initial station and the target station are found in a preset external memory through a preset element positioning algorithm, the preset external memory displays all intermediate stations between the initial station and the target station, and at this time, the preset element positioning reading algorithm searches the intermediate station with the shortest path. Compared with the traditional method, the method has the advantages that the length of the shortest path between the starting station and each intermediate station in the line from the target station can be found more accurately by utilizing the preset element positioning reading algorithm from the preset station matrix in the preset external memory, the required elements are not required to be found from the internal memory when the elements are found, but are directly found from the external memory, the internal memory is saved, and the time consumption is reduced.
S30: and taking the shortest path from the starting station to the target station as a route scheme to be selected.
It should be understood that, in step S20, the shortest path between the originating station and each of the destination stations has been found from the preset external memory by using the preset element location algorithm, and therefore, in step S30, the dijkstra algorithm or the freoude algorithm is directly selected to determine the shortest path between the originating station and the destination station, so that the consumption of the memory can be greatly reduced, and the query speed can be increased.
In addition, in the specific implementation, based on the dijkstra algorithm or the freoude algorithm, the shortest path from the originating station to the destination station is screened out by comparing the shortest paths between the originating station and each of the destination stations.
It should be understood that, in the specific embodiment, assuming that the intermediate stations between the starting station and the destination station are respectively A, B, C and D, the steps of obtaining the shortest paths between the starting station and each station in the destination station based on the dijkstra algorithm or the froude algorithm are that the starting station first finds the shortest path to the intermediate station a, then finds the shortest path from the intermediate station a to the intermediate station B, if the shortest path from the starting station to the intermediate station B has the shortest path, compares the path with the path from the starting station to the station B via the station a, selects the line with the shortest path, finds the shortest paths from the starting station to the intermediate station B again, finds the lines with or without direct connection by using the same method, if the path has the direct line, compares the path of the direct line with the path of the line passing through the intermediate station, and selecting the shortest path scheme with short line distance until determining the shortest path scheme from the starting station to the target station.
S40: and selecting an optimal line scheme from the line schemes to be selected, and displaying the optimal line scheme.
It should be understood that, in a specific embodiment, the bus route inquiry system in the device terminal may select a route plan with the shortest route from route plans from the starting station to the target station to be displayed on the system.
In order to better understand the preset element positioning reading algorithm provided by the present invention, the following specific description is made:
for convenience of description, the following convention is first applied to the required correspondence:
1)videnotes the originating site, S denotes the originating site viSet of any site that can go straight from.
2) The matrix C ═ Cij)n×nAnd representing a least site direct matrix, wherein n multiplied by n represents that the matrix is a matrix with n rows and n columns, and the value of n is more than or equal to 1. If from the starting site viTo final station vjCan reach directly, then cijRepresenting the minimum number of stations passed by the direct line; otherwise, cij=∞。
3) Routing matrix R ═ (R)ij)n×n,rijIndicating the point v from the starting siteiTo the final station vjAnd (3) stations needing transfer, wherein i, j is 1,2, …, n.
4) Line vector Previ(i ═ 1,2, …, n) storage site viDirect precursor of (c).
5) Row vector Backi(i ═ 1,2, …, n) storage site viIs passed through to the successor.
6) Line vector Disti(i-1, 2, …, n) stores the shortest path value between two stations.
7) Line vector Xi(i-1, 2, …, n) as temporary storage space.
For convenience of description, the method for querying a bus route provided in this embodiment is roughly divided into two parts, namely, using a preset element positioning reading algorithm to search for the shortest path length between stations, and using a dijkstra algorithm or a freoude algorithm to calculate the shortest path from an initial station to a target station, where the two parts are specifically implemented as follows:
1. searching shortest path length between stations by using preset element positioning reading algorithm
Assuming that the space size of each element in the matrix file is size, the offset of the ith row and jth column element in the n rows and n columns of the file matrix from the 1 st row and 1 st column element is [ (i-1) n + j-1]And (4) size. If the ith row and jth column elements in the least site direct matrix are used, the method can be from cijThe offset from the file may be [ (i-1) n + j-1 [ ]]The position of the size is read directly. Similarly, if we want to use the ith row and jth column element in the routing matrix, we can come from rijThe offset from the file may be [ (i-1) n + j-1 [ ]]The position of the size is read directly. If one wants to use cijOr rijThen, the minimum site direct matrix or the routing matrix needs to be first imported into the memory. Otherwise, the element is read directly by element position addressing. For example, the first address from the file matrix is [ (i-1) n + j-1%]Where size reads row i column j element.
The preset element positioning reading algorithm can only search the initial site viTo target site vjThe shortest path between the stations in the network, and the initial station v can not be foundiTo target site vjThe shortest path of (2). Therefore, it is necessary toAnd calculating the shortest path from the starting station to the target station by using a Dijkstra algorithm or a Floend algorithm in one step.
2. Calculating the shortest path from the starting station to the target station by utilizing Dijkstra algorithm
The steps of inquiring the bus route by using the traditional Dijjkstra algorithm are as follows:
(1) inputting a starting station begin and an end station end;
(2) importing the content of the least station through matrix into a memory matrix C ═ (C)ij)n×nPerforming the following steps;
(3) and solving the shortest path from the station begin to all other stations, and circularly executing the following steps:
1) row vector Dist for initializationi(i ═ 1,2, …, n) such that disti=cbegin,i
2) If distiInfinity, then previ0; otherwise, previ=begin;
3) Initializing distbegin0 and sbegin=1;
4) Let wm ═ infinity and wm ∞. Circular search wm distu=min{disti|i∈{1,2,…,n}}
5) Let su1 is ═ 1; for i e {1,2, …, n }, if distu+cu,i<distiThen disti=distu+cu,iAnd previ=u;
6) If u is end, jump to step 8);
7) circularly executing the steps 1) to 6);
8) set stack pointer top to 0 and stack0End, make j equal to end, circularly execute push operation j equal to prevj,top=top+1,stacktopJ until prevj=end;
9) And displaying the shortest path from the starting site begin to the destination site in a pop mode.
The traditional Dijj Tesla algorithm is improved, and the content of a minimum site direct matrix is not led into a memory matrix C ═ (C)ij)n×nInstead, the required elements are directly read from a preset externally stored matrix file;
(1) inputting a starting station begin and an end station end;
(2) and solving the shortest path from the station begin to all other stations, and circularly executing the following steps:
1) reading the data X of the begin line from the least site direct matrix file through the file pointer offset1x2…xn
2) Row vector Dist for initializationi(i ═ 1,2, …, n) such that disti=xi
3) If distiInfinity, then previ0; otherwise, previ=begin;
4) Initializing distbegin0 and sbegin=1;
5) Let wm ═ infinity and wm ∞. Circular search wm distu=min{disti|i∈{1,2,…,n}};
6) Let su1 is ═ 1; for i e {1,2, …, n }, element y is read from the ith row and column of the least site direct matrix. If distu+y<distiThen disti=distu+ y and previ=u;
7) If u is end, jump to step 8);
8) set stack pointer top to 0 and stack0End, make j equal to end, circularly execute push operation j equal to prevj,top=top+1,stacktopJ until prevj=end;
9) And displaying the shortest path from the starting site begin to the destination site in a pop mode.
3. Calculating the shortest path from the starting station to the target station by using a Floeard algorithm
The steps of inquiring the bus route by using the traditional Floiede algorithm are as follows:
(1) inputting a starting station begin and an end station end;
(2) importing the content of the routing matrix file into a memory routing matrix R ═ (R)ij)n×nPerforming the following steps;
(3) the optimal path is obtained through a module inorder (r, begin, end) which executes a routing matrix search method.
The module order (r, i, j) function of the routing matrix search method is defined as follows:
if r isijNot equal to 0, the process of recursively searching the line is as follows:
(1)k=rij
(2) performing inorder (r, i, k) recursively;
(3) outputting a station k;
(4) performing inorder (r, k, j) recursively;
the method improves the traditional Dijj Tesla algorithm, and comprises the following steps of inquiring the bus route:
(1) inputting a starting station begin and an end station end;
(2) the optimal path is obtained through a module inorder (fp, begin, end) that executes a routing matrix search method.
Wherein fp is a pointer pointing to the routing matrix file, and the module order (fp, i, j) function of the routing matrix search method is defined as follows:
(1) locating the file pointer at [ (i-1) n + j-1] size from the file header;
(2) reading an element k from the current position of the routing matrix file;
(3) if k ≠ 0, the procedure that requires recursive search of the line is as follows:
1) performing inorder (r, i, k) recursively;
2) outputting a station k;
3) performing inorder (r, k, j) recursively;
in order to verify that, based on the above bus route query method, according to the starting station and the target station input by the user, the memory space of the device terminal is saved, the query speed of the bus route is increased, and a bus route is provided for the user, which is specifically described below:
suppose that 3957 stations are known in the public transportation system of a certain city, and the public transportation routes are known.
It can be seen from the above algorithm that for dijkstra algorithm, the improvement is reflected in the difference of reading the least site matrix. Whereas for the freouard algorithm the improvement is manifested in the difference of the read routing matrix.
Therefore, the memory space occupied by each algorithm before and after the improvement is shown in table 1.
TABLE 1 memory space occupied by algorithms before and after improvement
Figure BDA0001941814160000121
From table 1, it can be seen that the modified dijkstra algorithm or the freoude algorithm can save a large amount of memory space.
As for the time taken for the inquiry, it depends on the origin and destination of the inquiry. Therefore, the comparison can only be made from a specific query process.
If the dijkstra algorithm is modified, the time taken to query some of the ride plans with the shortest ride time is shown in table 2.
Table 2 diejkstra algorithm search time for shortest ride time from start station to end station
Figure BDA0001941814160000122
Figure BDA0001941814160000131
As can be seen from table 2, the search time of the modified dijkstra algorithm is reduced by more than half of the search time of the unmodified dijkstra algorithm.
If the freouard algorithm is modified, the time taken to query some of the ride plans with the shortest ride time is shown in table 3.
Table 3 froude algorithm search time of shortest riding time from start station to end station
Figure BDA0001941814160000132
As can be seen from table 3, the search time of the modified froude algorithm is greatly reduced compared with the search time of the unmodified froude algorithm, and the saved query time is very obvious.
The above description is only for illustrative purposes and does not limit the technical solutions of the present application in any way.
It is not difficult to find out through the above description that the query method of the bus route provided in this embodiment first responds to the query instruction of the bus route of the user, extracts the starting station and the target station in the query instruction of the bus route, then searches for the shortest path length between each intermediate station in the route from the starting station to the target station from the preset external memory, then takes the shortest path from the starting station to the target station as the route plan to be selected, and finally selects the optimal route plan from the route plan to be selected, and displays the optimal route plan. The invention stores the preset site matrix in the preset external memory without leading the matrix into the memory, thereby saving a large amount of memory space, saving the time consumed for storing the memory and greatly improving the user experience.
Further, as shown in fig. 3, a second embodiment of the recommendation method for a riding scheme according to the present invention is proposed based on the first embodiment, and in this embodiment, after extracting a starting station and a target station from a bus route query instruction input by a user, a minimum station direct matrix and a route matrix are led into a preset external memory in advance, so that required data can be directly read from the preset external memory when needed, which is detailed in step S00 in fig. 3.
For ease of understanding, the following detailed description is made in conjunction with fig. 3:
in step S00: extracting an initial station and a target station input by a user, before searching for a shortest path from the initial station to the target station, checking whether data of a minimum station direct matrix and a routing matrix are stored in an external memory, if the data are stored, performing S20', and if the data are not stored, storing the minimum station direct matrix and the routing matrix in a preset external memory, wherein the minimum station direct matrix and the routing matrix comprise the shortest distance from the initial station to each station in the target station. And importing the minimum site direct matrix and the routing matrix into a preset external memory, so as to avoid the operation of importing the minimum site direct matrix and the routing matrix into the internal memory when data needs to be read.
Accordingly, step S20 is replaced with step S20': when data from an initial station to each station in a target station is needed, a preset element positioning reading method is used for directly reading the data from a preset external memory, the element positions of the initial station and the target station are firstly positioned in the preset external memory, then the element positions of each station in the initial station and the target station are positioned, and the intermediate station with the shortest path is found.
In addition, the embodiment of the invention also provides a device for inquiring the bus route. As shown in fig. 4, the bus route inquiry apparatus includes: the device comprises an acquisition module 10, a search module 20, a determination module 30 and a display module 40.
The obtaining module 10 is configured to, in response to a line query instruction triggered by a user, obtain an initial site and a target site input by the user. The searching module 20 is configured to search, from a preset external memory, a shortest path length between each intermediate station in a line from the starting station to the target station, where the preset external memory stores path lengths between stations. And the determining module 30 is configured to use the shortest path from the starting station to the destination station as an optimal route scheme. And the display module 40 is configured to select at least one optimal line scheme from the optimal line schemes and display the selected optimal line scheme.
It should be noted that, in the present embodiment, the preset external memory is mainly stored in the minimum site direct matrix and the routing matrix.
It is not difficult to find out through the above description that the query device of the bus route provided in this embodiment first responds to the query instruction of the bus route of the user, extracts the starting station and the target station in the query instruction of the bus route, then searches for the shortest path length between each intermediate station in the route from the starting station to the target station from the preset external memory, then takes the shortest path from the starting station to the target station as the route plan to be selected, and finally selects the optimal route plan from the route plan to be selected, and displays the optimal route plan. The invention stores the preset site matrix in the preset external memory without leading the matrix into the memory, thereby saving a large amount of memory space, saving the time consumed for storing the memory and greatly improving the user experience.
In addition, it should be noted that the above-described embodiments of the apparatus are merely illustrative, and do not limit the scope of the present invention, and in practical applications, a person skilled in the art may select some or all of the modules to implement the purpose of the embodiments according to actual needs, and the present invention is not limited herein.
In addition, the technical details that are not described in detail in this embodiment may refer to the method for querying a bus route provided in any embodiment of the present invention, and are not described herein again.
In addition, an embodiment of the present invention further provides a readable storage medium, where the readable storage medium is a computer-readable storage medium, and the computer-readable storage medium stores an inquiry program of a bus route, where the inquiry program of the bus route, when executed by a processor, implements the following operations:
responding to a bus route query instruction input by a user, and extracting a starting station and a target station from the bus route query instruction;
searching for the shortest path length between each intermediate station in the line from the starting station to the target station from a preset external memory, wherein the preset external memory stores the path length between each station;
taking the shortest path from the starting station to the target station as a scheme to be selected;
and selecting an optimal line scheme from the line schemes to be selected, and displaying the optimal line scheme.
Further, when executed by the processor, the bus route query program further implements the following operations:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from the preset external memory by using a preset element positioning reading algorithm.
Further, when executed by the processor, the bus route query program further implements the following operations:
importing a preset site matrix into the preset external memory, wherein the path length among the sites is stored in the preset site matrix;
the finding, by using a preset element positioning reading algorithm, a shortest path length between each intermediate station in a line from the starting station to the destination station from the preset external memory specifically includes:
and searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm.
Further, when executed by the processor, the bus route query program further implements the following operations:
searching the shortest path length between each intermediate station in the line from the starting station to the target station from a preset station matrix in the preset external memory by using a preset element positioning reading algorithm according to the following formula,
d=[(i-1)n+j-1]size,
the size is the space size of each element in the preset site matrix, i is a row element of the preset site matrix, j is a column element of the preset site matrix, and d is the shortest path length.
Further, when executed by the processor, the bus route query program further implements the following operations:
and searching all shortest paths between the starting station and the target station from the preset external memory by utilizing the Dijj Tesla algorithm, circularly calculating the shortest paths from the starting station to each intermediate station, and taking the shortest paths from the starting station to the target station as a scheme of a line to be selected.
Further, when executed by the processor, the bus route query program further implements the following operations:
and traversing the shortest paths from the starting station to all stations in the target station by utilizing the Flouard algorithm, and taking the shortest path from the starting station to the target station as a scheme of a route to be selected.
Further, when executed by the processor, the bus route query program further implements the following operations:
and taking the line scheme to be selected with the shortest total path length as the optimal line scheme, and displaying the optimal line scheme.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., a rom/ram, a magnetic disk, an optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (7)

1. A bus route query method is characterized by comprising the following steps:
responding to a bus route query instruction input by a user, and extracting a starting station and a target station from the bus route query instruction;
importing a preset site matrix into a preset external memory, wherein the path length among sites is stored in the preset site matrix;
the preset site matrix is an n x n matrix, the shortest path length between the initial site and each intermediate site in the line from the initial site to the target site is searched from the preset site matrix in the preset external memory by using a preset element positioning reading algorithm according to the following formula, and the path length between each site is stored in the preset external memory
d=[(i-1)n+j-1]size,
The size is the space size of each element in the preset site matrix, i is a row element of the preset site matrix, j is a column element of the preset site matrix, d is the shortest path length, and n is the order number of the preset site matrix;
taking the shortest path from the starting station to the target station as a scheme to be selected;
and selecting an optimal line scheme from the line schemes to be selected, and displaying the optimal line scheme.
2. The bus route inquiry method according to claim 1, wherein the step of using the shortest route from the starting station to the destination station as a route selection scheme specifically comprises:
and searching all shortest paths from the starting station to the target station from the preset external memory by utilizing a preset Dijjkstra algorithm, circularly calculating the shortest paths from the starting station to each intermediate station, and taking the shortest paths from the starting station to the target station as a scheme of a line to be selected.
3. The bus route inquiry method according to claim 1, wherein the step of using the shortest route from the starting station to the destination station as a route selection scheme specifically comprises:
and traversing the shortest paths from the starting station to all stations in the target station by using a preset Froude algorithm, and taking the shortest path from the starting station to the target station as a route scheme to be selected.
4. The bus route inquiry method according to any one of claims 1 to 3, wherein the selecting an optimal route plan from the route plans to be selected and displaying the optimal route plan specifically comprises:
and taking the line scheme to be selected with the shortest total path length as the optimal line scheme, and displaying the optimal line scheme.
5. A bus route inquiry device, characterized in that, the device includes:
the acquisition module is used for responding to a line inquiry instruction triggered by a user and acquiring an initial site and a target site input by the user;
a searching module, configured to import a preset site matrix into a preset external memory, where the preset site matrix stores path lengths between sites, the preset site matrix is an n × n matrix, and search, by using a preset element location reading algorithm, for a shortest path length between intermediate sites in a line from the starting site to the target site from the preset site matrix in the preset external memory according to the following formula, where the preset external memory stores path lengths between sites
d=[(i-1)n+j-1]size,
The size is the space size of each element in the preset site matrix, i is a row element of the preset site matrix, j is a column element of the preset site matrix, d is the shortest path length, and n is the order number of the preset site matrix;
the determining module is used for taking the shortest path from the starting station to the target station as an optimal circuit scheme;
and the display module is used for selecting at least one optimal line scheme from the optimal line schemes and displaying the selected optimal line scheme.
6. A terminal device, characterized in that the terminal device comprises: memory, a processor and a query program of a bus route stored on the memory and executable on the processor, the query program of a bus route being configured to implement the steps of the query method of a bus route according to any one of claims 1 to 4.
7. A readable storage medium, characterized in that the readable storage medium is a computer readable storage medium, on which a bus route inquiry program is stored, and the bus route inquiry program, when executed by a processor, implements the steps of the bus route inquiry method according to any one of claims 1 to 4.
CN201910025306.5A 2019-01-10 2019-01-10 Bus route query method and device, terminal device and readable storage medium Expired - Fee Related CN109726262B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910025306.5A CN109726262B (en) 2019-01-10 2019-01-10 Bus route query method and device, terminal device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910025306.5A CN109726262B (en) 2019-01-10 2019-01-10 Bus route query method and device, terminal device and readable storage medium

Publications (2)

Publication Number Publication Date
CN109726262A CN109726262A (en) 2019-05-07
CN109726262B true CN109726262B (en) 2020-12-25

Family

ID=66298953

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910025306.5A Expired - Fee Related CN109726262B (en) 2019-01-10 2019-01-10 Bus route query method and device, terminal device and readable storage medium

Country Status (1)

Country Link
CN (1) CN109726262B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113888953B (en) * 2020-07-01 2023-08-22 腾讯科技(深圳)有限公司 Subway line drawing method and equipment and computer readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268190A (en) * 2014-09-17 2015-01-07 腾讯科技(深圳)有限公司 Bus route search method and device
CN108491556A (en) * 2018-04-18 2018-09-04 武汉轻工大学 Bus line inquiry method based on big data dimension-reduction treatment and query facility
CN108629456A (en) * 2018-05-08 2018-10-09 武汉轻工大学 Read method, device, terminal device and the readable storage medium storing program for executing of public transport data

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
LU92498B1 (en) * 2014-07-11 2016-01-12 Flash Europ Internat Sa Method for transport analysis
CN108509659B (en) * 2018-05-22 2020-10-23 武汉轻工大学 Recommendation method and device for riding scheme, terminal equipment and readable storage medium
CN108763549A (en) * 2018-05-31 2018-11-06 武汉轻工大学 Method for quickly querying, device, terminal device and the storage medium of public bus network

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104268190A (en) * 2014-09-17 2015-01-07 腾讯科技(深圳)有限公司 Bus route search method and device
CN108491556A (en) * 2018-04-18 2018-09-04 武汉轻工大学 Bus line inquiry method based on big data dimension-reduction treatment and query facility
CN108629456A (en) * 2018-05-08 2018-10-09 武汉轻工大学 Read method, device, terminal device and the readable storage medium storing program for executing of public transport data

Also Published As

Publication number Publication date
CN109726262A (en) 2019-05-07

Similar Documents

Publication Publication Date Title
CN108388642B (en) Sub-graph query method and device and computer readable storage medium
US8234264B2 (en) System and method for preferred services in nomadic environments
CN101532842A (en) Path planning method for determining target route from starting point to ending point and device thereof
CN107367278A (en) A kind of indoor navigation method and equipment
CN101427102A (en) A map database having address points for determining destinations
JP2002116689A (en) Updating method of road information in map information providing system, its updating server, server program and recording medium recorded with the program
CN108509659B (en) Recommendation method and device for riding scheme, terminal equipment and readable storage medium
EP3112808A1 (en) Route-finding device, route-finding method, and program
KR101513588B1 (en) Device and method for path finding
CN112985413A (en) Scenic spot path planning method and device based on improved A-x algorithm
CN112015836A (en) Navigation map display method and device
CN105869512A (en) Multi-information mixed measurement mapping method and device
CN109726262B (en) Bus route query method and device, terminal device and readable storage medium
KR20180122737A (en) Road name display method, apparatus and storage medium
CN108763518B (en) Recommendation method and device for riding scheme, terminal equipment and readable storage medium
CN114422885A (en) Route searching method, device, equipment and medium based on topological route
JP2003207358A (en) Road guidance unit and program
JP4637133B2 (en) Guidance system, guidance server device, guidance method and program implementing the method
JP5132694B2 (en) DATA GENERATION DEVICE, DATA GENERATION METHOD, AND ROUTE SEARCH DEVICE
JP5081311B2 (en) Map information processing apparatus, map information processing method, map information processing program, and recording medium
JP2009116787A (en) Information providing device and method
CN113340316B (en) Route display method and device, electronic equipment and storage medium
JP5670761B2 (en) Navigation device
TWI412998B (en) Method and mobile device for processing web information
CN114279457A (en) Path planning method, device, equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20201225

Termination date: 20220110