I encountered a problem in choosing a solution, maybe there is an opinion to make it easier. I have GeoDataFrame that contains columns "geometry", "oneway", "highway" geometry is a LineString (line of the path/road) that contains coords (WGS-84), oneway=yes/no. Indicates that there is bidirectional or one-way traffic on a given path. highway - shows a type of road (there are only "motorway", "motorway_link", "trunk", "trunk_link") In fact, in my task "motorway", "motorway_link" is one class of road and trunk, trunk_link as well image1 In the picture This is part of the road graph in Arizona (gdf) light green color is trunk, trunk link type dark green color - motorway, motorway_link I need to find trunk paths that will connect small pieces of motorway/motorway_link in the shortest way and so that it does not form a loop In the picture, 1 - I have marked the shortest path that connects the motorways. But the question is by the same logic, should I mark the oncoming roads? And so that there is no looping between roads image2 I tried to build a full directed weighted graph (meters), connected components separately motorways and trunks. Find intersection points and use the shortest path algorithm. But unfortunately it returns only one path. path image2 I showed in the second picture (part of this path), this found shortest path. but I also need to mark similar paths - opposite directions and branches (with the is_connector tag) image3 in this case, if the shortest component is already connected, then do not look for connections on the opposite side or on other sides. That is, remove the loop. Continue reading...