Pipe arrangement is one of the most time-consuming works in ship production because the process requires designers to decide the optimum pipe routes. Previous works focused on finding preferable routes by applying optimization methods, but these methods have not considered the effect of gravity in obtained pipe routes. This paper presents an automatic pipe routing method that avoids air pockets. We call vertical U-shaped pipes "air pockets". In this paper, the pipe routing problem is considered as a routing problem in a directed and weighted graph. Dijkstra's method is used in the routing process for generating candidates of optimum routes. In order to avoid making air pockets in the obtained routes, we try to use a new cost Junction. The performance of this method is shown in several demonstrations.