Comparing version 2.1.2 to 2.1.5
{ | ||
"name": "graphlib", | ||
"version": "2.1.2", | ||
"version": "2.1.5", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "dist/graphlib.core.js" |
@@ -705,11 +705,13 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.graphlib = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
Graph.prototype.sources = function() { | ||
return _.filter(this.nodes(), _.bind(function(v) { | ||
return _.isEmpty(this._in[v]); | ||
}, this)); | ||
var self = this; | ||
return _.filter(this.nodes(), function(v) { | ||
return _.isEmpty(self._in[v]); | ||
}); | ||
}; | ||
Graph.prototype.sinks = function() { | ||
return _.filter(this.nodes(), _.bind(function(v) { | ||
return _.isEmpty(this._out[v]); | ||
}, this)); | ||
var self = this; | ||
return _.filter(this.nodes(), function(v) { | ||
return _.isEmpty(self._out[v]); | ||
}); | ||
}; | ||
@@ -719,9 +721,10 @@ | ||
var args = arguments; | ||
_.each(vs, _.bind(function(v) { | ||
var self = this; | ||
_.each(vs, function(v) { | ||
if (args.length > 1) { | ||
this.setNode(v, value); | ||
self.setNode(v, value); | ||
} else { | ||
this.setNode(v); | ||
self.setNode(v); | ||
} | ||
}, this)); | ||
}); | ||
return this; | ||
@@ -768,5 +771,5 @@ }; | ||
delete this._parent[v]; | ||
_.each(this.children(v), _.bind(function(child) { | ||
this.setParent(child); | ||
}, this)); | ||
_.each(this.children(v), function(child) { | ||
self.setParent(child); | ||
}); | ||
delete this._children[v]; | ||
@@ -800,3 +803,3 @@ } | ||
throw new Error("Setting " + parent+ " as parent of " + v + | ||
" would create create a cycle"); | ||
" would create a cycle"); | ||
} | ||
@@ -885,15 +888,15 @@ } | ||
_.each(this._nodes, _.bind(function(value, v) { | ||
var self = this; | ||
_.each(this._nodes, function(value, v) { | ||
if (filter(v)) { | ||
copy.setNode(v, value); | ||
} | ||
}, this)); | ||
}); | ||
_.each(this._edgeObjs, _.bind(function(e) { | ||
_.each(this._edgeObjs, function(e) { | ||
if (copy.hasNode(e.v) && copy.hasNode(e.w)) { | ||
copy.setEdge(e, this.edge(e)); | ||
copy.setEdge(e, self.edge(e)); | ||
} | ||
}, this)); | ||
}); | ||
var self = this; | ||
var parents = {}; | ||
@@ -1218,5 +1221,5 @@ function findParent(v) { | ||
},{"lodash":undefined}],20:[function(require,module,exports){ | ||
module.exports = '2.1.2'; | ||
module.exports = '2.1.5'; | ||
},{}]},{},[1])(1) | ||
}); |
@@ -123,5 +123,5 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.graphlib=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){/** | ||
Graph.prototype.isDirected=function(){return this._isDirected};Graph.prototype.isMultigraph=function(){return this._isMultigraph};Graph.prototype.isCompound=function(){return this._isCompound};Graph.prototype.setGraph=function(label){this._label=label;return this};Graph.prototype.graph=function(){return this._label};/* === Node functions ========== */ | ||
Graph.prototype.setDefaultNodeLabel=function(newDefault){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultNodeLabelFn=newDefault;return this};Graph.prototype.nodeCount=function(){return this._nodeCount};Graph.prototype.nodes=function(){return _.keys(this._nodes)};Graph.prototype.sources=function(){return _.filter(this.nodes(),_.bind(function(v){return _.isEmpty(this._in[v])},this))};Graph.prototype.sinks=function(){return _.filter(this.nodes(),_.bind(function(v){return _.isEmpty(this._out[v])},this))};Graph.prototype.setNodes=function(vs,value){var args=arguments;_.each(vs,_.bind(function(v){if(args.length>1){this.setNode(v,value)}else{this.setNode(v)}},this));return this};Graph.prototype.setNode=function(v,value){if(_.has(this._nodes,v)){if(arguments.length>1){this._nodes[v]=value}return this}this._nodes[v]=arguments.length>1?value:this._defaultNodeLabelFn(v);if(this._isCompound){this._parent[v]=GRAPH_NODE;this._children[v]={};this._children[GRAPH_NODE][v]=true}this._in[v]={};this._preds[v]={};this._out[v]={};this._sucs[v]={};++this._nodeCount;return this};Graph.prototype.node=function(v){return this._nodes[v]};Graph.prototype.hasNode=function(v){return _.has(this._nodes,v)};Graph.prototype.removeNode=function(v){var self=this;if(_.has(this._nodes,v)){var removeEdge=function(e){self.removeEdge(self._edgeObjs[e])};delete this._nodes[v];if(this._isCompound){this._removeFromParentsChildList(v);delete this._parent[v];_.each(this.children(v),_.bind(function(child){this.setParent(child)},this));delete this._children[v]}_.each(_.keys(this._in[v]),removeEdge);delete this._in[v];delete this._preds[v];_.each(_.keys(this._out[v]),removeEdge);delete this._out[v];delete this._sucs[v];--this._nodeCount}return this};Graph.prototype.setParent=function(v,parent){if(!this._isCompound){throw new Error("Cannot set parent in a non-compound graph")}if(_.isUndefined(parent)){parent=GRAPH_NODE}else{ | ||
Graph.prototype.setDefaultNodeLabel=function(newDefault){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultNodeLabelFn=newDefault;return this};Graph.prototype.nodeCount=function(){return this._nodeCount};Graph.prototype.nodes=function(){return _.keys(this._nodes)};Graph.prototype.sources=function(){var self=this;return _.filter(this.nodes(),function(v){return _.isEmpty(self._in[v])})};Graph.prototype.sinks=function(){var self=this;return _.filter(this.nodes(),function(v){return _.isEmpty(self._out[v])})};Graph.prototype.setNodes=function(vs,value){var args=arguments;var self=this;_.each(vs,function(v){if(args.length>1){self.setNode(v,value)}else{self.setNode(v)}});return this};Graph.prototype.setNode=function(v,value){if(_.has(this._nodes,v)){if(arguments.length>1){this._nodes[v]=value}return this}this._nodes[v]=arguments.length>1?value:this._defaultNodeLabelFn(v);if(this._isCompound){this._parent[v]=GRAPH_NODE;this._children[v]={};this._children[GRAPH_NODE][v]=true}this._in[v]={};this._preds[v]={};this._out[v]={};this._sucs[v]={};++this._nodeCount;return this};Graph.prototype.node=function(v){return this._nodes[v]};Graph.prototype.hasNode=function(v){return _.has(this._nodes,v)};Graph.prototype.removeNode=function(v){var self=this;if(_.has(this._nodes,v)){var removeEdge=function(e){self.removeEdge(self._edgeObjs[e])};delete this._nodes[v];if(this._isCompound){this._removeFromParentsChildList(v);delete this._parent[v];_.each(this.children(v),function(child){self.setParent(child)});delete this._children[v]}_.each(_.keys(this._in[v]),removeEdge);delete this._in[v];delete this._preds[v];_.each(_.keys(this._out[v]),removeEdge);delete this._out[v];delete this._sucs[v];--this._nodeCount}return this};Graph.prototype.setParent=function(v,parent){if(!this._isCompound){throw new Error("Cannot set parent in a non-compound graph")}if(_.isUndefined(parent)){parent=GRAPH_NODE}else{ | ||
// Coerce parent to string | ||
parent+="";for(var ancestor=parent;!_.isUndefined(ancestor);ancestor=this.parent(ancestor)){if(ancestor===v){throw new Error("Setting "+parent+" as parent of "+v+" would create create a cycle")}}this.setNode(parent)}this.setNode(v);this._removeFromParentsChildList(v);this._parent[v]=parent;this._children[parent][v]=true;return this};Graph.prototype._removeFromParentsChildList=function(v){delete this._children[this._parent[v]][v]};Graph.prototype.parent=function(v){if(this._isCompound){var parent=this._parent[v];if(parent!==GRAPH_NODE){return parent}}};Graph.prototype.children=function(v){if(_.isUndefined(v)){v=GRAPH_NODE}if(this._isCompound){var children=this._children[v];if(children){return _.keys(children)}}else if(v===GRAPH_NODE){return this.nodes()}else if(this.hasNode(v)){return[]}};Graph.prototype.predecessors=function(v){var predsV=this._preds[v];if(predsV){return _.keys(predsV)}};Graph.prototype.successors=function(v){var sucsV=this._sucs[v];if(sucsV){return _.keys(sucsV)}};Graph.prototype.neighbors=function(v){var preds=this.predecessors(v);if(preds){return _.union(preds,this.successors(v))}};Graph.prototype.isLeaf=function(v){var neighbors;if(this.isDirected()){neighbors=this.successors(v)}else{neighbors=this.neighbors(v)}return neighbors.length===0};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,_.bind(function(value,v){if(filter(v)){copy.setNode(v,value)}},this));_.each(this._edgeObjs,_.bind(function(e){if(copy.hasNode(e.v)&©.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 ========== */ | ||
parent+="";for(var ancestor=parent;!_.isUndefined(ancestor);ancestor=this.parent(ancestor)){if(ancestor===v){throw new Error("Setting "+parent+" as parent of "+v+" would create a cycle")}}this.setNode(parent)}this.setNode(v);this._removeFromParentsChildList(v);this._parent[v]=parent;this._children[parent][v]=true;return this};Graph.prototype._removeFromParentsChildList=function(v){delete this._children[this._parent[v]][v]};Graph.prototype.parent=function(v){if(this._isCompound){var parent=this._parent[v];if(parent!==GRAPH_NODE){return parent}}};Graph.prototype.children=function(v){if(_.isUndefined(v)){v=GRAPH_NODE}if(this._isCompound){var children=this._children[v];if(children){return _.keys(children)}}else if(v===GRAPH_NODE){return this.nodes()}else if(this.hasNode(v)){return[]}};Graph.prototype.predecessors=function(v){var predsV=this._preds[v];if(predsV){return _.keys(predsV)}};Graph.prototype.successors=function(v){var sucsV=this._sucs[v];if(sucsV){return _.keys(sucsV)}};Graph.prototype.neighbors=function(v){var preds=this.predecessors(v);if(preds){return _.union(preds,this.successors(v))}};Graph.prototype.isLeaf=function(v){var neighbors;if(this.isDirected()){neighbors=this.successors(v)}else{neighbors=this.neighbors(v)}return neighbors.length===0};Graph.prototype.filterNodes=function(filter){var copy=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});copy.setGraph(this.graph());var self=this;_.each(this._nodes,function(value,v){if(filter(v)){copy.setNode(v,value)}});_.each(this._edgeObjs,function(e){if(copy.hasNode(e.v)&©.hasNode(e.w)){copy.setEdge(e,self.edge(e))}});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){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultEdgeLabelFn=newDefault;return this};Graph.prototype.edgeCount=function(){return this._edgeCount};Graph.prototype.edges=function(){return _.values(this._edgeObjs)};Graph.prototype.setPath=function(vs,value){var self=this,args=arguments;_.reduce(vs,function(v,w){if(args.length>1){self.setEdge(v,w,value)}else{self.setEdge(v,w)}return w});return this};/* | ||
@@ -139,2 +139,2 @@ * setEdge(v, w, [value, [name]]) | ||
module.exports={Graph:require("./graph"),version:require("./version")}},{"./graph":16,"./version":20}],18:[function(require,module,exports){var _=require("./lodash"),Graph=require("./graph");module.exports={write:write,read:read};function write(g){var json={options:{directed:g.isDirected(),multigraph:g.isMultigraph(),compound:g.isCompound()},nodes:writeNodes(g),edges:writeEdges(g)};if(!_.isUndefined(g.graph())){json.value=_.clone(g.graph())}return json}function writeNodes(g){return _.map(g.nodes(),function(v){var nodeValue=g.node(v),parent=g.parent(v),node={v:v};if(!_.isUndefined(nodeValue)){node.value=nodeValue}if(!_.isUndefined(parent)){node.parent=parent}return node})}function writeEdges(g){return _.map(g.edges(),function(e){var edgeValue=g.edge(e),edge={v:e.v,w:e.w};if(!_.isUndefined(e.name)){edge.name=e.name}if(!_.isUndefined(edgeValue)){edge.value=edgeValue}return edge})}function read(json){var g=new Graph(json.options).setGraph(json.value);_.each(json.nodes,function(entry){g.setNode(entry.v,entry.value);if(entry.parent){g.setParent(entry.v,entry.parent)}});_.each(json.edges,function(entry){g.setEdge({v:entry.v,w:entry.w,name:entry.name},entry.value)});return g}},{"./graph":16,"./lodash":19}],19:[function(require,module,exports){/* global window */ | ||
var lodash;if(typeof require==="function"){try{lodash=require("lodash")}catch(e){}}if(!lodash){lodash=window._}module.exports=lodash},{lodash:undefined}],20:[function(require,module,exports){module.exports="2.1.2"},{}]},{},[1])(1)}); | ||
var lodash;if(typeof require==="function"){try{lodash=require("lodash")}catch(e){}}if(!lodash){lodash=window._}module.exports=lodash},{lodash:undefined}],20:[function(require,module,exports){module.exports="2.1.5"},{}]},{},[1])(1)}); |
@@ -116,11 +116,13 @@ "use strict"; | ||
Graph.prototype.sources = function() { | ||
return _.filter(this.nodes(), _.bind(function(v) { | ||
return _.isEmpty(this._in[v]); | ||
}, this)); | ||
var self = this; | ||
return _.filter(this.nodes(), function(v) { | ||
return _.isEmpty(self._in[v]); | ||
}); | ||
}; | ||
Graph.prototype.sinks = function() { | ||
return _.filter(this.nodes(), _.bind(function(v) { | ||
return _.isEmpty(this._out[v]); | ||
}, this)); | ||
var self = this; | ||
return _.filter(this.nodes(), function(v) { | ||
return _.isEmpty(self._out[v]); | ||
}); | ||
}; | ||
@@ -130,9 +132,10 @@ | ||
var args = arguments; | ||
_.each(vs, _.bind(function(v) { | ||
var self = this; | ||
_.each(vs, function(v) { | ||
if (args.length > 1) { | ||
this.setNode(v, value); | ||
self.setNode(v, value); | ||
} else { | ||
this.setNode(v); | ||
self.setNode(v); | ||
} | ||
}, this)); | ||
}); | ||
return this; | ||
@@ -179,5 +182,5 @@ }; | ||
delete this._parent[v]; | ||
_.each(this.children(v), _.bind(function(child) { | ||
this.setParent(child); | ||
}, this)); | ||
_.each(this.children(v), function(child) { | ||
self.setParent(child); | ||
}); | ||
delete this._children[v]; | ||
@@ -211,3 +214,3 @@ } | ||
throw new Error("Setting " + parent+ " as parent of " + v + | ||
" would create create a cycle"); | ||
" would create a cycle"); | ||
} | ||
@@ -296,15 +299,15 @@ } | ||
_.each(this._nodes, _.bind(function(value, v) { | ||
var self = this; | ||
_.each(this._nodes, function(value, v) { | ||
if (filter(v)) { | ||
copy.setNode(v, value); | ||
} | ||
}, this)); | ||
}); | ||
_.each(this._edgeObjs, _.bind(function(e) { | ||
_.each(this._edgeObjs, function(e) { | ||
if (copy.hasNode(e.v) && copy.hasNode(e.w)) { | ||
copy.setEdge(e, this.edge(e)); | ||
copy.setEdge(e, self.edge(e)); | ||
} | ||
}, this)); | ||
}); | ||
var self = this; | ||
var parents = {}; | ||
@@ -311,0 +314,0 @@ function findParent(v) { |
@@ -1,1 +0,1 @@ | ||
module.exports = '2.1.2'; | ||
module.exports = '2.1.5'; |
{ | ||
"name": "graphlib", | ||
"version": "2.1.2", | ||
"version": "2.1.5", | ||
"description": "A directed and undirected multi-graph library", | ||
@@ -5,0 +5,0 @@ "author": "Chris Pettitt <cpettitt@gmail.com>", |
@@ -6,3 +6,3 @@ # Graphlib | ||
[![Build Status](https://secure.travis-ci.org/cpettitt/graphlib.png)](http://travis-ci.org/cpettitt/graphlib) | ||
[![Build Status](https://secure.travis-ci.org/dagrejs/graphlib.svg)](http://travis-ci.org/dagrejs/graphlib) | ||
@@ -15,4 +15,4 @@ To learn more [see our Wiki](https://github.com/cpettitt/graphlib/wiki). | ||
[LICENSE](LICENSE) file | ||
aor details. | ||
for details. | ||
[npm package manager]: http://npmjs.org/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30145
1162719