Method and device for generating minimum stations of through line and electronic equipment

By sorting and indexing bus route stops, and using the route index table to calculate the minimum number of stops, the problem of low generation efficiency in large-scale bus networks is solved, achieving efficient route planning and real-time response.

CN121765148APending Publication Date: 2026-03-31WUHAN POLYTECHNIC UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing technologies are computationally inefficient in generating the minimum station access matrix for large-scale public transport networks, making it difficult to meet real-time requirements, especially when the public transport network is dynamically changing.

Method used

By sorting the station names in the transportation routes and generating a station index, and using the route index table to calculate the minimum number of stations between any two stations, the frequent string matching operations in traditional methods are avoided. The binary search tree and binary search algorithm are used to improve data processing efficiency.

Benefits of technology

It significantly reduces the time complexity of data retrieval and path calculation, improves the efficiency of generating the minimum stop direct route matrix under large-scale public transport networks, and enhances the real-time response capability of the intelligent public transport system's path planning function.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121765148A_ABST
    Figure CN121765148A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a method and device for generating minimum stations of a direct line and electronic equipment, and relates to the technical field of information processing. According to the method, the station names contained in all the traffic lines are sorted, the station names in the line information of all the traffic lines are updated into the station indexes, unstructured station names can be converted into ordered numerical identifiers, and standardized and indexed expression of line data is achieved. And directly calculating the minimum station number on the same line between any two station indexes based on the line index table, and finally generating a minimum station nonstop matrix covering all station pairs. By introducing a station index mechanism, frequent character string matching operation in a traditional method is avoided, and the time complexity of data search and path calculation is remarkably reduced, so that the generation efficiency of the minimum station nonstop matrix in a large-scale public transportation network is improved, and the real-time response capability of a path planning function in an intelligent public transportation system is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information processing technology, and more specifically, to a method, apparatus, and electronic device for generating a direct route with the fewest stops. Background Technology

[0002] Intelligent public transport query systems, as an important component of modern urban transportation service systems, have been widely used in public transport information inquiry and route planning in recent years. These systems provide users with optimal travel route recommendations by analyzing bus route data and direct connections between stops. However, the effectiveness of such systems highly depends on the accuracy and real-time nature of the underlying data, especially the minimum stop direct connection matrix, which needs to be updated promptly.

[0003] In real-world applications, public transport networks are constantly changing, including the addition of new routes, station adjustments, and temporary detours. These changes can cause discrepancies between system-recommended routes and actual operational conditions, severely impacting user travel experience and efficiency. While updating the bus route database is relatively easy, regenerating the minimum-stop direct route matrix presents challenges such as high computational complexity and long processing times. Existing generation methods are inefficient when dealing with large-scale public transport networks and struggle to meet real-time requirements.

[0004] Current methods for generating the minimum station accessibility matrix primarily rely on a global traversal strategy, requiring a complete calculation of accessibility relationships between all stations. While this method ensures accuracy, it involves numerous redundant operations, leading to a significant decrease in computational efficiency, especially when the public transport network is large. Improving matrix generation efficiency without compromising accuracy has become a key technical challenge for intelligent public transport systems. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for generating the minimum number of stops for direct routes, which can improve the generation efficiency of the minimum number of stops direct route matrix in a large-scale public transport network.

[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows: In a first aspect, the present invention provides a method for generating a direct route with the fewest stops, the method comprising: Sort the station names included in all transportation routes and determine the station index corresponding to each station name based on the sorting results; The station names in the route information of each of the aforementioned transportation routes are updated with the corresponding station indexes to obtain a route index table; the route index table is used to record the station indexes contained in each transportation route. The minimum number of stations between any two station indices is determined based on the route index table, resulting in a minimum station direct route matrix; the minimum station direct route matrix is ​​used to record the minimum number of stations for direct routes between any two stations.

[0007] In an optional implementation, the step of sorting the station names included in all transportation routes and determining the station index corresponding to each station name based on the sorting result includes: Obtain the raw information of all transportation routes and standardize the raw information to obtain the route information of all transportation routes. Obtain the station names from all the route information, sort all the station names to remove duplicates, and obtain a station array; The index of each site name in the site array is determined as the site index corresponding to each site name.

[0008] In an optional implementation, the step of deduplicating and sorting all the site names to obtain a site array includes: Construct a binary search tree for the sites based on all the site names; The site array is obtained by performing an inorder traversal on the binary search tree.

[0009] In an optional implementation, updating the station names in the route information of each of the transportation routes to the corresponding station indexes to obtain a route index table includes: Iterate through the route information of each of the aforementioned transportation routes and sequentially obtain the names of the stations to be processed from the route information; Use binary search to obtain the site index corresponding to the site name to be processed from the site array; The station name to be processed in each of the line information is determined as the corresponding station index to obtain the line index table.

[0010] In an optional implementation, determining the minimum number of stations between any two station indices based on the route index table to obtain the minimum station direct route matrix includes: Based on the route index table, determine the station location index of the station index in the corresponding transportation route to obtain the location index table; The minimum number of stations between any two station indices is determined based on the route index table and the location index table, thus obtaining the minimum station direct access matrix.

[0011] In an optional implementation, each record in the route index table includes a route identifier and a list of station indexes, wherein the list of station indexes records all station indexes included on the traffic route according to the direction of travel; the step of determining the station location index of the station index in the traffic route according to the route index table to obtain the location index table includes: Iterate through each record in the route index table, and generate a position index corresponding to each station index in each route identifier in turn, based on the route identifier, each station index in the station index list, and the position order of each station index in the station index list. The location index table is generated based on all the station indexes and corresponding location indexes in each of the line identifiers.

[0012] In an optional implementation, each record in the route index table includes a route identifier and a travel mode; each record in the location index table includes a route identifier, a station index, and a location index corresponding to the station index; the step of determining the minimum number of stations between any two station indices based on the route index table and the location index table to obtain the minimum station direct route matrix includes: Each site index is sequentially determined as the starting index, and each site index that is different from the starting index is sequentially determined as the ending index. Traverse the location index table to determine whether the starting point index and the ending point index are on the same transportation route; If the origin index and the destination index are not on the same transportation route, set the minimum number of stops between the origin index and the destination index to an invalid value; If the origin index and the destination index are on the same transportation route, obtain the target route identifier of the transportation route where the origin index and the destination index are located, and determine the minimum number of candidate stations between the origin index and the destination index based on the driving mode corresponding to the target route identifier in the route index table, the location index corresponding to the origin index in the record where the target route identifier is located in the location index table, and the location index corresponding to the destination index in the record where the target route identifier is located in the location index table; the number of the same transportation route where the origin index and the destination index are located is consistent with the number of the minimum number of candidate stations; The minimum value among all candidate minimum station numbers between the starting point index and the ending point index is determined as the minimum station number between the starting point index and the ending point index; the minimum station directness matrix is ​​composed of the minimum station numbers between all starting point indices and ending point indices.

[0013] In an optional implementation, each record in the route index table includes a travel mode and a list of station indexes, wherein the list of station indexes records all station indexes included on the traffic route according to the travel direction; the step of determining the minimum number of stations between any two station indexes based on the route index table to obtain the minimum station direct route matrix includes: Traverse each of the station index lists in the route index table, and determine the station index in the station index list as the starting point index in turn, and determine the station index in the station index list that is different from the starting point index as the ending point index; The number of interval stops between the origin index and the destination index is calculated based on the distance between them and the corresponding travel mode; the number of the same traffic lines where the origin index and the destination index are located is consistent with the number of interval stops. The minimum number of all interval stations between the starting point index and the ending point index is determined as the minimum number of stations between the starting point index and the ending point index; the minimum station directness matrix is ​​composed of the minimum number of stations between all starting point indices and the ending point index.

[0014] Secondly, the present invention provides a device for generating a direct route with the fewest stops, the device comprising: The acquisition module is used to sort the station names included in all transportation routes and determine the station index corresponding to each station name based on the sorting result. The processing module is used to update the station names in the route information of each of the transportation routes to the corresponding station indexes, thereby obtaining a route index table; the route index table is used to record the station indexes contained in each transportation route. The determination module is used to determine the minimum number of stations between any two station indices based on the route index table, and obtain the minimum station direct route matrix; the minimum station direct route matrix is ​​used to record the minimum number of stations for direct routes between any two stations.

[0015] Thirdly, the present invention provides an electronic device including a processor and a memory, the memory storing a computer program executable by the processor, the processor executing the computer program to implement the direct route minimum station generation method described in any of the foregoing embodiments.

[0016] Compared to existing technologies, the method, apparatus, and electronic device for generating minimum-stop direct routes provided in this invention sort the station names included in all transportation routes and update the station names in the route information of each transportation route with station indices. This transforms unstructured station names into ordered numerical identifiers, achieving standardized and indexed representation of route data. Based on the route index table, the minimum number of stations on the same route between any two station indices is directly calculated, ultimately generating a minimum-stop direct route matrix covering all station pairs. By introducing a station index mechanism, frequent string matching operations in traditional methods are avoided, significantly reducing the time complexity of data lookup and path calculation. This improves the generation efficiency of the minimum-stop direct route matrix in large-scale public transportation networks and enhances the real-time response capability of the route planning function in intelligent public transportation systems.

[0017] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This diagram illustrates a flowchart of a method for generating the minimum number of stations for a direct route, as provided in an embodiment of the present invention.

[0020] Figure 2 This diagram illustrates another flowchart of the method for generating the minimum number of stations for a direct route provided in an embodiment of the present invention.

[0021] Figure 3 A block diagram of a direct route minimum station generation device provided in an embodiment of the present invention is shown.

[0022] Figure 4 A block diagram of an electronic device provided in an embodiment of the present invention is shown.

[0023] Icons: 400 - Direct route minimum station generation device; 410 - Acquisition module; 420 - Processing module; 430 - Determination module; 500 - Electronic device; 510 - Memory; 520 - Processor; 530 - Communication module. Detailed Implementation

[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0025] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0026] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0027] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0028] Please refer to Figure 1 , Figure 1 A flowchart illustrating a method for generating the minimum number of stops for a direct route according to an embodiment of the present invention is shown. The method includes the following steps: Step S10: Sort the station names included in all transportation routes and determine the station index corresponding to each station name based on the sorting result.

[0029] In this embodiment of the invention, all station names covered by the normally operating transportation routes are extracted, and after deduplication, they are arranged according to preset rules (such as lexicographical order, pinyin sorting, etc.) to form an ordered set of stations.

[0030] Based on this, each unique site is assigned an integer value corresponding to its position in the ordered set as its site index. It should be understood that the site index, as a key identifier in subsequent data processing, can effectively replace the original string form of the site name, reducing the time complexity of comparison and search operations and improving overall computational efficiency.

[0031] Step S20: Update the station names in the route information of each transportation route to the corresponding station index to obtain the route index table; the route index table is used to record the station indexes contained in each transportation route.

[0032] In this embodiment of the invention, after the station index is constructed, the station sequence of each transportation route is traversed. The established mapping relationship (i.e., the correspondence between station name and station index) is used to replace the station names in the original route, which are represented in text form, with their corresponding station indexes one by one. The resulting route index table records the station indexes contained in each transportation route in a structured manner, which transforms the original string matching operation into efficient numerical calculation, providing a data foundation for subsequent fast retrieval and distance calculation.

[0033] Step S30: Determine the minimum number of stations between any two station indices based on the route index table to obtain the minimum station direct route matrix; the minimum station direct route matrix is ​​used to record the minimum number of stations for direct routes between any two stations.

[0034] In this embodiment of the invention, based on the arrangement order of the station indexes within each traffic line recorded in the route index table, for each pair of station index combinations of the start and end points, all traffic lines that may cover these two stations are traversed, the number of interval stations within the traffic line is calculated, and the minimum value is selected as the minimum number of direct stations between the two.

[0035] In summary, the method for generating the minimum number of stations for direct routes provided in this invention sorts the station names included in all transportation routes and updates the station names in the route information of each transportation route with station indices. This transforms unstructured station names into ordered numerical identifiers, achieving standardized and indexed representation of route data. Based on the route index table, the minimum number of stations on the same route between any two station indices is directly calculated, ultimately generating a minimum station direct route matrix covering all station pairs. By introducing a station index mechanism, the frequent string matching operations in traditional methods are avoided, significantly reducing the time complexity of data lookup and path calculation. This improves the generation efficiency of the minimum station direct route matrix in large-scale public transportation networks and enhances the real-time response capability of the route planning function in intelligent public transportation systems.

[0036] Alternatively, one possible implementation for generating the index value of the site name is provided below. Figure 1 The sub-steps of step S10 may include: Step S100: Obtain the original information of all transportation routes and standardize the original information to obtain the route information of all transportation routes.

[0037] In this embodiment of the invention, the raw data of all transportation routes is obtained from the original transportation route database (such as the bus route database file wfx.txt). The raw information of transportation routes is manually compiled based on experience, lacking a unified data structure standard, resulting in significant differences in the number of fields and organization methods for different route types, making it impossible for computer systems to directly identify and automate the process.

[0038] Based on the analysis of existing route data, the original routes can be divided into three basic types: loop routes, up / down routes, and other types of routes. Loop routes contain four fields: route number, fare calculation method, loop identifier, and route name (i.e., the route stop sequence). Up / down routes contain six fields: route number, fare calculation method, up / down identifier, route A name, down / down identifier, and route B name; while other types of routes contain only three fields: route number, fare calculation method, and route name. This inconsistent number of fields and heterogeneous structure severely restricts the efficiency of unified data parsing and system integration.

[0039] To achieve efficient processing of traffic route data, a unified data structure standard must be established. System analysis determined that all routes should be uniformly converted to a standard format containing four fields: route identifier (e.g., route number), fare calculation method, travel mode (e.g., direction identifier), and route station sequence. The route station sequence includes the names of all stations along the traffic route corresponding to the route identifier. This standard structure is compatible with the directional characteristics and naming logic of various traffic routes, ensuring clear data semantics and facilitating programmatic processing.

[0040] For different types of routes, corresponding standardized conversion strategies are designed: For "upbound and downbound" routes, a data splitting method is used to split the original six-field record into two independent four-field standardized records. The first route corresponds to the route identifier, fare calculation method, and route A name, and the travel mode is set to upbound. The second route corresponds to the route identifier, fare calculation method, and route B name, and the travel mode is set to downbound.

[0041] For "circular" routes, the original four fields already meet the target structure requirements, and only field mapping and standardized naming are needed to complete the conversion; for "other types" routes, the default driving mode "bidirectional" is added to the original three fields to form a complete four-field standard record by supplementing the fields.

[0042] As one possible implementation, during the initialization phase, the source file "wfx.txt" is opened in read-only mode, and a target output file "step1.txt" is created to store the standardized result data. Then, the basic fields of each route are read line by line, including route number (a), pricing method (b), and route type (c). The category of the route is determined based on the value of the route type (c), and the corresponding processing logic is executed. If c is "upward", the subsequent fields are read and two standardized records are generated. If c is "circular", the corresponding circular route station sequence is read and a standard record is generated. If c is other types, "bidirectional" is added as the travel mode, and a complete record is generated by combining the existing fields. Finally, the generated standard data is written to the standard route library file "step1.txt".

[0043] The above processing iterates through all traffic route records in the original file one by one until all data has been converted. Ultimately, the original route data, which was structurally chaotic and varied in format, was successfully transformed into a standardized set of route information with a unified structure and consistent semantics, and output to the "step1.txt" file.

[0044] By implementing this standardization scheme, the data heterogeneity problem in the original bus route database was effectively solved, significantly improving data readability, consistency, and system compatibility. This standardization achievement not only provides a high-quality data foundation for data modeling, function development, and service integration of the intelligent bus query system, but also creates the necessary conditions for subsequent data analysis, route planning, and information service optimization.

[0045] It is particularly important to note that because the raw bus route data relies on manual experience for compilation, it possesses strong arbitrary and unstructured characteristics, making it unsuitable for directly supporting the operation of automated systems. Therefore, it is essential to first conduct an in-depth analysis of its structural characteristics, clarify the data patterns of various routes, and implement a systematic and standardized transformation process to ensure that the raw data possesses machine-readable, processable, and scalable capabilities. This will enable it to fully support the core functions of intelligent bus systems and ultimately achieve the fundamental goal of improving the quality of public transportation services and user experience.

[0046] Step S110: Obtain the station names from all line information, sort all station names to remove duplicates, and obtain a station array.

[0047] In this embodiment of the invention, to analyze and statistically analyze transportation stops, all route information is traversed to collect all stop names. Duplicates are eliminated using a deduplication mechanism, and then the names are sorted according to preset rules to form a linearly arranged set of stops, i.e., a stop array. This stop array not only ensures the uniqueness of each stop but also provides an ordered structure for its global location, which is a prerequisite for efficient search and index mapping.

[0048] As one possible implementation, the standard line library file "step1.txt" is opened in read-only mode and its file pointer is named fp for reading line information line by line; a new text file "line.txt" is created in write-only mode and its file pointer is named ft for storing the extracted line station sequence.

[0049] Next, we proceed to the field extraction stage: We read all four fields from the current line pointed to by `fp`, denoted as Line Identifier, Pricing Method, Travel Mode, and Line Stop Sequence. The Line Stop Sequence is the target field, containing a series of stop names connected by a specific delimiter.

[0050] Then, a write operation is performed: the extracted d field content is written to the output file "line.txt" pointed to by ft. Each line corresponds to one line, retaining only the line station sequence and removing other irrelevant information, thereby achieving data simplification and focus.

[0051] The above reading and writing process is repeated under loop control, continuously traversing all line records in "step1.txt" until the end of the file, ensuring that the line station sequence of all lines is completely extracted and written to the "line.txt" file.

[0052] The final generated "line.txt" file contains only the sequence of stations for each transportation route, forming a collection of pure station sequences. To further parse the specific station names, further preprocessing is required: the original separators used to separate stations in the station sequences (such as " / ", ";", or "|") are uniformly replaced with spaces, making each station name an independent and recognizable term, facilitating subsequent word segmentation, deduplication, and data analysis.

[0053] Step S120: Determine the subscript of each site name in the site array as the site index corresponding to each site name.

[0054] In this embodiment of the invention, the position of each element in the site array is uniquely identified by its index, which is used as the numerical index value of the corresponding site. For example, the site index of the site name at the beginning of the array is 1 (or 0, depending on the specific implementation), and so on.

[0055] As can be seen, the embodiments of the present invention effectively solve the problem of inconsistent multi-source public transport data structures by standardizing the original information and establishing a subscript-based station indexing mechanism. At the same time, it provides support for the rapid location and efficient retrieval of station information, and improves the automation and computational efficiency of the entire minimum station direct access matrix generation process.

[0056] Optionally, a possible implementation method for generating a deduplicated and sorted list of site names is provided below. The sub-steps of step S110 may include: Construct a site binary sort tree based on all site names; perform an in-order traversal of the site binary sort tree to obtain a site array.

[0057] In an embodiment of the present invention, a binary search tree (BST) is used as the core data structure to support dynamic insertion, fast search, and ordered output. When traversing the sequence of site names of each traffic line, each site name is inserted into the site binary sort tree as a node. During the insertion process, the left or right subtree direction is determined according to the string comparison rule, and it is judged whether the site already exists in the tree before insertion. If it exists, it is skipped, thus achieving automatic deduplication. The site binary sort tree not only effectively eliminates duplicate sites but also forms an ordered hierarchical structure with the site name as the key, providing a data basis for efficiently generating an ordered list subsequently.

[0058] As a possible implementation method, first initialize an empty tree t, where t is the root node of the site binary sort tree. Each node contains three attributes: t.s is used to store the current site name string; t.lchild points to the left subtree, storing sites with a lexicographical order less than the current node name; t.rchild points to the right subtree, storing sites with a lexicographical order greater than the current node name. Through this structure, it can be ensured that sites with the same name are only retained once in the tree, achieving automatic deduplication.

[0059] Next, extract each site name s from the "line.txt" file in sequence and insert it into the site binary sort tree. If t is empty (i.e., there is no node at the current path), create a new node, store s in t.s, and initialize its left and right subtrees to be empty, completing the registration of the new site name; if s < t.s (such as comparing in lexicographical order), recursively search for the insertion position in the left subtree; if s > t.s, recursively search for the insertion position in the right subtree; if s = t.s, it means that the site already exists in the tree and there is no need to add it repeatedly, so directly return and do nothing.

[0060] The above reading and insertion operations are executed in a loop, continuously processing all site names in "line.txt" until the end of the file. During the whole process, the binary sort tree grows dynamically and automatically filters duplicate sites, finally forming an ordered tree structure containing all unique site names.

[0061] After constructing the binary search tree for the sites, an inorder traversal is needed to obtain an ordered list of unique sites. The inorder traversal follows the access order of "left subtree → root node → right subtree". The site names in the binary search tree are saved to a site array and then to the file "count.xls".

[0062] As can be seen, by leveraging the data structure characteristics of a binary search tree, this embodiment of the invention naturally forms an ordered output while completing deduplication, significantly improving the efficiency and stability of large-scale site data processing. It provides an accurate and efficient ordered data foundation for subsequent site index mapping based on array subscripts, and enhances the automation and computational performance of the entire minimum site access matrix generation process.

[0063] Alternatively, one possible implementation for generating the route index table is provided below. Figure 1 The sub-steps of step S20 may include: Step S200: Traverse the route information of each transportation route and obtain the names of the stations to be processed from the route information in sequence.

[0064] In this embodiment of the invention, each standardized route information is read sequentially, and the names of the stations to be processed are obtained one by one from the route station sequence contained in the route information, so as to ensure that each station name in all traffic routes is accessed.

[0065] Step S210: Use binary search to obtain the site index corresponding to the site name to be processed from the site array.

[0066] In this embodiment of the invention, since the station array is an ordered array, a binary search algorithm can be used to quickly narrow down the search range by comparing intermediate elements, thereby locating the position of the station name to be processed (i.e., the station index). This method is significantly better than linear search, especially when dealing with large-scale data of thousands of transportation stations, greatly improving the mapping efficiency from station name to station index and reducing the computational overhead caused by matching duplicate strings.

[0067] Step S220: Determine the station name to be processed in each line information as the corresponding station index to obtain the line index table.

[0068] In this embodiment of the invention, the station names originally stored in text format are replaced one by one with their retrieved integer station indexes, forming a station index list containing only numerical identifiers. The route index table records the list of station indexes contained in each route in a structured manner, facilitating subsequent direct numerical calculations and location relationship analysis.

[0069] As one possible implementation, open the file named `count.xls`, check if it exists and open successfully. If the file cannot be accessed, output an error message and terminate the program. Read the deduplicated and lexicographically ordered station names from the file one by one and store them in the station array `station(i)`. Increment the counter `i` to record the number of stations until the end of the file. Finally, construct an ordered array containing all n unique stations, providing a data foundation for subsequent station indexing and location based on binary search.

[0070] Open the standard route library file named `step1.txt` and check if it opens successfully. If the file does not exist or reading fails, output an error message and terminate the program. Then, read the four fields of each bus route (route number a, fare method b, travel mode c, and route stop sequence d) from the file in sequence, count the number of stops contained in route d, dynamically allocate memory for the route, and store the route number, fare method, and travel mode into `path(i).road`, `path(i).price`, and `path(i).method` respectively.

[0071] Next, each station name `bus_stop` in the route is traversed as the station name to be processed. A binary search algorithm is used to find the station index corresponding to the station name to be processed in the sorted global station array `station(1..n)`. After finding it, the index value is stored sequentially in `path(i).d(j)` (j=1,…,count), thus completing the station index storage for each route and constructing structured route data with stations represented by indexes.

[0072] The binary search algorithm specifically includes defining three integer variables: low, mid, and high. Let low = 1 and high = n, representing the search operation in the station array station(i) (i = 1, 2, ..., n). The search range is defined in (n). The loop condition for the search is set to low ≤ high. This loop will continue until the station name to be processed, bus_stop, is found or the range is determined. In each loop, the midpoint of the current search range, mid, is calculated, i.e., mid = (low + high) / 2.

[0073] Compare the name of the station to be processed, bus_stop, with the current bus station, station(mid) (the station at the current middle position in the station array). If the station bus_stop < station(mid) (i.e., the target station is before the current middle station), then high = mid - 1. If the station bus_stop > station(mid) (i.e., the target station is after the current middle station), then update low = mid + 1. If the station bus_stop is equal to station(mid) (the target station is found), then break out of the loop. After the loop ends, return mid, indicating the station index corresponding to the name of the station to be processed.

[0074] It should be understood that binary search is to find the position of a specified station in a sorted set of bus stations (i.e., the station array) by repeatedly narrowing the search range.

[0075] It can be seen that through the binary search mechanism supported by the ordered array in the embodiments of the present invention, the batch mapping from the station name to the station index is efficiently completed, reducing the string comparison overhead, providing a high-efficiency data access basis for quickly calculating the minimum number of direct stations between any two stations subsequently, and thus overall improving the generation performance of the path matrix in the large-scale bus network.

[0076] Optionally, for how to generate the minimum station direct matrix, a possible implementation is provided below. Figure 1 The sub-steps of step S30 may include: Step S300, determine the station position index of the station index in the corresponding traffic line according to the line index table, and obtain the position index table.

[0077] In the embodiments of the present invention, the line index table records the station indexes included in each traffic line and their arrangement order in the line. Based on the line index table, the relative position of each station index in the running direction of the corresponding traffic line, that is, the station position index, can be obtained. For example, the station position index of the first station is 1, the station position index of the second station is 2, and so on. This process establishes a mapping relationship from the station index to its specific position in a specific line, forming a structured position index table.

[0078] Step S310, determine the minimum number of stations between any two station indexes according to the line index table and the position index table, and obtain the minimum station direct matrix.

[0079] In this embodiment of the invention, after knowing the position of each station index in each traffic route, for any pair of station index combinations of origin and destination, the minimum number of stations between the two station indexes can be determined by checking whether they both appear in the same traffic route and combining the corresponding station position indices, thereby generating a minimum station direct route matrix.

[0080] As can be seen, by introducing a station location indexing mechanism, the embodiments of the present invention avoid repeated parsing of the original station names, significantly reduce the time complexity of path calculation, improve the generation efficiency of the minimum station directness matrix under large-scale transportation networks, and enhance the real-time response capability of the path planning function in intelligent transportation systems.

[0081] Optionally, each record in the route index table includes a route identifier and a list of station indexes. The station index list records all station indexes included on the traffic route according to the direction of travel. Regarding how to generate a location index table based on the route index table, the following is a possible implementation. Sub-steps of step S300 may include: Step S301: Traverse each record in the line index table, and generate the position index corresponding to each station index in each line identifier according to the line identifier, each station index in the station index list, and the position order of each station index in the station index list.

[0082] In this embodiment of the invention, each record in the route index table is traversed, and each traffic route is processed sequentially. For the current record, its route identifier is extracted, and each station index in the station index list is accessed one by one. Since the elements in the station index list are arranged according to the actual direction of vehicle operation, the physical position order of each station index in the list reflects its relative position in the route. For example, if the route identifier is 1, and the station index list includes 3, 2, and 5, then the position index corresponding to station index 5 in route identifier 1 is 3 (assuming that the position index is numbered starting from 1), which can be represented as r(1, 5) = 3.

[0083] Step S302: Generate a location index table based on all station indexes and corresponding location indexes in each line identifier.

[0084] In this embodiment of the invention, each triplet record (line identifier, station index, location index) generated during the aforementioned traversal process is summarized to form a location index table. The location index table supports quick lookup of the specific location of any station index within a particular line, providing a precise basis for subsequent determination of whether two stations are collinear and for calculating the number of stations between them.

[0085] As one possible implementation, read the route index table path(i)(i=1,2, Let $i$ be the number of traffic routes, and let $m$ be the number of integers from 1 to $m$. The current integer is called $i$. For each $i$ value (i.e., route identifier), the corresponding station index list $path(i).d$ is obtained. Each station index in the list is read sequentially (assuming the current element is the $k$-th station index), and the position index $k$ of the station index $path(i).d(k)$ in route identifier $i$ is generated, i.e., $r(i, path(i).d(k)) = k$. The value of $k$ is 1, 2, ..., $m$. `count` represents the total number of stations on the transportation route. A location index table is generated from the station indices and corresponding location indices for all transportation routes.

[0086] As can be seen, by establishing a fine-grained station location mapping mechanism, the embodiments of the present invention provide an accurate location reference for the subsequent efficient calculation of the minimum number of direct stations between any two stations, which significantly improves the accuracy and calculation efficiency of path analysis.

[0087] Optionally, each record in the route index table includes a route identifier and travel mode; each record in the location index table includes a route identifier, a station index, and the corresponding location index. The following provides a possible implementation for generating the location index table based on the route index table. Please refer to... Figure 2 The sub-steps of step S310 may include: Step S311: Determine each site index as the starting index in sequence, and determine the site index that is different from the starting index as the ending index in sequence.

[0088] In this embodiment of the invention, a minimum station reach matrix is ​​generated by traversing all possible combinations of station pairs using a double loop. The outer loop selects one station index as the starting index for the current calculation, while the inner loop selects one from all other station indices as candidate ending indices. This systematically covers all non-self-looping station pairs, establishing an input basis for subsequent calculations of the minimum number of stations pair by pair.

[0089] It should be understood that if the origin index and the destination index are the same, it means that there is no meaning to have direct access to stations in the transportation route. The minimum number of stations between the same origin index and destination index is set to an invalid value (such as ∞).

[0090] Step S312: Traverse the location index table and determine whether the starting point index and the ending point index are on the same transportation route.

[0091] In this embodiment of the invention, a pair of start-point and end-point indices can be randomly determined through the aforementioned double loop. Within the double loop, the location indices on each transportation route are traversed, and it is determined whether the start-point and end-point indices are located on the same transportation route. Specifically, for the current combination of start-point and end-point indices, all records in the location index table are scanned to find whether there is at least one transportation route (i.e., the same route identifier) ​​that simultaneously contains the start-point and end-point indices. If two records sharing the same route identifier and corresponding to the start-point and end-point indices respectively can be found in the location index table, it is determined that the two can be connected by a direct route; otherwise, it is considered that there is no direct path.

[0092] As one possible implementation, assume that transportation route 1 includes 5 stations with station indices of 3, 5, 1, 7, and 9. The records for transportation route 1 in the location index table are {r(1,3)=1, r(1,5)=2, r(1,1)=3, r(1,7)=4, r(1,9)=5}. Based on the records for transportation route 1 in the location index table, determine whether both the origin and destination indices are on the transportation route.

[0093] Step S313: If the origin index and the destination index are not on the same traffic route, set the minimum number of stations between the origin index and the destination index to an invalid value.

[0094] In this embodiment of the invention, assuming the starting point index is 3 and the ending point index is 8, a comparison with {r(1,3)=1, r(1,5)=2, r(1,1)=3, r(1,7)=4, r(1,9)=5} reveals that the starting point index is in transportation route 1, while the ending point index is not. Therefore, the minimum number of stops between the starting point index 3 and the ending point index 8 is set to an invalid value. An invalid value is typically represented by infinity or a preset special marker value, indicating that there is no direct route between these two stops, making direct access impossible via a single bus route. This result will be retained as an unreachable state during subsequent matrix filling.

[0095] It should be understood that if other transportation routes are subsequently traversed, and it is determined that the starting point index 3 and the ending point index 8 are both on other transportation routes, then the minimum number of stations between the starting point index and the ending point index will be updated.

[0096] Step S314: If the starting point index and the ending point index are on the same traffic line, obtain the target route identifier of the traffic line where the starting point index and the ending point index are located, and determine the minimum number of candidate stations between the starting point index and the ending point index according to the driving mode corresponding to the target route identifier in the route index table, the location index corresponding to the starting point index in the record where the target route identifier is located in the location index table, and the location index corresponding to the ending point index in the record where the target route identifier is located in the location index table; the number of the same traffic line where the starting point index and the ending point index are located is consistent with the number of minimum candidate stations.

[0097] In this embodiment of the invention, for each route identifier that makes the start index and the end index co-occur, the system extracts the respective location indexes (i.e., their sequential numbers in the route station sequence) from the location index table, and calculates the number of stations passed through in the route by combining the travel mode of the traffic route (such as one-way, two-way or circular).

[0098] If the location index of the destination index is greater than the location index of the origin index, then the minimum number of candidate stations corresponding to the target traffic sign (i.e., the number of interval stations between the origin index and the destination index on the traffic line corresponding to the target traffic sign) is the difference between the location index of the destination index and the location index of the origin index.

[0099] If the location index of the destination index is less than the location index of the origin index, then the travel mode corresponding to the target route identifier in the route index table is retrieved. If the travel mode corresponding to the target route identifier is bidirectional, then the minimum number of candidate stations corresponding to the target traffic identifier is the difference between the location index of the origin index and the location index of the destination index. If the travel mode corresponding to the target route identifier is circular, then the minimum number of candidate stations corresponding to the target traffic identifier is the total number of stations on the traffic line corresponding to the target route identifier minus 1 and the location index of the origin index, plus the location index of the destination index.

[0100] Continuing with transportation route 1 as an example, assuming the starting point index is 3 and the ending point index is 7, comparing it with {r(1,3)=1, r(1,5)=2, r(1,1)=3, r(1,7)=4, r(1,9)=5}, we know that both the starting point and ending point indices are on transportation route 1. Therefore, the target route identifier is 1. From the record {r(1,3)=1, r(1,5)=2, r(1,1)=3, r(1,7)=4, r(1,9)=5} containing the target route identifier 1 in the location index table, we obtain the location indices of the starting point and ending point, which are 1 and 4 respectively. In other words, the minimum number of candidate stations between the starting point index 3 and the ending point index 7 on transportation route 1 is 3.

[0101] It should be understood that if the origin index and the destination index are not on any transportation route, meaning that the origin index and the destination index cannot be directly reached, then the minimum number of stops between the origin index and the destination index will ultimately be an invalid value. If the origin index and the destination index appear on multiple transportation routes, then there are multiple candidate minimum number of stops for the origin index and the destination index.

[0102] Step S315: Determine the minimum value among all candidate minimum station numbers between the start index and the end index as the minimum station number between the start index and the end index; form the minimum station directness matrix from all minimum station numbers between the start index and the end index.

[0103] In this embodiment of the invention, the minimum number of candidate stations between the starting point index and the ending point index is compared, and the minimum value is selected as the minimum number of stations between the starting point index and the ending point index to ensure that the recommended path is optimal. Specifically, each time a candidate minimum number of stations is calculated, it is compared with the current minimum number of stations (the current minimum value), and the smaller of the two is set as the latest minimum number of stations. Alternatively, multiple candidate minimum number of stations can be recorded, and after traversal, the minimum value is selected as the minimum number of stations between the starting point index and the ending point index. This invention does not limit the scope of the invention.

[0104] After all combinations of origin and destination indices have undergone the above processing, the accumulated minimum station counts are organized in a two-dimensional matrix to form a complete minimum station direct route matrix, which is used to support route query and optimization decisions in the intelligent public transportation system.

[0105] As can be seen, this embodiment of the invention, by sequentially determining each station index as the starting point index and traversing all different ending point indices, can systematically enumerate the direct path relationships of all station pairs. Utilizing the travel mode in the route index table and the location information in the location index table, it can accurately determine whether two stations are collinear, and calculate the minimum number of candidate stations based on their relative positions on the route and the route's operating characteristics. For station pairs covered by multiple routes, the minimum value is selected as the final result, ensuring path optimality. While ensuring calculation accuracy, it significantly improves the efficiency of generating the minimum station direct path matrix in large-scale public transport networks, enhancing the real-time performance and reliability of intelligent transportation system route planning.

[0106] Optionally, each record in the route index table includes a travel mode and a list of station indexes. The station index list records all station indices along the travel route in the direction of travel. The following provides a possible implementation for generating the minimum station direct route matrix. Figure 1 The sub-steps of step S30 may include: Step S320: Traverse each station index list in the route index table, and determine the station index in the station index list as the starting point index, and determine the station index in the station index list that is different from the starting point index as the ending point index.

[0107] In this embodiment of the invention, station combinations are obtained by traversing the station index list of each transportation route to generate a minimum station direct access matrix based on the station index traversal of the transportation route. First, each station index list in the route index table is traversed. Then, for the current route's station sequence, each station index is sequentially determined as the starting point index, and each subsequent station index different from it in the list is determined as the ending point index. This operation completes the enumeration of all possible starting-ending point pairs within a single route, ensuring that all station pairs directly accessible via the route are covered, while avoiding the overhead of judging invalid combinations across routes, thus improving processing efficiency.

[0108] Step S330: Calculate the number of interval stations between the starting point index and the ending point index based on the distance between them and the corresponding travel mode; the number of stations on the same traffic line where the starting point index and the ending point index are located is consistent with the number of interval stations.

[0109] In this embodiment of the invention, if the position index of the endpoint index is greater than the position index of the starting point index, then the number of stations between the starting point index and the endpoint index is the difference between the position index of the endpoint index and the position index of the starting point index.

[0110] If the location index of the destination index is less than the location index of the origin index, then the corresponding travel mode is obtained. If the travel mode is bidirectional, the number of stations between the origin and destination indices is the difference between their location indices. If the travel mode is circular, the number of stations between the origin and destination indices is the total number of stations on the route minus 1, the location index of the origin index, and then the location index of the destination index.

[0111] Step S340: Determine the minimum number of all interval stations between the start index and the end index as the minimum number of stations between the start index and the end index; form the minimum station directness matrix by the minimum number of stations between all start indices and the end index.

[0112] In this embodiment of the invention, the minimum number of all interval stations calculated across all relevant routes between the origin and destination indices is taken as the minimum number of stations between them, reflecting the length of their optimal direct path. The combination of the minimum number of stations for all station pairs constitutes the complete minimum station direct path matrix. It should be understood that the elements of the minimum station direct path matrix can initially be initialized to invalid values.

[0113] As can be seen, the embodiments of the present invention avoid redundant calculations between unrelated stations by directly traversing and calculating within the traffic lines, effectively reducing the global query overhead, and significantly improving the generation efficiency of the minimum station direct access matrix while ensuring the accuracy of the results. It is especially suitable for real-time data processing scenarios of large-scale public transportation networks.

[0114] To compare the differences between the two methods for generating the minimum number of stations for direct routes provided in this invention and the existing methods for generating the minimum number of stations for direct routes, performance comparison and analysis are conducted through experiments.

[0115] First, configure the experimental environment: (1) Software development environment: Windows 7 operating system, Microsoft Visual Studio 2008 development tool; (2) Software operation environment: Windows 11 operating system; (3) Hardware development environment: Dell Vostro 220 PC, configured as follows: a) Processor: Intel® Pentium® Dual-Core CPU 2.70GHz; b) Memory: 2GB DDR3 SDRAM; Hard disk 320GB SATA (7200RPM). (4) Hardware operation environment: Dell Vostro 220PC; (5) Programming language and version: Microsoft Visual C++ 6.0.

[0116] Next, the experimental data was obtained: the data came from the public transport database file B2007data.rar (36.3KB) published on the official website of the National Undergraduate Mathematical Modeling Contest (https: / / www.mcm.edu.cn / html_cn / node / a6b7310adbb9eac56152a6815a759986.html). After downloading, the original public transport route database underwent standardized preprocessing, including data cleaning, format unification, and redundant information removal. After standardization, a dataset containing 929 standard public transport routes and 3957 public transport stops was finally obtained, with all stops arranged in ascending order to form an ordered set.

[0117] Subsequently, three different traversal methods are used to calculate the minimum station directness matrix: traversal by bus stops, traversal by station index, and traversal by station index based on related transportation routes. Among them, traversal by station index and traversal by station index based on related transportation routes are two methods provided in this embodiment of the invention for generating the minimum station directness matrix, while traversal by bus stops is a traditional traversal method in the prior art.

[0118] It should be noted that in the process of generating the shortest station direct matrix through bus stop traversal, in the process of "calculating the shortest station direct matrix and time statistics", the necessary variable definitions and initializations are first completed, including string variables s1, s2, and s12 (limited to a maximum length of 10 characters) for operating station names, a file pointer fp for writing result data, a character pointer array station for storing the station names of all buses after deduplication and sorting, an integer variable count for recording the station distance in the current line, loop variables i and j for traversing station pairs, the total number of stations n, and time variables begin_t and end_t are introduced to accurately calculate the algorithm execution time. Subsequently, the program calls the clock() function to obtain the start time and assigns it to begin_t, officially starting the timing for subsequent evaluation of the algorithm efficiency.

[0119] Next, enter the core calculation stage. The program opens the output file "shortest.xls" in write mode, preparing to write the generated shortest station direct matrix into it. Through a double-loop structure, the system traverses all possible station pairs (i, j), where both i and j range from 1 to n. For each pair of different stations (i.e., i ≠ j), the program calls the direct1(begin, end) function for calculation.

[0120] The core function of the direct1 function is to read the line information one by one in the standard bus line library. If the starting station begin and the ending station end are different, find the positions (flag1 and flag2) of the starting station begin and the ending station end in the same line, and judge whether they can be directly reached according to the line type (one-way, two-way or circular), and calculate the minimum number of stations passed between them.

[0121] If the two stations are on the same line and meet the driving direction requirements, find the positions (flag1 and flag2) of begin and end in line d, and count the minimum number of stations between the starting station begin and the ending station end on the current line. If both begin and end exist: (1) flag2 > flag1: dist = (flag2 - flag1) / size; (2) flag2 < flag1 and c = "two-way": dist = (flag1 - flag2) / size; (3) flag2 < flag1 and c = "circular": dist = count - 1 - (flag1 - flag2) / size; (4) dist < minl, update minl = dist. Among them, minl is used to store the minimum number of stations and is initialized to ∞; size is the station length.

[0122] If the starting station (begin) and the ending station (end) are the same, it means that the starting and ending stations are the same station. In this case, the minimum number of stations between the starting station (begin) and the ending station (end) is set to infinity (∞), indicating that no transfer is needed or the distance is zero. After each calculation, the minimum number of stations is written to the output file, and the complete n×n minimum station direct route matrix is ​​gradually constructed.

[0123] After all station pairs have been calculated, the program calls the clock() function again to obtain the end time end_t, and calculates the total time as end_t - begin_t (in milliseconds). This time value is then output to reflect the overall efficiency of the matrix generation process. This method searches each route based on string matching of station names, but because it requires repeatedly traversing all routes for each station pair, it incurs huge computational overhead, exhibiting a significant performance bottleneck, especially in large-scale public transport networks.

[0124] It should be noted that during the experiment, the computation time of the three different traversal methods for generating the minimum station reach matrix was obtained through precise timing (unit: seconds), and detailed data records are shown in Table 1. To ensure the reliability of the experimental results, each method was run independently three times, and the average value was taken as the final result. Variables were strictly controlled during the experiment to ensure that the performance of different methods was compared under the same data and hardware environment.

[0125] Table 1

[0126] Based on the experimental data in Table 1, the following conclusions can be drawn: First, generating the minimum direct route matrix using the traditional bus stop traversal method takes approximately 44.9 hours (161,641.471 seconds), which is extremely inefficient when processing large-scale public transport network data. Second, using the bus stop index traversal method significantly reduces the computation time to 2.69 minutes (161.457 seconds), demonstrating a significant performance improvement brought about by index optimization. Finally, the station index traversal method based on related transportation routes can complete all calculations in just 0.531 seconds, exhibiting extremely high computational efficiency.

[0127] A quantitative comparative analysis of the computational efficiency of the three methods revealed that: the computation time of the bus stop traversal method is 1001 times that of the stop index traversal method; the computation time of the stop traversal method is 304,409 times that of the stop index traversal method based on related transportation routes; and the computation time of the stop index traversal method is 304 times that of the stop index traversal method based on related transportation routes. Therefore, the efficient direct route minimum stop generation method provided by this invention not only significantly reduces computation time costs but also provides reliable technical support for real-time bus dispatching systems and intelligent route planning algorithms.

[0128] Based on the same inventive concept, the basic principle and technical effects of the direct route minimum station generation device provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0129] Please refer to Figure 3 , Figure 3 This is a block diagram of a direct route minimum station generation device 400 provided in an embodiment of the present invention. The direct route minimum station generation device 400 includes an acquisition module 410, a processing module 420, and a determination module 430.

[0130] The acquisition module 410 is used to sort the station names included in all transportation routes and determine the station index corresponding to each station name based on the sorting result. The processing module 420 is used to update the station names in the route information of each transportation route to the corresponding station index, thereby obtaining a route index table; the route index table is used to record the station indexes contained in each transportation route. The determination module 430 is used to determine the minimum number of stations between any two station indices based on the line index table, and obtain the minimum station direct route matrix; the minimum station direct route matrix is ​​used to record the minimum number of stations for direct routes between any two stations.

[0131] In summary, the minimum station generation device for direct routes provided in this embodiment sorts the station names included in all transportation routes and updates the station names in the route information of each transportation route with station indices. This transforms unstructured station names into ordered numerical identifiers, achieving standardized and indexed representation of route data. Based on the route index table, it directly calculates the minimum number of stations on the same route between any two station indices, ultimately generating a minimum station direct route matrix covering all station pairs. By introducing a station index mechanism, it avoids frequent string matching operations in traditional methods, significantly reducing the time complexity of data lookup and path calculation, thereby improving the generation efficiency of the minimum station direct route matrix in large-scale public transportation networks and enhancing the real-time response capability of the route planning function in intelligent public transportation systems.

[0132] Optionally, the acquisition module 410 is specifically used to acquire the original information of all transportation routes, and to standardize the original information to obtain the route information of all transportation routes; to acquire the station names from all route information, to sort all station names by deduplication, and to obtain a station array; and to determine the subscript of each station name in the station array as the station index corresponding to each station name.

[0133] Optionally, module 410 is used to construct a binary search tree for sites based on all site names; and to perform an inorder traversal of the binary search tree to obtain a site array.

[0134] Optionally, the processing module 420 is specifically used to traverse the route information of each transportation route, sequentially obtain the station names to be processed from the route information; use binary search to obtain the station index corresponding to the station name to be processed from the station array; and determine the station name to be processed in each route information as the corresponding station index to obtain the route index table.

[0135] Optionally, the determining module 430 is specifically used to determine the station location index of the station index in the corresponding traffic line according to the route index table, and obtain the location index table; and to determine the minimum number of stations between any two station indices according to the route index table and the location index table, and obtain the minimum station direct access matrix.

[0136] Optionally, each record in the route index table includes a route identifier and a list of station indexes. The list of station indexes records all station indexes included on the traffic route according to the direction of travel. The determination module 430 is specifically used to traverse each record in the route index table, generating a position index corresponding to each station index in each route identifier based on the route identifier, each station index in the station index list, and the position order of each station index in the station index list; and generating a position index table based on all station indexes and their corresponding position indexes in each route identifier.

[0137] Optionally, each record in the route index table includes a route identifier and a mode of transportation; each record in the location index table includes a route identifier, a station index, and a location index corresponding to the station index. The determination module 430 is specifically used to sequentially determine each station index as a starting point index, and sequentially determine the station indexes that differ from the starting point index as the ending point index.

[0138] Traverse the location index table and determine whether the origin index and the destination index are on the same transportation route; if the origin index and the destination index are not on the same transportation route, set the minimum number of stations between the origin index and the destination index to an invalid value.

[0139] If the origin index and the destination index are on the same transportation route, obtain the target route identifier of the transportation route where the origin index and the destination index are located, and determine the minimum number of candidate stations between the origin index and the destination index based on the driving mode corresponding to the target route identifier in the route index table, the location index corresponding to the origin index in the record where the target route identifier is located in the location index table, and the location index corresponding to the destination index in the record where the target route identifier is located in the location index table. The number of the same transportation route where the origin index and the destination index are located is consistent with the number of minimum candidate stations.

[0140] The minimum number of candidate minimum stations between the start index and the end index is determined as the minimum number of stations between the start index and the end index; the minimum station directness matrix is ​​composed of the minimum number of stations between all start indices and the end index.

[0141] Optionally, each record in the route index table includes a travel mode and a list of station indexes. The list of station indexes records all station indexes included on the traffic route according to the travel direction. The determination module 430 is specifically used to traverse each list of station indexes in the route index table, determining the station indexes in the list of station indexes as the starting point indexes, and determining the station indexes in the list of station indexes that are different from the starting point indexes as the ending point indexes.

[0142] The number of interval stations between the origin and destination indices is calculated based on the distance between them and the corresponding mode of transportation. The number of stations on the same transportation route where the origin and destination indices are located is the same as the number of interval stations.

[0143] The minimum number of all interval stations between the start index and the end index is determined as the minimum number of stations between the start index and the end index; the minimum station directness matrix is ​​composed of the minimum number of stations between all start indices and the end index.

[0144] Please refer to Figure 4 This is a block diagram of an electronic device 500 provided in an embodiment of the present invention. The electronic device 500 includes, but is not limited to, a personal computer (PC), a server, a portable computer, etc. The electronic device 500 includes a memory 510, a processor 520, and a communication module 530. The memory 510, processor 520, and communication module 530 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.

[0145] The memory 510 is used to store programs or data. The memory 510 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0146] The processor 520 is used to read / write data or programs stored in the memory 510 and perform corresponding functions. For example, when a computer program stored in the memory 510 is executed by the processor 520, the direct route minimum station generation method disclosed in the above embodiments can be implemented.

[0147] The communication module 530 is used to establish a communication connection between the electronic device 500 and other communication terminals via a network, and to send and receive data via the network.

[0148] It should be understood that, Figure 4 The structure shown is only a schematic diagram of the electronic device 500. The electronic device 500 may also include components that are larger than... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown. Figure 4 The components shown can be implemented using hardware, software, or a combination thereof.

[0149] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 520, implements the direct route minimum station generation method disclosed in the above embodiments.

[0150] This invention also provides a program product that, when executed by processor 520, implements the method for generating the minimum number of stations for direct routes disclosed in the above embodiments.

[0151] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0152] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0153] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0154] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A direct line minimum station generation method characterized by, The method comprises: sorting station names contained in all traffic lines, and determining station indexes corresponding to the station names according to a sorting result; updating station names in line information of each of the traffic lines into corresponding station indexes to obtain a line index table; the line index table is used to record station indexes contained in each traffic line; determining a minimum number of stations between any two station indexes according to the line index table to obtain a minimum station direct reach matrix; the minimum station direct reach matrix is used to record a minimum number of stations of a direct reach line between any two stations.

2. The direct route minimum station generation method according to claim 1, characterized by, The sorting of station names contained in all traffic lines and the determination of station indexes corresponding to the station names according to a sorting result comprise: obtaining original information of all traffic lines, and performing standardization processing on the original information to obtain line information of all traffic lines; obtaining station names from all the line information, and performing de-duplication sorting on all the station names to obtain a station array; determining a subscript of each of the station names in the station array as a station index corresponding to the station name.

3. The direct route minimum station generation method according to claim 2, characterized by, The de-duplication sorting of all the station names to obtain a station array comprises: constructing a station binary sorting tree according to all the station names; performing in-order traversal on the station binary sorting tree to obtain the station array.

4. The direct route minimum station generation method according to claim 2, characterized by, The updating of station names in line information of each of the traffic lines into corresponding station indexes to obtain a line index table comprises: traversing line information of each of the traffic lines, and sequentially obtaining a station name to be processed from the line information; obtaining a station index corresponding to the station name to be processed from the station array by using binary search; determining the station name to be processed in each of the line information as the corresponding station index to obtain a line index table.

5. The direct route minimum station generation method of claim 1, wherein, The determination of a minimum number of stations between any two station indexes according to the line index table to obtain a minimum station direct reach matrix comprises: determining a station position index of the station index in a traffic line to which the station index belongs according to the line index table to obtain a position index table; determining a minimum number of stations between any two station indexes according to the line index table and the position index table to obtain a minimum station direct reach matrix.

6. The direct route minimum station generation method according to claim 5, characterized by, Each record of the line index table comprises a line identifier and a station index list, and the station index list is used to record all station indexes contained in a traffic line in a driving direction; The determination of a station position index of the station index in a traffic line to which the station index belongs according to the line index table to obtain a position index table comprises: traversing each record of the line index table, and sequentially generating a position index corresponding to each of the station indexes in each of the line identifiers according to the line identifier, each of the station indexes in the station index list, and a position order of each of the station indexes in the station index list; generating the position index table according to all the station indexes in each of the line identifiers and corresponding position indexes.

7. The direct route minimum station generation method according to claim 5, wherein Each record of the line index table comprises a line identifier and a travel mode; each record of the position index table comprises a line identifier, a station index and a position index corresponding to the station index; The determining of the minimum number of stations between any two station indexes according to the line index table and the position index table comprises: Each station index is determined as a starting point index in turn, and all station indexes different from the starting point index are determined as ending point indexes in turn; It is judged whether the starting point index and the ending point index are on the same transportation line by traversing the position index table; If the starting point index and the ending point index are not on the same transportation line, the minimum number of stations between the starting point index and the ending point index is set as an invalid value; If the starting point index and the ending point index are on the same transportation line, a target line identifier of the transportation line where the starting point index and the ending point index are located is obtained, and a candidate minimum number of stations between the starting point index and the ending point index is determined according to a travel mode corresponding to the target line identifier in the line index table, a position index corresponding to the starting point index in a record where the target line identifier is located in the position index table and a position index corresponding to the ending point index in the record where the target line identifier is located in the position index table; the number of the same transportation lines where the starting point index and the ending point index are located is consistent with the number of the candidate minimum number of stations; The minimum value of all candidate minimum numbers of stations between the starting point index and the ending point index is determined as the minimum number of stations between the starting point index and the ending point index; the minimum number of stations between all starting point indexes and ending point indexes forms the minimum station direct matrix.

8. The direct route minimum station generation method of claim 1, wherein, Each record of the line index table comprises a travel mode and a station index list, and the station index list is used to record all station indexes contained on a transportation line in a travel direction; The determining of the minimum number of stations between any two station indexes according to the line index table comprises: Each station index in the station index list is determined as a starting point index in turn by traversing each station index list in the line index table, and station indexes different from the starting point index in the station index list are determined as ending point indexes; The number of the same transportation lines where the starting point index and the ending point index are located is consistent with the number of interval station numbers between the starting point index and the ending point index, which are calculated according to a distance between the starting point index and the ending point index and a corresponding travel mode; The minimum value of all interval station numbers between the starting point index and the ending point index is determined as the minimum number of stations between the starting point index and the ending point index; the minimum number of stations between all starting point indexes and ending point indexes forms the minimum station direct matrix.

9. A direct line minimum station generation apparatus characterized by comprising: The device comprises: An acquisition module, configured to sort station names contained in all transportation lines, and determine station indexes corresponding to the station names according to a sorting result; The processing module is used for updating the station name in the line information of each traffic line into the corresponding station index to obtain a line index table; the line index table is used for recording the station index contained in each traffic line; The determining module is used for determining the least number of stations between any two station indexes according to the line index table to obtain a least station direct line matrix; the least station direct line matrix is used for recording the least number of stations of the direct line between any two stations.

10. An electronic device, comprising: The processor and the memory are included, the memory stores a computer program capable of being executed by the processor, and the processor can execute the computer program to implement the direct line least station generation method in any one of claims 1-8.