Calculate shortest path through a grocery store

前端 未结 5 737
走了就别回头了
走了就别回头了 2020-12-31 06:31

I\'m trying to find a way to find the shortest path through a grocery store, visiting a list of locations (shopping list). The path should start at a specified start positio

5条回答
  •  暖寄归人
    2020-12-31 07:05

    The requirement of a start node is fictitious. Using the TSP you'll end up with a tour where you can chose the start node that you want without altering the solution cost.

    It's somewhat trickier when it comes to the counters: what you need is to solve the problem on a directed graph with some arcs missing (or, which is the same, where some arcs have a really high cost).

    Starting with the complete directed graph you should modify the costs of the proper arcs in order to:

    1. deny going from the items to the start node
    2. deny going from the counters to the items
    3. deny going from the start node to the counters
    4. allow going from the counters to the start node at zero cost (this are only needed to close the path)
    5. after having drawn the thing down, tell me if I missed something :)

    HTH

提交回复
热议问题