File tree 1 file changed +0
-9
lines changed
1 file changed +0
-9
lines changed Original file line number Diff line number Diff line change @@ -25,28 +25,19 @@ function ShortestPath(graph) {
25
25
visited = [ ] ,
26
26
length = this . graph . length ;
27
27
28
- // Initialize all distances as INFINITE (JavaScript max number) and visited[] as false
29
28
for ( var i = 0 ; i < length ; i ++ ) {
30
29
dist [ i ] = INF ;
31
30
visited [ i ] = false ;
32
31
}
33
32
34
- // Distance of source vertex from itself is always 0
35
33
dist [ src ] = 0 ;
36
34
37
- // Find shortest path for all vertices
38
35
for ( var i = 0 ; i < length - 1 ; i ++ ) {
39
36
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.
43
37
var u = minDistance ( dist , visited ) ;
44
38
45
- // Mark the picked vertex as processed
46
39
visited [ u ] = true ;
47
40
48
- // Update dist value of the adjacent vertices of the
49
- // picked vertex.
50
41
for ( var v = 0 ; v < length ; v ++ ) {
51
42
if ( ! visited [ v ] && this . graph [ u ] [ v ] != 0 && dist [ u ] != INF && dist [ u ] + this . graph [ u ] [ v ] < dist [ v ] ) {
52
43
dist [ v ] = dist [ u ] + this . graph [ u ] [ v ] ;
You can’t perform that action at this time.
0 commit comments