Dijkstra's algorithm: choosing which point to begin with

  • Thread starter Thread starter nomadreid
  • Start date Start date
  • Tags Tags
    Algorithm Point
AI Thread Summary
In discussions about Dijkstra's algorithm for finding the shortest path in a graph, the focus is on the choice of starting vertex and its potential impact on efficiency. While the algorithm guarantees the same shortest path regardless of the starting point, the total computing time may vary. Some participants suggest starting from the node with the fewest connections, but this approach is questioned as it may not always yield the best results. The conversation highlights the importance of testing multiple graphs, as results can differ significantly across different structures. Additionally, there is a suggestion to enhance efficiency by terminating the algorithm early once both endpoints are resolved, which could save computation time. A notable concern raised is how the algorithm handles scenarios where multiple nodes have the same minimal distance, potentially leading to indecision. Overall, while starting point choice may not fundamentally alter the outcome, it can influence performance, and the algorithm's handling of ties in distance values remains a critical consideration.
nomadreid
Gold Member
Messages
1,748
Reaction score
243
In Dijkstra's algorithm (for an efficient way to find the shortest path between two given vertices, or nodes, in a graph), the only freedom the programmer has is to name which of the two given vertices one begins with. Is there any efficient way to tell which one of the two one should start with? That is, the answer will obviously be the same, but the total computing time, or number of steps, is likely to be different, according to one's choice.
 
Technology news on Phys.org
You mean, you want to first apply an algorithm to find out where start from and second apply the real algorithm? :confused: I guess that is possible if at the end provides savings.

The very first thing the occurs to me is to start on the node with the least number of connections. In any case, have you simply tried running the program and starting from one node and then starting from the other and see if there are real savings?

Is your graph bi-directional? I presume your worry is a moot point for a directional graph where if you want to go from A to B, you would really need to start from A, I guess.

my 2 cents
 
  • Like
Likes nomadreid
Thanks for your 2 cents, gsal. I will now convert it to local currency...:)
Yes, I would ideally first run a program that did not cost too much (in computer time) in order to select which one of the two given points to use as starting points, and then run the full algorithm. I am referring to an undirected (bidirectional) graph. Running the algorithm on a test graph or two to see which one comes out better is not sufficient -- there is no guarantee that the result of a couple of graphs will work on other graphs. Also there may be other factors that how many connections there are at first... I am not convinced that starting with the end with fewest connections is necessarily the best.
 
Well...I just read a bit of the Wikipedia page for Dijkstra's algorightm...I guess I should have done that in the first place...anyway, it does not seem that complicated at all and it is exhaustive; so, I don't know what kind of algorithm you would initially apply just to find out where to start...may as well start applying Dijkstra's right away.

So, I guess that if you start on node A, you get one SPT starting on A; and if you start on B, you get a SPT starting on B...BUT, I presume the path connecting A to B would be exactly the same on both trees.

One thing you COULD do to improve solution time is to cut Dijkstra's loops short...in other words, if all you want is A to B and not the entire tree...as soon as both A and B are in the solved for set, you can quite the do-loops.
 
  • Like
Likes nomadreid
gsal, thanks. Yes, the algorithm could be made more efficient by eliminating loops. But I do not know whether the running time would be significantly different if you started went from A to B or B to A: that is part of the question (such an algorithm as I am searching for would not exist if there were no difference). That is, I would like to know if there is a difference, and if so, what. It is not obvious that there would be a difference, and it is not obvious that there wouldn't, so I am asking. Anyway, while we are on the question of this algorithm, one thing that strikes me is that the algorithm does not take into account what to do when there are two or more points with the same value assignment and both minimal. That is, what if your algorithm, giving the values to the points, gets to the situation where the algorithm has assigned the values (which are distances to the origin along the paths regarded up to that point) to the neighbors of a current node, and there are two points that fulfill the requirement of being a minimum amongst all the values of all the neighbors? It looks as if it would not be very hard to construct a graph that would make the algorithm freeze in indecision.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top