algorithm - Finding the shortest path over multiple points -
requirements:
there multiple targets need visit on graph (does not matter order or how many times visit each point)
you can start starting point, visit targets , come base.
you allowed visit each target multiple times.
question:
1) algorithm should use approach this?
2) proposed approach
let's targets = [a, b, c]
- i thinking use dijkstra's algorithm find shortest path of targets.
- once reach target, use dijstra's find of remaining targets.
- once have found targets, use dijstra's find path starting point.
- this should give me shortest path find targets , home
you on right track, problem reduces travelling salesman problem (tsp).
using dijkstra mentioned, can replace paths between target nodes not contain target nodes, single edge. result graph target nodes... leaves tsp.
as weighted directed edge thing in comments, think long edge costs non-negative, dijkstra fine.
Comments
Post a Comment