File tree Expand file tree Collapse file tree 1 file changed +0
-9
lines changed
Expand file tree Collapse file tree 1 file changed +0
-9
lines changed Original file line number Diff line number Diff line change @@ -25,28 +25,19 @@ function ShortestPath(graph) {
2525 visited = [ ] ,
2626 length = this . graph . length ;
2727
28- // Initialize all distances as INFINITE (JavaScript max number) and visited[] as false
2928 for ( var i = 0 ; i < length ; i ++ ) {
3029 dist [ i ] = INF ;
3130 visited [ i ] = false ;
3231 }
3332
34- // Distance of source vertex from itself is always 0
3533 dist [ src ] = 0 ;
3634
37- // Find shortest path for all vertices
3835 for ( var i = 0 ; i < length - 1 ; i ++ ) {
3936
40- // Pick the minimum distance vertex from the set of vertices
41- // not yet processed. u is always equal to src in first
42- // iteration.
4337 var u = minDistance ( dist , visited ) ;
4438
45- // Mark the picked vertex as processed
4639 visited [ u ] = true ;
4740
48- // Update dist value of the adjacent vertices of the
49- // picked vertex.
5041 for ( var v = 0 ; v < length ; v ++ ) {
5142 if ( ! visited [ v ] && this . graph [ u ] [ v ] != 0 && dist [ u ] != INF && dist [ u ] + this . graph [ u ] [ v ] < dist [ v ] ) {
5243 dist [ v ] = dist [ u ] + this . graph [ u ] [ v ] ;
You can’t perform that action at this time.
0 commit comments