I'm having trouble understanding a past quiz question I got:Bobby works at Starbucks in San Mateo (V). He is doing quality assurance testing and needs to visit stores in Palo Alto (B), Tenderloin (C), and San Jose (S) - and then return to San Mateo for a meeting.The distances between the stores are:VB = 2VC = 3VS = 6BC = 1BS = 5CS = 4Which is the first store he visits in the optimal solution to this problem?How would you approach solving this problem? It reminds me a bit of Djistra's algorithm but I suspect there's an easier way other than trying every combination as the time limit is short.My interpretation:    B__1__C  |     |2 |     | 4  |__6__|  V     SFor Bobby to visit all 4 stores and return to V, he simply starts at V and travels the edges of the above box. But the question is asking which is the first store? Either direction will give a total of 13, so how is there a right answer?
Finding minimum path with return?
algorithms
The right answer is that path which has the least cost. While this is technically traveling salesman and an exact solution is very difficult to achieve quickly, you can typically achieve an optimal or near optimal route by using a greedy, novelty hungry algorithm.The algorithm is thus:For current node pick the path with the least cost provided it leads to a node you've not visited prior. Travel to the new node and repeat until all nodes but the origin have been visited. Then visit origin by min cost path.We start with an empty graph:Next we mark the current node as visited (bold) and follow the least cost path to an unvisited node:We continue this pattern for the next two nodes:Now we have no new nodes to visit but we have the origin node connected so we take that path:Thus we arrive at our solution. This algorithm is most optimal for fully connected graphs with distinctly weighted edges. We of course have used a form of Dijkstra's algorithm which confirms what you suspected. The best possible cost is 13.