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)