Reputation: 2661
I have a Cytoscape graph, and certain user actions can add nodes to the graph. When this happens I want to apply a layout to the new nodes, so that they appear in a reasonable position. However, I want to leave the previously existing nodes at their current positions, since the user might have manually positioned them there.
I found two related questions on Stack Overflow, but they relate to slightly different things:
1) How to dynamically add nodes to cytoscape graph is about adding nodes, but the suggested approach applies the layout to all nodes, not only the new ones.
2) Cytoscape dynamically style last added node only is about applying styling to new nodes, but I'm interesting in the positioning of nodes, not the styling.
An obvious workaround would be to manually specify the position of the new nodes. However, the whole reason layouts exist in the first place is to have a way to calculate decent-looking positions. I'm pretty sure this is possible, I'm just unable to find this anywhere in the Cytoscape documentation.
Upvotes: 1
Views: 1252
Reputation: 1065
You can apply the layout on specific elements by using eles.layout()
There is also add
event which is triggered when a new node is added.
Upvotes: 3