iVis-at-Bilkent / cytoscape.js-fcose

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

Better node positioning during tree reduction in incremental layout #42

Closed hasanbalci closed 2 years ago

hasanbalci commented 3 years ago

While applying tree reduction in incremental layout, we keep relative position of the one degree node with its adjacent before reduce operation, and then bring back that node according to its relative position again while growing the tree. But if the distance between two nodes is too much, then iterations applied during grow operation may not generate a good final layout for the one degree node. Therefore, relative position should be scaled, for example based on the ideal edge length, to provide a better positioning during grow operation.

hasanbalci commented 2 years ago

On second thoughts, considering the application of the incremental layout, nodes can be in two possible situations: they are already in the graph with not-so-bad positions and layout just wants to adjust them for a better positioning or they are newly added to the graph and layout wants to position them properly while preserving the mental map of the user.

For the first case, we can assume that nodes will have decent positions and a child will not be too far from its parent during reduce operation. For the second case, we can first position the newly added nodes near their adjacent using heuristic approaches (see layout-utilities extension). In this way, the child nodes again will not be far from their parents and the incremental layout will not have the problem mentioned in the issue. We can ignore extreme cases where we have to apply incremental layout while nodes do not have decent positions.