I am trying to figure out how to find all the shortest paths from each point and each node of a line to the other points and nodes of lines of this map.
With that road network, I have 214 nodes (which should result in 214x214 shortest paths, I think). I have tried to make the graph of the road network with this code:
#Create the network graph G = nx.DiGraph() for k,v in idict.items(): G.add_edge(v,v, weight = v) # v = first (x,y) of a linestring, v = last (x,y) of a linestring, v = distance G.add_edge(v,v, weight = v) # return path len(G.edges()) pos = nx.spring_layout(G) nx.draw_networkx_nodes(G, pos = pos, node_size=20,arrows = True) nx.draw_networkx_edges(G, pos = pos) plt.show()
And the result shows:
I've also tried to apply the networkx floyd warshall function to calculate all shortest paths from each point to another point but some of the results return to infinity (as I think it says that no path is found between the points, while actually all paths are connected). All in all, it only returns to about 1720 shortest paths
How should I proceed to have the shortest path of each node to every other nodes in the map?