File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -9,18 +9,18 @@ function PriorityQueue () {
9
9
this . enqueue = function ( priority , key ) {
10
10
this . _nodes . push ( { key : key , priority : priority } ) ;
11
11
this . sort ( ) ;
12
- }
12
+ } ;
13
13
this . dequeue = function ( ) {
14
14
return this . _nodes . shift ( ) . key ;
15
- }
15
+ } ;
16
16
this . sort = function ( ) {
17
17
this . _nodes . sort ( function ( a , b ) {
18
18
return a . priority - b . priority ;
19
19
} ) ;
20
- }
20
+ } ;
21
21
this . isEmpty = function ( ) {
22
22
return ! this . _nodes . length ;
23
- }
23
+ } ;
24
24
}
25
25
26
26
/**
@@ -32,7 +32,7 @@ function Graph(){
32
32
33
33
this . addVertex = function ( name , edges ) {
34
34
this . vertices [ name ] = edges ;
35
- }
35
+ } ;
36
36
37
37
this . shortestPath = function ( start , finish ) {
38
38
var nodes = new PriorityQueue ( ) ,
@@ -58,7 +58,7 @@ function Graph(){
58
58
smallest = nodes . dequeue ( ) ;
59
59
60
60
if ( smallest === finish ) {
61
- path ;
61
+ path = [ ] ;
62
62
63
63
while ( previous [ smallest ] ) {
64
64
path . push ( smallest ) ;
@@ -85,7 +85,7 @@ function Graph(){
85
85
}
86
86
87
87
return path ;
88
- }
88
+ } ;
89
89
}
90
90
91
91
var g = new Graph ( ) ;
You can’t perform that action at this time.
0 commit comments