added Graph.detachNode which removes edges associated with a given node.

This commit is contained in:
Cody 2011-08-23 11:48:57 -06:00
parent aad5e3cb80
commit fa333bd664

View File

@ -139,6 +139,13 @@ 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)
@ -150,7 +157,6 @@ Graph.prototype.removeNode = function(node)
this.notify();
};
// remove a node and it's associated edges from the graph
Graph.prototype.removeEdge = function(edge)
{