To make a Distance Matrix for the Floyd Warshall algorithm "Shortest path" (https://www.cs.usfca.edu/~galles/visualization/Floyd.html?hc_location=ufi), you need some roads as vertices and distances between these roads as edges. For example (departure, destination, distance): roads = [["Philadelphia", "New York City", 120 ], ["New York City", "Philadelphia", 97 ],[ "Millburn, "New York City", 25 ],["Morristown", "Harrisburg", 150]
How can I make this matrix in python?
This is the structure:
network[0] = #list destinations
for i in range (len(roads)):
network [i][0] = #list departures
I don't know how to fill the distances in the correct position, because network[roads[i][0],[roads[i][1]]
isn't the right solution when a destination or departure is used more times than one.
Thanks a lot!