The public transportation system of cities, including subway and public transportation, is becoming more and more perfect. With the rapid development of urban public transport, the path selection considering multiple factors has become a new problem. Based on the optimization model, we take urban public transport operators and travelers as the objects, and use the entroy weight TOPSIS method to comprehensively evaluate the feasible lines and paths between multiple OD pairs. Besides, the optimal path to traverse all nodes was solved by Hamilton cycle problem algorithm, which can also provide reference for both operators and travelers. According to the latest urban public transport data in 2021, we select Beijing, China as the empirical research object. This paper chooses the existing public transport network of Beijing to verify, and selects the optimal path of 5 nodes and 10 paths to traverse all nodes.