Skip to content

Commit 4b45faf

Browse files
committed
Prep v2.0.0 release
1 parent 5a84ef8 commit 4b45faf

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphlib",
3-
"version": "1.0.7",
3+
"version": "2.0.0",
44
"main": [
55
"dist/graphlib.core.js"
66
],

dist/graphlib.core.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ module.exports = dfs;
109109

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

123+
var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);
124+
122125
var acc = [],
123126
visited = {};
124127
_.each(vs, function(v) {
125128
if (!g.hasNode(v)) {
126129
throw new Error("Graph does not have node: " + v);
127130
}
128131

129-
doDfs(g, v, order === "post", visited, acc);
132+
doDfs(g, v, order === "post", visited, navigation, acc);
130133
});
131134
return acc;
132135
}
133136

134-
function doDfs(g, v, postorder, visited, acc) {
137+
function doDfs(g, v, postorder, visited, navigation, acc) {
135138
if (!_.has(visited, v)) {
136139
visited[v] = true;
137140

138141
if (!postorder) { acc.push(v); }
139-
_.each(g.neighbors(v), function(w) {
140-
doDfs(g, w, postorder, visited, acc);
142+
_.each(navigation(v), function(w) {
143+
doDfs(g, w, postorder, visited, navigation, acc);
141144
});
142145
if (postorder) { acc.push(v); }
143146
}
@@ -1232,6 +1235,6 @@ if (!lodash) {
12321235
module.exports = lodash;
12331236

12341237
},{"lodash":undefined}],21:[function(require,module,exports){
1235-
module.exports = '1.0.7';
1238+
module.exports = '2.0.0';
12361239

12371240
},{}]},{},[1]);

dist/graphlib.core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/graphlib.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ module.exports = dfs;
109109

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

123+
var navigation = (g.isDirected() ? g.successors : g.neighbors).bind(g);
124+
122125
var acc = [],
123126
visited = {};
124127
_.each(vs, function(v) {
125128
if (!g.hasNode(v)) {
126129
throw new Error("Graph does not have node: " + v);
127130
}
128131

129-
doDfs(g, v, order === "post", visited, acc);
132+
doDfs(g, v, order === "post", visited, navigation, acc);
130133
});
131134
return acc;
132135
}
133136

134-
function doDfs(g, v, postorder, visited, acc) {
137+
function doDfs(g, v, postorder, visited, navigation, acc) {
135138
if (!_.has(visited, v)) {
136139
visited[v] = true;
137140

138141
if (!postorder) { acc.push(v); }
139-
_.each(g.neighbors(v), function(w) {
140-
doDfs(g, w, postorder, visited, acc);
142+
_.each(navigation(v), function(w) {
143+
doDfs(g, w, postorder, visited, navigation, acc);
141144
});
142145
if (postorder) { acc.push(v); }
143146
}
@@ -1232,7 +1235,7 @@ if (!lodash) {
12321235
module.exports = lodash;
12331236

12341237
},{"lodash":22}],21:[function(require,module,exports){
1235-
module.exports = '1.0.7';
1238+
module.exports = '2.0.0';
12361239

12371240
},{}],22:[function(require,module,exports){
12381241
(function (global){

dist/graphlib.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = '1.0.8-pre';
1+
module.exports = '2.0.0';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphlib",
3-
"version": "1.0.8-pre",
3+
"version": "2.0.0",
44
"description": "A directed and undirected multi-graph library",
55
"author": "Chris Pettitt <[email protected]>",
66
"main": "index.js",
@@ -37,4 +37,4 @@
3737
"url": "https://github.com/cpettitt/graphlib.git"
3838
},
3939
"license": "MIT"
40-
}
40+
}

0 commit comments

Comments
 (0)