An Improved Prim Algorithm for Connection Scheme of Last Train in Urban Mass Transit Network

: In the network operation stage of urban mass transit, the connection relations between lines can e ﬀ ectively improve travel accessibility. As the last opportunity to travel on the same day, whether the last train can achieve transfer will directly a ﬀ ect passengers’ travel experiences. It is an important work to make the connection scheme of the last train, which needs to take the network structure, the trend, and the volume of passenger ﬂow into overall consideration. This paper analyzes the characters of the last train connection, including the connection structure and the accessible form. Then, we establish a scheme model and deﬁne the objectives, the constraints, and the decision data source, and transform it into a graph theory problem. Taking an urban mass transit network as an example, we demonstrate the solution process by using an improved Prim algorithm. Finally, the main aspects and methods of initial scheme optimization are proposed.


Introduction
Punctuality of urban rail transit and rationality of transfer connection are important factors in improving service quality and attracting passengers to travel by public transport [1]. The last train is the last opportunity for passengers to travel on the same day. The transfer connection sequence and the departure time of the last train have more direct impacts on passengers' travel experiences. Influenced by the transfer relations between lines, the connection scheme should not be aimed at a single line but should consider the whole network and implement overall coordination. Therefore, the objective and the basis of decision-making are the first issues to be considered.

Related Works on Last Train Connection Scheme
The last train connection scheme problem belongs to the category of transportation system planning and optimization. Transportation system planning and optimization can usually be solved by operational research approaches, which include linear and nonlinear programming, nonsmooth and no convex optimization, integer programming, solving problems on graphs or with mixed variables, and heuristic approaches such as genetic algorithms [2][3][4]. At present, the connection scheme of the last train in the network has received extensive attention in the industry, and some scholars have carried out relevant research.
Aiming at the transfer connection problem, the existing research mainly sets the scheme objective to reduce the total waiting time of passengers at the transfer station. The research methods used include a mixed integer programming model [5][6][7][8][9], a non-linear mathematical programming model [10], and a genetic algorithm [11][12][13][14]. The main influencing factors for decision-making to be considered in the model construction include transfer forms, walking distance, and passenger volume at the transfer station [15]. In addition, some scholars have proposed multi-objective programming models. In literature [16], the authors take the minimized transfer waiting times and transfer dissatisfaction as the objectives and give priority to major passengers. In literatures [17,18], the authors propose to reduce passengers' transfer waiting times and inaccessible passenger volume of all origin-destination as well as to improve passengers' accessible reliability for the last trains. In literature [19], the authors take the maximized passenger satisfaction, the minimized train trip time, and the network energy consumption as objectives. Timetable or real-time control can be adopted in the transfer connection coordination mode of the last train [20]. Timetable coordination should first determine the departure time domain of the last train [21], and then, by optimizing the timetables of the last train on each line, it can achieve a good connection at transfer stations, thus achieving the optimal scheme objectives [22][23][24][25]. Real-time control coordination is mainly aimed at train delay under unexpected events and proposes a dispatch coordination model of the last train. By adjusting the arrival and the departure time of the last train on the affected lines and transfer lines, it minimizes the impact of emergencies [26][27][28][29]. In addition, taking service quality as the starting point, some scholars put forward last train passenger travel guidance to provide decision-making reference for the accessibility of Origin-Destination and the choice of transfer routes [30][31][32].

Novelties and Contributions
We comprehensively compare various research viewpoints in the industry and put forward the last train connection scheme model aimed at achieving maximum transfer passenger volume.
In the process of model building, we consider the factors of transfer passenger volume, transfer connection structure, category of operating days, and non-passenger flow constraints. We put forward the calculation method of the last train connection sequence and departure time of each line in the timetable planning stage. This model has good applicability for various types of network structures. The main novelties and contributions of our works are listed below.
(1) This paper transforms the last train connection scheme problem into a graph theory problem and constructs a scheme model aimed at maximizing the last train transfer volume, thus the practical scheme requirements can be solved mathematically. (2) This paper proposes to use a Prim algorithm to solve the maximum spanning tree and proposes a table operation method in the process of solving. (3) This paper applies big data. The big historical data of transfer volume in the last train time domain are used as the basis of solving the maximum spanning tree. (4) From the aspects of model building, algorithm selection, and application of basic data, we believe that we propose a new method about last train connection scheme.

Connection Structure of Urban Mass Transit Network
For transfer stations, there may be different situations, such as double-line or multi-line transfer. However, in any case, a transfer connection relation is generated by only two lines. The overall connection structure is the combination of connection structures between two lines. The connection structure between two lines mainly includes the following basic types. As shown in Figure 1d, there are multiple transfer stations between two lines. At each transfer station, the form of transfer may be cross, T or L.

Accessibility Form of Last Train Transfer
In the urban mass transit network, lines are connected by transfer stations. Every transfer connection relation is formed by any two directions passing through the transfer station, and we define it as a transfer connection pair. Because of the two directions of each line, multiple connection pairs can be formed between two lines. For the accessibility of last train transfer, there are three situations: double connection, single connection, and no connection.

Double Connection
Double connection means that, in a transfer connection pair, the passengers of the last train in both directions can transfer to the other direction. Taking Figure 2a as an example, the down directions of line A and line B can transfer to each other. To achieve double connection of the last train, both the station dwell times of the two last trains at the transfer station should not be less than the sum of the arrival time difference and the passenger's transfer time. This situation has higher requirements on the structure of transfer corridor and station dwell time. In the actual operation of urban rail transit, it is mainly suitable for some special situations, such as one-platform transfer.

Single Connection
Single connection means that, in a transfer connection pair, only one transfer can be achieved between the two last trains, as shown in Figure 2b. It is a normal situation of transfer connection.

No Connection
No connection means that, in a transfer connection pair, no transfer can be achieved between the two last trains, as shown in Figure 2c. When the station dwell time difference between the two last trains is less than the passenger's transfer time, this situation will occur. This situation should be avoided in the planning of a timetable.

Transfer at Multiple Stations
As shown in Figure 1d, there are multiple transfer stations between two lines. At each transfer station, the form of transfer may be cross, T or L.

Accessibility Form of Last Train Transfer
In the urban mass transit network, lines are connected by transfer stations. Every transfer connection relation is formed by any two directions passing through the transfer station, and we define it as a transfer connection pair. Because of the two directions of each line, multiple connection pairs can be formed between two lines. For the accessibility of last train transfer, there are three situations: double connection, single connection, and no connection.

Double Connection
Double connection means that, in a transfer connection pair, the passengers of the last train in both directions can transfer to the other direction. Taking Figure 2a as an example, the down directions of line A and line B can transfer to each other. To achieve double connection of the last train, both the station dwell times of the two last trains at the transfer station should not be less than the sum of the arrival time difference and the passenger's transfer time. This situation has higher requirements on the structure of transfer corridor and station dwell time. In the actual operation of urban rail transit, it is mainly suitable for some special situations, such as one-platform transfer.

Scheme Objective of Last Train Connection
Due to the diversity of passenger Origin-Destination, there may be transfer needs between any two directions in the network. As mentioned in Section 2.2, the normal accessibility form of last train transfer is single connection. Therefore, no matter how the last train timetable is developed, there will be passenger flow of successful transfer and failure transfer. To improve service quality, operators should make a reasonable connection scheme for last train to maximize the passenger transfer and to guide passengers to avoid failure transfer.
Considering the actual demand above, this paper puts forward the goal of achieving the

Single Connection
Single connection means that, in a transfer connection pair, only one transfer can be achieved between the two last trains, as shown in Figure 2b. It is a normal situation of transfer connection.

No Connection
No connection means that, in a transfer connection pair, no transfer can be achieved between the two last trains, as shown in Figure 2c. When the station dwell time difference between the two last trains is less than the passenger's transfer time, this situation will occur. This situation should be avoided in the planning of a timetable.

Scheme Objective of Last Train Connection
Due to the diversity of passenger Origin-Destination, there may be transfer needs between any two directions in the network. As mentioned in Section 2.2, the normal accessibility form of last train transfer is single connection. Therefore, no matter how the last train timetable is developed, there will be passenger flow of successful transfer and failure transfer. To improve service quality, operators should make a reasonable connection scheme for last train to maximize the passenger transfer and to guide passengers to avoid failure transfer.
Considering the actual demand above, this paper puts forward the goal of achieving the maximum transfer passenger volume within the network.

Constraints on the Connection Scheme of Last Train
The last train connection scheme is based on transfer passenger flow and is also constrained by a variety of conditions. For example, due to the demands of passengers' night travel and maintenance time after operation, the last train time should not be earlier than 22:30 or later than 24:00. The lines extending from urban areas to suburbs, especially those connecting large residential areas, should first guaranty transport of passengers on the last train. This determines that some connection relations need to be prioritized. When there are planned large-scale night events, considering the location of the exercise yard, we should temporarily adjust the last train connection scheme and timetable for the whole network.

Data Source for Transfer Passenger Flow of Last Train
In a narrow sense, the transfer passenger flow of the last train is composed of passengers who take the last train and achieve transfer. However, the formation of the passenger flow is affected by the existing connection sequence of the last train, and that cannot accurately reflect the passengers' demand for last train travel. Based on the facts, we assume that passengers have the ability to make rational decisions. When passengers have last train travel demand and Origin-Destination is not accessible, they will adopt flexible schemes, such as early travel. That is to say, the passenger flow in the last train time domain can be regarded as the potential passenger flow of the last train. Therefore, in a broad sense, the transfer passenger flow in the last train time domain is taken as the transfer passenger flow of the last train. This can be the decision basis of the last train connection scheme.

Minimum Spanning Tree Problem
Graph theory is an important research method for traffic planning. A graph is a typical non-linear structure. Its essential content is the connection relations between vertices and edges, also known as the topological structure relationship. Given an undirected and a connected graph, G = (V, E), V is a finite non-empty set of vertices, E is a finite non-empty set of edges, e(u, v) represents the edges connecting vertices u and v, and w(u, v) represents the weights of the edges. Assuming that the total number of vertices of graph G is N, if a subgraph containing N − 1 edges can connect its N vertices without forming a loop, it is said that the subgraph T is the spanning tree of graph G. The spanning tree with the minimal weight is the minimal spanning tree of the connected graph, or MST for short [30]. The equation is as follows:

Graph Theory Representation for Connection Scheme of Last Train
To achieve the optimal objective, firstly, we transform the last train connection scheme problem into a graph theory problem. The key lies in converting the connection structure of the network into a connected graph and expressing the connection as the relationship between vertices and edges.

Representation of Vertices and Edges
As mentioned in Section 2.2, every transfer connection relation is formed by any two directions passing through the transfer station. In a connected graph, two vertices join to form an edge. We define the up and down directions of each line as vertices and the connection pairs as edges of the connected graph. When applied to the whole network, the connection structure of the network can be transformed into a connected graph, G = (V, E), where V is the set of vertices, E is the set of edges, the up or down direction of each line is the vertex, recorded as v and v ∈ V, and the connection pair is the edge, recorded as e and e ∈ E.

Representation of Weights
The weights of edges are the basis for solving the minimum spanning tree problem. The connection scheme of the last train is based on the transfer passenger volume. It should be defined as the weight of each edge, recorded as w.

Representation of Scheme Objective
To solve the minimum spanning tree of a connected graph, N − 1 edges are needed to connect N vertices. To solve the connection scheme of the last train, it is necessary to define N − 1 connection sequences for N directions. For a weighted undirected graph, the principle of solving a minimum spanning tree is the same as that of a maximum spanning tree. The objective of the last train connection scheme is to achieve maximum transfer passenger volume. It can be expressed as solving the maximum spanning tree problem with transfer passenger volume as the weight. The equation is as follows: where i and j represent the line number, p and q represent the line direction, and its value is 1 or 2. When the value is 1, it represents the up direction; when the value is 2, it represents the down direction.
T is the spanning tree of the connected graph, G.

Algorithms for Solving Minimum Spanning Tree Problem
For the minimum spanning tree problem, the commonly used algorithms include a Kruskal algorithm, a Prim algorithm, and so on [33][34][35].

Prim Algorithm
A Prim algorithm is a construction algorithm. The idea of constructing a minimum spanning tree is as follows.
Suppose that U ∈ V, U is a set of selected points in a connected graph, and V − U is a set of points waiting to be selected.
Step 1. Initialize V = {v 0 } and take the edges from v 0 to all other vertices as candidate edges.
Step 2. Repeat Step (3) and execute N − 1 times until other N − 1 vertices join U.
Step 3. Select the edge with the minimum weight from the candidate edges, and ensure that it does not constitute a loop. Define the other vertex of the minimum edge as v i , and add it to V. V = {v 0 , v i }. The edges from each vertex in V to each vertex in V − U are modified as candidate edges.

Kruskal Algorithm
A Kruskal algorithm selects appropriate edges to construct the minimum spanning tree according to the increasing order of weights. Its basic idea is as follows.
Suppose that the minimum spanning tree of a connected graph is T, its set of vertices is V, and its set of edges is E.
Step 1. The set of all vertices in the connected graph is defined as the initial value of V, and the initial value of E is defined as empty.
Step 2. All edges in the connected graph are selected in order of weight from small to large. If the selected edge does not make T form a loop, then the edge is added to T. Otherwise, it is discarded until the number of edges in T reaches N − 1.

Comparisons of the Applicability of Algorithms
In terms of algorithm efficiency, especially computer program execution efficiency, a Prim algorithm is suitable for dense graphs with fewer vertices and more edges. For a connected graph with N vertices, the time complexity of a Prim algorithm is O N 2 , independent of the number of edges. A Kruskal algorithm is suitable for sparse graphs with more vertices and fewer edges. For a connected graph with E edges, its time complexity is O(ElogE), independent of the number of vertices.
In an urban mass transit network, if the total number of lines is N, then the total number of vertices in the connected graph is 2N, and the number of edges is equal to the total number of connection pairs. Taking a transfer station as an example, if there are N t lines passing through the station and N e lines terminating at the station, then there are (2 N t + N e ) 2 − (4N t + N e ) connection pairs at the transfer station [36]. Generally, the planning and the construction of urban mass transit network consider linking the lines as much as possible to improve the overall accessibility, thus the total number of connection pairs in the network operation stage is much larger than the number of lines. Therefore, its connected graph has the characteristics of fewer vertices and more edges. A Prim algorithm is suitable for solving the Minimum Spanning Tree problem.

Model Construction and Solution
In this chapter, we take an urban rail transit network as an example to discuss the construction and the solution of the model. Figure 3 shows the structure of the urban mass transit network, which consists of six lines and 13 transfer stations. Among them, G station is a three-line transfer station, and the others are two-line transfer stations.

Terminal Transfer at Single Station
For the two cases of Figure 1b,c, because the transfer station is the terminal station of one or two lines, the actual number of connection pairs is less. For example, station in Figure 3 is the terminal station of 9, and the connection between 9 and 3 is transformed into a connected graph, as shown in Figure 5. In this case, there is only one-way passenger flow in a connection pair.

Terminal Transfer at Single Station
For the two cases of Figure 1b,c, because the transfer station is the terminal station of one or two lines, the actual number of connection pairs is less. For example, G station in Figure 3 is the terminal station of L9, and the connection between L9 and L3 is transformed into a connected graph, as shown in Figure 5. In this case, there is only one-way passenger flow in a connection pair.

Transfer at Multiple Stations
For the case shown in Figure 1d, when there are two or more transfer stations between two lines, there will be multiple edges between the corresponding vertices in the connected graph. In Figure 3, and are transfer stations between 3 and 6, and the connected graph is shown in Figure 6.

Transfer at Multiple Stations
For the case shown in Figure 1d, when there are two or more transfer stations between two lines, there will be multiple edges between the corresponding vertices in the connected graph. In Figure 3, C and K are transfer stations between L3 and L6, and the connected graph is shown in Figure 6. In this case, it is necessary to modify the connected graph. Only one edge should be reserved between two vertices. The modifying ideas are as follows-by comparing the weights of each edge in the same direction between two vertices, the edge with the highest weight is retained, and the other edges are discarded. The equation is as follows: where subscript means the nth transfer station, and the other indexes share the same meaning as that in Equation (2).

Combination into Connected Graphs of Wire Network
The connected graph of various transfer structures can be combined to form the whole In this case, it is necessary to modify the connected graph. Only one edge should be reserved between two vertices. The modifying ideas are as follows-by comparing the weights of each edge in the same direction between two vertices, the edge with the highest weight is retained, and the other edges are discarded. The equation is as follows: where subscript n means the nth transfer station, and the other indexes share the same meaning as that in Equation (2).

Combination into Connected Graphs of Wire Network
The connected graph of various transfer structures can be combined to form the whole connected graph of the network. The urban mass transit network shown in Figure 6 is converted into a connected graph shown in Figure 7. Each edge is two-way or one-way. Its direction represents the direction of transfer passenger flow. It does not affect the solution of the minimum spanning tree and is not marked in the graph.

Matrix Representation of Connected Graphs
Algorithms are closely related to data structures. Algorithms affect the construction of data structures, and data structures are the basis of algorithms. Weight matrix is an important data structure; it can be used not only as the storage structure of a graph but also to solve the objective by artificial or software program. It is an important method to construct a spanning tree. We set each vertex of the connected graph as the row label and the column label of the weight matrix in turn. From the row label to the column label, a connection pair is formed. The weight of the matrix is the lTable 4. Update of weight table.

Origin
Transfer Destination

Calculation Example
In this section, combined with the actual data of last train transfer passenger volume in the

Matrix Representation of Connected Graphs
Algorithms are closely related to data structures. Algorithms affect the construction of data structures, and data structures are the basis of algorithms. Weight matrix is an important data structure; it can be used not only as the storage structure of a graph but also to solve the objective by artificial or software program. It is an important method to construct a spanning tree. We set each vertex of the connected graph as the row label and the column label of the weight matrix in turn. From the row label to the column label, a connection pair is formed. The weight of the matrix is the last train passenger volume. For the convenience of visual display, the weight matrix is recorded in the form of a table called a weight table. The first row and the first column of the weight table are labeled as vertices of connected graphs, respectively. Combining with the actual situations of Figures 3 and 7, the weight table is formed, as shown in Table 1.  According to the actual operation, there is no transfer between the up and the down directions of the same line except for wrong boarding, thus the weight is recorded as zero. There is no transfer between lines without connection, and the weight is recorded as zero. For the connection pair with two-way transfer passenger flow, its weight is listed in the table.

Weight Selection of Two-Way Edges
The weights of the edges are derived from the transfer passenger volume in the last train time domain. Therefore, in the cross transfer structure, each connection pair has two-way passenger flow-that is, the two-way edge described in Section 4.1.4. Therefore, there are two weights in the corresponding cells of the weight table. As described in Section 1.2, single connection is a normal situation of transfer connection. The last train transfer between two directions within a connection pair is mutually exclusive. Combining with the scheme objective of maximizing transfer passenger volume, the two weights of each edge is compared, and only the larger one is retained. The equation is as follows: w where the arrows indicate transfer direction, and the other indexes share the same meaning as that in Equation (2).

Maximum Spanning Tree Construction Method
Based on the weight table, the maximum spanning tree of the connected graph can be constructed by using a Prim algorithm. Set Tab = (V, W) as the weight table, where V is the set of row and column labels corresponding to the vertex of the connected graph, and W is the set of weights corresponding to the transfer passenger volume of the last train.
Combined with the basic idea of the Prim algorithm, in order to optimize the solution process, we divide the weight table into zones, as shown in Table 2. Zone I is the selected zone, and the corresponding set is U, which is the set of the selected vertices in the process of solving. Zones II and III are zones to be selected and contain vertices in V − U, which connect with the vertices in U. Zone IV is the unselected zone and contains vertices in V − U, which are not connected to the vertices in U.
According to the property of the maximum spanning tree, in the process of solving, the newly selected vertex needs to be connected with the existing vertices, while the newly selected edge should not form a closed loop with the existing edges. If the new vertex and the edge are selected from Zone I, a closed loop will be formed with the existing parts. The vertices and edges in Zone IV are not connected to the existing parts. Therefore, the newly selected vertices and edges can only be generated from Zones II and III.
The process of solving the maximum spanning tree by a Prim algorithm is to select vertices one by one from Zones II or III according to the weight of each edge, and ensure the connection with the vertices in Zone I. The newly selected vertices are added to Zone I continuously until Zone I contains all vertices and areas II, III, and IV are empty.
For the weight table shown in Table 1, if taking v 11 as the initial vertex, the initial value of U is {v 11 }, and the initial zone division of Table 1 is shown in Table 3. After solving the maximum spanning tree,

Origin
Transfer Destination Based on zone division of the weight table, the steps of constructing the maximum spanning tree using the Prim algorithm are as follows: Step Step 2. Select the maximum weight in Zone II and Zone III, put the corresponding vertex in U, the corresponding edge in T, and move the rows and the columns corresponding to the weight to Zone I, thus updating the four zones.
Step 3. Determine whether U equals V; if so, the maximum spanning tree construction is completed, and if not, continue Step 2 until U = V.
For the update of zones in Step 2, an example is shown in Table 4.

Matrix Representation of Connected Graphs
Algorithms are closely related to data structures. Algorithms affect the construction of data structures, and data structures are the basis of algorithms. Weight matrix is an important data structure; it can be used not only as the storage structure of a graph but also to solve the objective by artificial or software program. It is an important method to construct a spanning tree. We set each vertex of the connected graph as the row label and the column label of the weight matrix in turn. From the row label to the column label, a connection pair is formed. The weight of the matrix is the lTable 4. Update of weight table.

Origin
Transfer Destination Assuming that, in a solution step, U = {v 11 , v 12 , v 21 }, the maximum weight in Zones II and III are w 91,21 , thus the newly selected vertex is v 91 . The rows and columns corresponding to v 91 should be moved to the back of rows and columns corresponding to v 21 . Therefore, new rows and columns are added to Zone I, and Zones II, III, and IV are updated accordingly

Calculation Example
In this section, combined with the actual data of last train transfer passenger volume in the network (shown in Figure 3), the maximum spanning tree is solved by using a Prim algorithm, and the optimization scheme of the last train connection is sought. In the initial stage of modeling, we use the artificial modeling method. In the software development stage, we use Visual Studio tools and Visual C# language to program and model and to verify the feasibility of the model.

Statistics of Last Train Transfer Passenger Volume
In the actual operation of urban rail transit, the operation days are usually divided into different categories according to the characteristics of passenger volume, such as working days, holidays, pre-festival days, etc. This paper chooses the sample of working days during the stable period of operation, and get the big data of transfer passenger volume in last train time domain (22:00-23:30), and takes its statistical expectation as the value of transfer passenger volume. The calculation equation is as follows: where index n means the nth sample working day, the arrows indicate transfer direction, and the other indexes share the same meaning as that in Equation (2). According to the calculation equation, the weight table is obtained, as shown in Table 5.

Maximum Spanning Tree Solution
Firstly, combined with Section 4.3.1, the mutually exclusive two-way transfer passenger flow is screened by comparison, and the one-way weight table is obtained, as shown in Table 6.  Secondly, the maximum spanning tree is constructed according to the method described in Section 3.3. The process is shown in Table 7. Table 7. Maximum spanning tree construction process.

Construction Step U: Set of Vertices T: Set of Edges
Initialization Step Based on the steps above, the maximum spanning tree can be obtained, and its set of edges is The maximum spanning tree of the connection graph is shown in Figure 8.

Statistics of Last Train Transfer Passenger Volume
In the actual operation of urban rail transit, the operation days are usually divided into different categories according to the characteristics of passenger volume, such as working days, holidays, pre-festival days, etc. This paper chooses the sample of working days during the stable period of operation, and get the big data of transfer passenger volume in last train time domain (22:00-23:30), and takes its statistical expectation as the value of transfer passenger volume. The c

Connection Order of Last Train in the Network
Sorting the edges of the maximum spanning tree by weight in descending order, the connection priority and the sequence of the last train on each line can be determined, as shown in

Connection Order of Last Train in the Network
Sorting the edges of the maximum spanning tree by weight in descending order, the connection priority and the sequence of the last train on each line can be determined, as shown in Table 8.

Calculating the Timetable of the Last Train
According to the last train connection sequence listed in Table 8, the down direction of L1 should be taken as the benchmark, and its departure time of the last train should be the basis for calculating the departure time of the last train on other lines. The equation for calculating the last train departure time of each line is as follows.
where T ip is the departure time of the last train in the origin line direction, and T jq is the departure time of the last train in the transfer destination line direction. T ip−m and T jq−m are the times required for the last train to run from the departure station to the transfer station. T trans(ip− jq) is the transfer walking time of passengers between two directions. T ∆ is the transfer time margin.

Initial Scheme Optimization and Adjustment
The initial scheme obtained by the Prim algorithm needs to be optimized and adjusted according to the actual operation constraints.

Constraint Test of Last Train Time Domain
Considering the limitation of the earliest closing time and the maintenance time, the departure time of the last train on each line should meet the constraints of the last train time domain.
where T sta and T end are respectively the earliest and the latest time in the last train time domain. When the last train departure time of a certain direction exceeds the time domain, it should be adjusted, and the connecting directions should be adjusted accordingly, so as to ensure that the last train time of each line is in the time domain. When the adjustment cannot meet the time domain constraints, the connection relation between the overrun direction and its connection directions should be broken from low to high priority and then adjusted again according to the principle of priority to meet the time domain constraints.

Adjustment of Transfer Time Margin for Secondary Connection Relations
The initial scheme defines the priority transfer connection relations in order to achieve the maximum transfer passenger volume; we define it as the primary connection relations. Other connection relations not determined in the initial scheme are defined as secondary connection relations. The ideal situation of secondary connection should be single connection, and the typical transfer failure of a "just miss" should be avoided. "Just miss" means that the last train just leaves when passengers arrive at the platform [37]. Therefore, for the initial scheme, it is necessary to check the transfer time margin of secondary connection relations. If the transfer time margin does not meet the requirements, it should be adjusted by changing the departure time, the station stop time, or the runtime without breaking the primary connection.

Results
The derivation from Figure 3 to Figure 7 shows the method of converting the network structure into the last train connected graph. The derivation from Figure 7 to Table 1 shows the method of converting the connected graph into the weight matrix. In the case of a fixed network, operators can implement the conversion according to this method, thus facilitating the solution of the objective. Tables 2-4 show the basic method of using the improved Prim algorithm to solve the problem-that is, the table operation method. Equation (5) shows the method of calculating the matrix weight by using the big data of transfer volume in the last train time domain.
Tables 5-7 show the solving process by using the actual network and data. The result of the last step in Table 7 shows the connection sequence of each line direction-that is, the content shown in Table 8. According to the last train departure time of the reference line direction, the departure time of other line directions can be calculated according to Equation (6).

Discussion
The model construction method proposed in this paper has good applicability to different network structures. The solution based on the actual case shows that the improved Prim algorithm has good operability, and the table operation method can be easily implemented both by manual and computer solution.
The model constructed in this paper is single-objective. It takes the transfer volume as the basic data for decision-making. The main consideration is to achieve maximum transfer. In the theme of the last train connection scheme, the decision-making basis considered by relevant researchers is generally the generalized cost of passenger travel, such as travel time, distance, and economic costs. Compared with the existing research, the maximum transfer proposed in this paper can also be regarded as a kind of generalized cost from a macro perspective. Whether they can achieve transfer is an important factor that passengers consider in the last train stage, and it will directly affect their satisfaction.
In addition, there should be other considerations for the last connection scheme, such as the connection between urban and suburban areas and passenger transport of large traffic hubs. They are also the constraints of decision-making. This is one direction of the authors' future research, which could transform the single-objective of the model into a multi-objective.

Conclusions
Whether the last train transfer is successful or not has a direct impact on passengers' travel feelings. Rationally aquatinting the last train connection scheme is an important problem faced by operation enterprises in the stage of network operation. Aimed at solving this problem, this paper mainly completes the following research: (1) Based on the analysis of the connection structure and the accessibility form, a scheme model is proposed. This model aims at maximizing the transfer passenger volume of the last train in the network and transforms the last train connection problem into the maximum spanning tree problem of the connected graph.
(2) Based on the big data of transfer passenger volume in the last train time domain, this paper proposes an improved Prim algorithm to solve the maximum spanning tree. This algorithm is a calculation method of the initial connection scheme and demonstrates an example based on the actual data in a certain urban mass transit network.
(3) The main considerations for optimizing and adjusting the initial scheme are put forward, and the adjusting methods are discussed.
The research results of this paper include the working methods of the following stages: model building, decision-making data selection, initial scheme calculation, scheme adjustment, and optimization. Through the practical application test, it is proved that the novelties of the paper-that is, the model built method, the basic data used, and the calculation method-can solve the target problem, which has strong operability. It has strong practical operability and reliability. It provides an assistant decision-making tool for operation enterprises in the scheme of network operation, which can effectively enhance the scientific level of operation management.