PurposeSince the performance of vehicular users and cellular users (CUE) in Vehicular networks is highly affected by the allocated resources to them. The purpose of this paper is to investigate the resource allocation for vehicular communications when multiple V2V links and a V2I link share spectrum with CUE in uplink communication under different Quality of Service (QoS).Design/methodology/approachAn optimization model to maximize the V2I capacity is established based on slowly varying large-scale fading channel information. Multiple V2V links are clustered based on sparrow search algorithm (SSA) to reduce interference. Then, a weighted tripartite graph is constructed by jointly optimizing the power of CUE, V2I and V2V clusters. Finally, spectrum resources are allocated based on a weighted 3D matching algorithm.FindingsThe performance of the proposed algorithm is tested. Simulation results show that the proposed algorithm can maximize the channel capacity of V2I while ensuring the reliability of V2V and the quality of service of CUE.Originality/valueThere is a lack of research on resource allocation algorithms of CUE, V2I and multiple V2V in different QoS. To solve the problem, one new resource allocation algorithm is proposed in this paper. Firstly, multiple V2V links are clustered using SSA to reduce interference. Secondly, the power allocation of CUE, V2I and V2V is jointly optimized. Finally, the weighted 3D matching algorithm is used to allocate spectrum resources.