File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed
algorithm/graph_search/dijkstra/shortest_path Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,20 @@ function Dijkstra(start, end) {
33 var D = [ ] ; // D[i] indicates whether the i-th node is discovered or not
44 for ( var i = 0 ; i < G . length ; i ++ ) D . push ( false ) ;
55 S [ start ] = 0 ; // Starting node is at distance 0 from itself
6+ tracerS . _notify ( start , S [ start ] ) ;
67 var k = G . length ;
78 while ( k -- ) {
89 // Finding a node with the shortest distance from S[minIndex]
910 minDistance = MAX_VALUE ;
1011 for ( i = 0 ; i < G . length ; i ++ ) {
11- tracerS . _select ( i ) . _wait ( ) ;
1212 if ( S [ i ] < minDistance && ! D [ i ] ) {
1313 minDistance = S [ i ] ;
1414 minIndex = i ;
1515 }
16- tracerS . _deselect ( i ) ;
1716 }
1817 if ( minDistance == MAX_VALUE ) break ; // If there is no edge from current node, jump out of loop
1918 D [ minIndex ] = true ;
20- tracerS . _notify ( minIndex , S [ minIndex ] ) . _denotify ( minIndex ) ;
19+ tracerS . _notify ( minIndex ) ;
2120 tracer . _visit ( minIndex ) . _wait ( ) ;
2221 // For every unvisited neighbour of current node, we check
2322 // whether the path to it is shorter if going over the current node
You can’t perform that action at this time.
0 commit comments