This function works fine.
I call it many times as dijkstra(A,C,1) into an optimization function.
Nevertheless, the Matlab profiler halt me with warnings about the use of sparse functions, and indexing sparse matrices.
I think you could speed up Dirk Stelder's solution by replacing the first for loop (between "candidate=[];' and "[u_index u]=min(candidate);") by the statement
[u_index u] = min(1 ./ (S==0) .* dist);
(Note that u_index is in fact the value; u is the index.) Entries in 1 ./ (S==0) have value Inf when their value in S is 1, i.e. when they have been visited, and 1 otherwise. Multiplying by dist leaves all visited nodes with distance Inf: precisely what 'candidate' looks like.
I have a database with nodes en segments but the segments must be calculated before they can be added to the algorithm. I have a query wich calculates all the posible segments from one specific node to other nodes.
Is it possible to calculate the needed segments during the algorithm? In that case i don't have to calculate all the possible segments for the whole database (16,000 nodes with about 2,450,000 segments)
Puffeltje
Hi All,
I have a need, wherein there are multiple nodes spread across. All I know is the location of each nodes. How do I find the best path from all nodes to a particular node?
Can I use the "Dijkstra's Shortest Path Algorithm"? Believe, its YES.
I am not sure, as how do I populate the variable, “segments” in program.
Appreciate an earlier response on this. Would be great, if you could give a code snippet as well.
Thanks
Sunil Kumar
Comment only