Skip to content

Commit 524c76f

Browse files
authored
Merge pull request #13 from juur/patch-1
fix missing semi-colons and a small bug
2 parents d1f3c2a + 63a5adf commit 524c76f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dijkstras.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ function PriorityQueue () {
99
this.enqueue = function (priority, key) {
1010
this._nodes.push({key: key, priority: priority });
1111
this.sort();
12-
}
12+
};
1313
this.dequeue = function () {
1414
return this._nodes.shift().key;
15-
}
15+
};
1616
this.sort = function () {
1717
this._nodes.sort(function (a, b) {
1818
return a.priority - b.priority;
1919
});
20-
}
20+
};
2121
this.isEmpty = function () {
2222
return !this._nodes.length;
23-
}
23+
};
2424
}
2525

2626
/**
@@ -32,7 +32,7 @@ function Graph(){
3232

3333
this.addVertex = function(name, edges){
3434
this.vertices[name] = edges;
35-
}
35+
};
3636

3737
this.shortestPath = function (start, finish) {
3838
var nodes = new PriorityQueue(),
@@ -58,7 +58,7 @@ function Graph(){
5858
smallest = nodes.dequeue();
5959

6060
if(smallest === finish) {
61-
path;
61+
path = [];
6262

6363
while(previous[smallest]) {
6464
path.push(smallest);
@@ -85,7 +85,7 @@ function Graph(){
8585
}
8686

8787
return path;
88-
}
88+
};
8989
}
9090

9191
var g = new Graph();

0 commit comments

Comments
 (0)