added Graph.detachNode which removes edges associated with a given node.
This commit is contained in:
parent
aad5e3cb80
commit
fa333bd664
|
@ -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();
|
var tmpEdges = this.edges.slice();
|
||||||
tmpEdges.forEach(function(e) {
|
tmpEdges.forEach(function(e) {
|
||||||
if (e.source.id === node.id || e.target.id === node.id)
|
if (e.source.id === node.id || e.target.id === node.id)
|
||||||
|
@ -150,7 +157,6 @@ Graph.prototype.removeNode = function(node)
|
||||||
this.notify();
|
this.notify();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// remove a node and it's associated edges from the graph
|
// remove a node and it's associated edges from the graph
|
||||||
Graph.prototype.removeEdge = function(edge)
|
Graph.prototype.removeEdge = function(edge)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user