Comparing version 0.5.6 to 0.5.7
@@ -0,1 +1,6 @@ | ||
v0.5.7 | ||
====== | ||
* Fix toString, copy, filterNodes for compound graphs. | ||
v0.5.6 | ||
@@ -2,0 +7,0 @@ ====== |
@@ -144,20 +144,17 @@ var filter = require("./filter"), | ||
BaseGraph.prototype.copy = function() { | ||
return this.filterNodes(filter.all); | ||
var copy = new this.constructor(); | ||
copy.graph(this.graph); | ||
this.eachNode(function(u, value) { copy.addNode(u, value); }); | ||
this.eachEdge(function(e, u, v, value) { copy.addEdge(e, u, v, value); }); | ||
return copy; | ||
}; | ||
BaseGraph.prototype.filterNodes = function(filter) { | ||
var graph = new this.constructor(); | ||
this.eachNode(function(u, value) { | ||
if (filter(u, value)) { | ||
graph.addNode(u, value); | ||
var copy = this.copy(); | ||
this.nodes().forEach(function(u) { | ||
if (!filter(u)) { | ||
copy.delNode(u); | ||
} | ||
}); | ||
this.eachEdge(function(e, u, v, value) { | ||
if (graph.hasNode(u) && graph.hasNode(v)) { | ||
graph.addEdge(e, u, v, value); | ||
} | ||
}); | ||
return graph; | ||
return copy; | ||
}; | ||
@@ -164,0 +161,0 @@ |
@@ -32,1 +32,5 @@ var Digraph = require("./Digraph"), | ||
}; | ||
CDigraph.prototype.toString = function() { | ||
return "CDigraph " + JSON.stringify(this, null, 2); | ||
}; |
@@ -32,1 +32,5 @@ var Graph = require("./Graph"), | ||
}; | ||
CGraph.prototype.toString = function() { | ||
return "CGraph " + JSON.stringify(this, null, 2); | ||
}; |
@@ -73,3 +73,11 @@ // This file provides a helper function that mixes-in Dot behavior to an | ||
Constructor.prototype.copy = function() { | ||
var copy = SuperConstructor.prototype.copy.call(this); | ||
this.nodes().forEach(function(u) { | ||
copy.parent(u, this.parent(u)); | ||
}, this); | ||
return copy; | ||
}; | ||
return Constructor; | ||
} |
@@ -1,1 +0,1 @@ | ||
module.exports = '0.5.6'; | ||
module.exports = '0.5.7'; |
{ | ||
"name": "graphlib", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"description": "A directed and undirected multi-graph library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
57398
1475