File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -93,22 +93,19 @@ var dijstra = function () {
9393 var tempDistance = 0 ;
9494 init ( src , graph ) ;
9595 while ( current . node != dest && current . distance != Infinity ) {
96- var changed = false ;
9796 for ( var i = 0 ; i < graph . length ; i += 1 ) {
9897 if ( current . node !== i && //if it's not the current node
9998 ! visited [ i ] && //and if we haven't visited this node
10099 Number . isFinite ( graph [ i ] [ current . node ] ) ) { //and this node is sibling of the current...
101100
102- tempDistance = current . distance + graph [ i ] [ current . node ] ;
101+ tempDistance = current . distance + graph [ i ] [ current . node ] ;
103102 if ( tempDistance < distance [ i ] . distance ) {
104- changed = true ;
105103 distance [ i ] . distance = tempDistance ;
104+ current . distance = tempDistance ;
105+ unvisited . update ( current ) ;
106106 }
107107 }
108108 }
109- if ( changed ) {
110- // TODO the heap should update the order of the elements!
111- }
112109 visited [ current . node ] = true ;
113110 current = unvisited . extract ( ) ;
114111 }
You can’t perform that action at this time.
0 commit comments