Rank: 218354 based on 0 downloads (last 30 days) and 0 file submitted
photo

Bas

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Bas
Updated File Comments Rating
08 Jul 2014 dijkstra very simple Dijkstra's algorithm to find the shortest path Author: Jorge Barrera

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.

Contact us