How can I refresh Cytoscape after add a new node?

3.2k views Asked by At

My Cytoscape is using arbor layout and I've loaded some nodes in initialization process. All worked fine. The nodes was created and moving some time until all stabilizes.

Now, with a button, I've added a new node:

function addNode() {
    var eles = cy.add([
       { group: "nodes", data: { id: 'zz', name: 'MyNewNode', weight: 450, faveColor: '#F5A45D', faveShape: 'rectangle' }, position: { x: 100, y: 100 } },
       { group: "edges", data: { source: 'zz', target: 'a', faveColor: '#F5A45D', strength: 1 } }
    ]);
}

But, as you can see, I need to specify the position of new node. How can I force all nodes to reacomodate, so I can add other nodes without concern about positions?

0

There are 0 answers