Question

i´m obviously missing the forest through the trees ...

i know about the traveling salesman problem, but is there any other algorithm/problem which better fits my needs/description? I need to describe my problem with the help of such a mathematical description.

I have up to five points with known start- and endpoint. So i just need to calculate the shortest way to visit all the three points between that two. Dijkstra and similar algorithms try to find the shortest path between two points, so here they probably won´t visit all points between. Or is there a algorithm which finds shortest way and visit all points between two points?

Was it helpful?

Solution

You are overthinking it. There are only six (3*2*1) possible paths through the three intermediate nodes. Just check them all.

For larger instances, you could reduce your problem to the TSP as follows:

If s is the starting node and t is the final node, add a zero-weight edge between s and t and an infinitely-heavy edge between s and every other node, and between t and every other node.

The problem is NP-hard, but is extremely well-researched. There is a plethora of exact and approximate algorithms that you could explore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top