Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dijkstra or TSP

I am developing a web app to show a map and a route between some points. I want to know the short route between that points.

Now I am using the dijkstra algorithm but I was asked to use TSP instead.

I want that first and last point would be the same, using dijkstra I have to set the last point to be the same but with TSP it is set automatically.

Are both the same algorithm? just with that modification or are different algorithms?

Any webpage where I can check the pseudo code of TSP?

like image 296
Biribu Avatar asked Jan 30 '26 15:01

Biribu


1 Answers

Travelling Salesman Problem as the name suggests, talks about the shortest route and it's cost starting from a single node and returning to it by visiting ALL the other nodes in between

But Dijkstra is more simple. It just talks about the shortest route and cost between 2 nodes. So in your case, if there's a need to include all nodes in between then the suggestion for TSP is valid.

P.S. If you want to have the shortest routes and cost between all pairs of nodes, then you should go for Floyd's algorithm which is basically an extension of Dijkstra.

like image 103
Nithish Inpursuit Ofhappiness Avatar answered Feb 02 '26 05:02

Nithish Inpursuit Ofhappiness



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!