Skip to content

Commit

Permalink
Prep v2.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt committed Nov 23, 2015
1 parent 5a84ef8 commit 4b45faf
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphlib",
"version": "1.0.7",
"version": "2.0.0",
"main": [
"dist/graphlib.core.js"
],
Expand Down
17 changes: 10 additions & 7 deletions dist/graphlib.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ module.exports = dfs;

/*
* A helper that preforms a pre- or post-order traversal on the input graph
* and returns the nodes in the order they were visited. This algorithm treats
* the input as undirected.
* and returns the nodes in the order they were visited. If the graph is
* undirected then this algorithm will navigate using neighbors. If the graph
* is directed then this algorithm will navigate using successors.
*
* Order must be one of "pre" or "post".
*/
Expand All @@ -119,25 +120,27 @@ function dfs(g, vs, order) {
vs = [vs];
}

var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);

var acc = [],
visited = {};
_.each(vs, function(v) {
if (!g.hasNode(v)) {
throw new Error("Graph does not have node: " + v);
}

doDfs(g, v, order === "post", visited, acc);
doDfs(g, v, order === "post", visited, navigation, acc);
});
return acc;
}

function doDfs(g, v, postorder, visited, acc) {
function doDfs(g, v, postorder, visited, navigation, acc) {
if (!_.has(visited, v)) {
visited[v] = true;

if (!postorder) { acc.push(v); }
_.each(g.neighbors(v), function(w) {
doDfs(g, w, postorder, visited, acc);
_.each(navigation(v), function(w) {
doDfs(g, w, postorder, visited, navigation, acc);
});
if (postorder) { acc.push(v); }
}
Expand Down Expand Up @@ -1232,6 +1235,6 @@ if (!lodash) {
module.exports = lodash;

},{"lodash":undefined}],21:[function(require,module,exports){
module.exports = '1.0.7';
module.exports = '2.0.0';

},{}]},{},[1]);
2 changes: 1 addition & 1 deletion dist/graphlib.core.min.js

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions dist/graphlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ module.exports = dfs;

/*
* A helper that preforms a pre- or post-order traversal on the input graph
* and returns the nodes in the order they were visited. This algorithm treats
* the input as undirected.
* and returns the nodes in the order they were visited. If the graph is
* undirected then this algorithm will navigate using neighbors. If the graph
* is directed then this algorithm will navigate using successors.
*
* Order must be one of "pre" or "post".
*/
Expand All @@ -119,25 +120,27 @@ function dfs(g, vs, order) {
vs = [vs];
}

var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);

var acc = [],
visited = {};
_.each(vs, function(v) {
if (!g.hasNode(v)) {
throw new Error("Graph does not have node: " + v);
}

doDfs(g, v, order === "post", visited, acc);
doDfs(g, v, order === "post", visited, navigation, acc);
});
return acc;
}

function doDfs(g, v, postorder, visited, acc) {
function doDfs(g, v, postorder, visited, navigation, acc) {
if (!_.has(visited, v)) {
visited[v] = true;

if (!postorder) { acc.push(v); }
_.each(g.neighbors(v), function(w) {
doDfs(g, w, postorder, visited, acc);
_.each(navigation(v), function(w) {
doDfs(g, w, postorder, visited, navigation, acc);
});
if (postorder) { acc.push(v); }
}
Expand Down Expand Up @@ -1232,7 +1235,7 @@ if (!lodash) {
module.exports = lodash;

},{"lodash":22}],21:[function(require,module,exports){
module.exports = '1.0.7';
module.exports = '2.0.0';

},{}],22:[function(require,module,exports){
(function (global){
Expand Down
8 changes: 4 additions & 4 deletions dist/graphlib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '1.0.8-pre';
module.exports = '2.0.0';
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphlib",
"version": "1.0.8-pre",
"version": "2.0.0",
"description": "A directed and undirected multi-graph library",
"author": "Chris Pettitt <[email protected]>",
"main": "index.js",
Expand Down Expand Up @@ -37,4 +37,4 @@
"url": "https://github.com/cpettitt/graphlib.git"
},
"license": "MIT"
}
}

0 comments on commit 4b45faf

Please sign in to comment.