iVis-at-Bilkent / cytoscape.js-fcose

fCoSE: a fast Compound Spring Embedder
MIT License
134 stars 25 forks source link

Cannot Layout The Graph and Tiles On Unconnected Nodes #49

Closed aryoxp closed 2 years ago

aryoxp commented 2 years ago

Hi!,

Thank you for a nice layout library for the Cytoscape.JS. I made the following pen: (https://codepen.io/aryoxp/pen/MWEWrWj) to test how the fcose layout the graph. According to the documentation, if I put the following option in the layout,

.layout({
    // For enabling tiling
    tile: true,
}).run();

I expect the library should layout the graph and tile unconnected nodes. However, when I run it, it tile all nodes, regardless connection. If the tile option is set to false, the graph is properly layout, including all unconnected nodes.

Is the library expected to behave like this? Because when I use an older version of the library (I don't remember which version), it behaves like I expect (layout the graph, group and tile all the remaining unconnected nodes).

PS: The same behaviour also happened on cose-bilkent layout.

Thank you. Warm regards,

Aryo

hasanbalci commented 2 years ago

Hi @aryoxp,

You need to call the layout on all elements, not only on nodes. Instead of this.cy.nodes().layout({ ... }).run(); please use this.cy.elements().layout({ ... }).run(); or this.cy.layout({ ... }).run();. Otherwise, layout cannot be aware of the edges.

aryoxp commented 2 years ago

Thank you, @hasanbalci. I understand now, and now it works perfectly.