Hello,
I want to display a shortest path from 'a' to 'd' for the graph made of the following links and nodes:
This is the script I've developed and the result obtained:
import networkx as nx
graph = nx.Graph()
routes = open('links.txt')
for line in routes:
orig, dest, dist = line.split(",")
graph.add_edge(orig, dest, weight=int(dist))
print nx.shortest_path_length(graph, 'a', 'd')
print nx.shortest_path(graph, 'a', 'd')
I then modify the 'links.txt' file to force ['a', 'b', 'd'] to be selected as the shortest path:
However after running script again and again the old result is returned.
Is it possible python caches the result of previous shortest path calculations?