Reputation: 33
When you remove nodes in cytoscape JS (using cy.remove()
), the edges attached to these nodes are also deleted from the graph. The description for cy.remove() says it removes elements from the graph and returns them.
However, the data that is returned does not include the deleted edges.
As a consequence the following sequence of operations
removedData = cy.remove(someNodes); cy.add(removedData);
do modify the graph, as they could cause some edges to disappear.
How should you perform a reversible removal operation in Cytoscape JS?
Upvotes: 3
Views: 3019
Reputation: 8294
With CytoscapeJS 2.5.4 I can run the following and the connected nodes are removed and restored
removedData = cy.remove("#node2");
--pause--
removedDate.restore();
Upvotes: 0
Reputation: 192
You could just include the edges explicitly:
removedData = cy.remove(someNodes.union(someNodes.connectedEdges()));
Then both removedData.restore()
and cy.add(removedData)
will restore both nodes and edges.
Upvotes: 5