Skip to content

Commit

Permalink
MST now shows up again
Browse files Browse the repository at this point in the history
  • Loading branch information
Pieter Colpaert committed Jan 15, 2016
1 parent ebbc7e5 commit c9d3fb6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ try {
}
});

planner.on("data", function (mstConnection) {
console.error(mstConnection);
});

planner.on("stop_condition", function (count) {
console.error("Reached stop condition after relaxing " + count + " connections.");
});
Expand Down
6 changes: 3 additions & 3 deletions lib/BasicCSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ ResultStream.prototype._transform = function (connection, encoding, done) {

//Check the pending queue first for connections that can be officially added to the MST
while (this._pending.length > 0 && this._pending.peek().arrivalTime < connection.departureTime) {
var connection = this._pending.dequeue();
var pendingConnection = this._pending.dequeue();
//test whether we still have a match, otherwise, just throw it away
if (this._earliestArrivalTimes[connection.arrivalStop]['@id'] === connection.arrivalStop['@id']) {
this.push(connection);
if (this._earliestArrivalTimes[pendingConnection.arrivalStop]['@id'] == pendingConnection['@id']) {
this.push(pendingConnection);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "csa",
"version": "0.0.8",
"version": "0.0.9",
"description": "Route Planner on top of data published using Connections",
"main": "lib/csa.js",
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions test/routeplanning.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ describe('Route planning queries', function () {
var readStream = fs.createReadStream('test/data/test20131216.json.gz', {flags: 'r'});
var result = readStream.pipe(zlib.createGunzip()).pipe(new Deserialize()).pipe(planner);
it("should yield a result", function (done) {
var stations = [];
var mst = {};
result.on("data", function (data) {
//It should never give two times the same arrivalStop!
if (stations.indexOf(data.arrivalStop) > -1) {
done('Received two times a connection with arrival stop: ' + data.arrivalStop);
if (mst[data.arrivalStop]) {
done('Received two times a connection with arrival stop: ' + stations[data.arrivalStop].name + " - " + data.arrivalStop);
}
stations.push(data.arrivalStop);
mst[data.arrivalStop] = data;
});
result.on("result", function (path) {
done();
Expand Down

0 comments on commit c9d3fb6

Please sign in to comment.