Traditionally the traveling salesman problem works with the distance from city to city taking from its origin. This works perfectly fine if you can neglect the travel cost through the city compared to the travel cost between cities. So the question is, how can the shortest route be found when the traveling cost through a city can't be neglected?
The easiest way to explain the problem better is by taking a greedy algorithm, nearest neighbour for example starting at A who goes to B and then having 2 options, one going to C for 5 cost and one going to D for 6 cost. At first C looks like the cheaper options, but traveling through the city to go to B takes 3 cost and traveling through the city to go to D only takes 1. So in the end, taking D would be the cheaper option.
Before I created a map with the traveling cost between each city, but as you can see in the example, traveling through a city has big impact on the true traveling cost.
Any help on how to tackle such problem?
EDIT: the prefered edge can be chosen at the starting point (no traveling through city). The destination is reached when the salesman enters the city (no traveling through city). traveling through cities cost the same for both directions.