Skip to content

Commit

Permalink
Prep v1.0.6 release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpettitt-linkedin committed Jul 10, 2015
1 parent a5f8014 commit e676f6a
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 11 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.5",
"version": "1.0.6",
"main": [
"dist/graphlib.core.js"
],
Expand Down
46 changes: 45 additions & 1 deletion dist/graphlib.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,50 @@ Graph.prototype.neighbors = function(v) {
}
};

Graph.prototype.filterNodes = function(filter) {
var copy = new this.constructor({
directed: this._isDirected,
multigraph: this._isMultigraph,
compound: this._isCompound
});

copy.setGraph(this.graph());

_.each(this._nodes, function(value, v) {
if (filter(v)) {
copy.setNode(v, value);
}
}, this);

_.each(this._edgeObjs, function(e) {
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
copy.setEdge(e, this.edge(e));
}
}, this);

var self = this;
var parents = {};
function findParent(v) {
var parent = self.parent(v);
if (parent === undefined || copy.hasNode(parent)) {
parents[v] = parent;
return parent;
} else if (parent in parents) {
return parents[parent];
} else {
return findParent(parent);
}
}

if (this._isCompound) {
_.each(copy.nodes(), function(v) {
copy.setParent(v, findParent(v));
});
}

return copy;
};

/* === Edge functions ========== */

Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
Expand Down Expand Up @@ -1183,6 +1227,6 @@ if (!lodash) {
module.exports = lodash;

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

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

Large diffs are not rendered by default.

46 changes: 45 additions & 1 deletion dist/graphlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,50 @@ Graph.prototype.neighbors = function(v) {
}
};

Graph.prototype.filterNodes = function(filter) {
var copy = new this.constructor({
directed: this._isDirected,
multigraph: this._isMultigraph,
compound: this._isCompound
});

copy.setGraph(this.graph());

_.each(this._nodes, function(value, v) {
if (filter(v)) {
copy.setNode(v, value);
}
}, this);

_.each(this._edgeObjs, function(e) {
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
copy.setEdge(e, this.edge(e));
}
}, this);

var self = this;
var parents = {};
function findParent(v) {
var parent = self.parent(v);
if (parent === undefined || copy.hasNode(parent)) {
parents[v] = parent;
return parent;
} else if (parent in parents) {
return parents[parent];
} else {
return findParent(parent);
}
}

if (this._isCompound) {
_.each(copy.nodes(), function(v) {
copy.setParent(v, findParent(v));
});
}

return copy;
};

/* === Edge functions ========== */

Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
Expand Down Expand Up @@ -1183,7 +1227,7 @@ if (!lodash) {
module.exports = lodash;

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

},{}],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.6-pre';
module.exports = '1.0.6';
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.6-pre",
"version": "1.0.6",
"description": "A directed and undirected multi-graph library",
"author": "Chris Pettitt <cpettitt@gmail.com>",
"main": "index.js",
Expand Down Expand Up @@ -36,4 +36,4 @@
"url": "https://github.com/cpettitt/graphlib.git"
},
"license": "MIT"
}
}

0 comments on commit e676f6a

Please sign in to comment.