I am facing a small challenge that I'm hoping someone can help with. I have built a model of a city map that contains cities that each contain a list of other cities they are connected to, like this:
I am using the map to calculate routes that contain four, five or more cities. I am concerned that my method is not very efficient, it involves iterating over multiple arrays and 'moving' backwards and forwards over the map. My questions is whether there is an efficient way to calculate the route through 'n' cities, given 'n' can change.