Skip to content

Commit

Permalink
Updated comments and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
deiga committed Mar 16, 2014
1 parent 9cb2846 commit 8e8defc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/graph.js
Expand Up @@ -47,7 +47,7 @@
Graph.prototype.adj = function (u)
{
var adjacents = this._graph[u];
return typeof adjacents !== 'undefined' ? adjacents : {};
return adjacents ? adjacents : {};
}

Graph.prototype.get = function (u, v)
Expand Down
2 changes: 2 additions & 0 deletions test/core.js
Expand Up @@ -230,6 +230,8 @@ this.core_suite =
'Adjacency': function (test)
{
var g = new Graph();
test.ok(typeof g.adj(3) !== 'undefined',
"Should returns empty object when no adjacents.");
g.set(1, 2);
test.ok(1 in g.adj(2),
"Vertex 1 is adjacent to vertex 2.");
Expand Down

0 comments on commit 8e8defc

Please sign in to comment.