@@ -3,7 +3,8 @@ 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 ] ) ;
6+ tracerS . _notify ( start , S [ start ] ) . _wait ( ) . _denotify ( start ) ;
7+ tracerS . _select ( start ) ;
78 var k = G . length ;
89 while ( k -- ) {
910 // Finding a node with the shortest distance from S[minIndex]
@@ -16,15 +17,17 @@ function Dijkstra(start, end) {
1617 }
1718 if ( minDistance == MAX_VALUE ) break ; // If there is no edge from current node, jump out of loop
1819 D [ minIndex ] = true ;
19- tracerS . _notify ( minIndex ) ;
20+ tracerS . _select ( minIndex ) ;
2021 tracer . _visit ( minIndex ) . _wait ( ) ;
2122 // For every unvisited neighbour of current node, we check
2223 // whether the path to it is shorter if going over the current node
2324 for ( i = 0 ; i < G . length ; i ++ ) {
2425 if ( G [ minIndex ] [ i ] && S [ i ] > S [ minIndex ] + G [ minIndex ] [ i ] ) {
2526 S [ i ] = S [ minIndex ] + G [ minIndex ] [ i ] ;
26- tracerS . _notify ( i , S [ i ] ) . _wait ( ) . _denotify ( i ) ;
27- tracer . _visit ( i , minIndex , S [ i ] ) . _wait ( ) . _leave ( i , minIndex ) ;
27+ tracerS . _notify ( i , S [ i ] ) ;
28+ tracer . _visit ( i , minIndex , S [ i ] ) . _wait ( ) ;
29+ tracerS . _denotify ( i ) ;
30+ tracer . _leave ( i , minIndex ) . _wait ( ) ;
2831 }
2932 }
3033 tracer . _leave ( minIndex ) . _wait ( ) ;
0 commit comments