Merge pull request #6 from codr/master

Added detachNode
This commit is contained in:
Dennis Hotson 2011-10-20 17:14:16 -07:00
commit 84bf82ad5e

View File

@ -121,6 +121,12 @@ Graph.prototype.removeNode = function(node) {
}
}
this.detachNode(node);
};
// removes edges associated with a given node
Graph.prototype.detachNode = function(node) {
var tmpEdges = this.edges.slice();
tmpEdges.forEach(function(e) {
if (e.source.id === node.id || e.target.id === node.id) {
@ -131,7 +137,6 @@ Graph.prototype.removeNode = function(node) {
this.notify();
};
// remove a node and it's associated edges from the graph
Graph.prototype.removeEdge = function(edge) {
for (var i = this.edges.length - 1; i >= 0; i--) {