[8], which divides clusters by the k-means algorithm, and selects the node nearest to the cluster center as the cluster head. But the algorithm in ref. [8] only has one cluster head for each cluster, which may cause hot-zone problems, and its ability to combat network congestion is weak. To solve the problem, [PERSON] proposed a non-uniform clustering algorithm based on LEACH, which selects double cluster heads to prolong the network lifetime [9]. Furthermore, machine learning algorithms have also been used to select cluster heads. In ref. [10], a genetic algorithm (GA) is utilized for optimal cluster-head selection in the LEACH protocol, which can extend the lifetime to about three times that of conventional LEACH. Another useful machine learning algorithm in these networks is the ant colony optimization algorithm, which can help to find the best route. Authors in ref. [11] used an improved ant colony optimization method to find optimal multi-hop paths according to the residual energy of the next hop node. To avoid unnecessary energy consumption, energy-efficient dynamic and adaptive state-based scheduling (EDASS) was proposed [12], which can dynamically switch nodes between four states of route, active, wait, and sleep, and in this way, highly efficient energy management can be achieved. In addition to WSN, a vehicular ad hoc network (VANET) is another widely used type of network, which has the characteristics of strong mobility and rapid topology change. QMM-VANET is proposed in ref. [13], which considers quality-of-service (QoS) requirements, the distrust value parameters, and mobility constraints. To reduce the influence of vehicle movement, [PERSON] took into account the location information of vehicles and divided geographical locations into grids for clustering [14]. A wireless body area network (WBAN) is another new ad hoc network which has been developed in recent years. The WBAN is based on the human body and composed of network elements related to the human body. Authors in ref. [15] proposed an efficient QoS-based multi-path routing (MPR) scheme for WBAN, which divided data traffic into normal and emergency types, and the emergency traffic is routed onto the best path. In an urban rail transit scenario, ad hoc networks have often been used to monitor train operational status and the carriage environment. In ref. [16], a clustering algorithm was utilized to maximize the lifetime of the high-speed railway network under the WSN network. Another cluster algorithm was proposed in ref. [17], which was used to minimize and balance the energy consumption of nodes. However, nodes used for vehicle-ground critical service transmission are powered by cables, so there is no need to save node energy as in a WSN network. In addition, trackside nodes are distributed along tunnel walls, and only the train is moving, which is different from VANET. Therefore, a novel clustering routing protocol is needed to meet the needs of urban rail transit vehicle-ground communication. In this paper, we adopt an ad hoc network for the urban rail transit system and propose a clustering algorithm based on improved ant colony optimization. The contributions of this paper are as follows:  
1. An ad hoc network is deployed in an urban rail transit scenario, which can help to improve the robustness of the vehicle-ground network and the driving safety. Furthermore, urban rail transit is different from WSN or VANET, due to the fixed driving environment, power-suppliable nodes, and large data traffic;
2. A cluster-head selection strategy based on cost function is proposed to reduce packet loss rate, which can elect cluster head nodes periodically and change cluster head nodes according to the packet loss rate;
3. A low-delay queuing strategy based on service priority is proposed to reduce end-to-end delay, which can guarantee the time delay according to different service requirements;
4.