Closed Alexithemia closed 3 years ago
@Alexithemia The main point of having this extension is complexity management. Through compound nodes we would like to cluster / group nodes and using collapsing we would like to give the users a chance to work on a much smaller graph. Not just in terms of rendering but also keeping a reasonably sized graph model. So it would defeat this purpose.
You can search the collapsed elements with a simple recursive algorithm. The collapsed elements are not in cytoscape.js but are stored in a data property named collapsedChildren
. You can read it like ele.data('collapsedChildren')
@canbax I understand how they are saved under data on the parent nodes, but they basically become inaccessible nodes through cytoscape when collapsed. I cannot select them, find them in a search to pan to or manipulate, and you cannot remove them, as they are already removed, and then uncollapsing the node it is re-added. To access them you would also have to know what node they are collapsed onto, you cannot find the nodes to run cy.$(selector).parent()
While they are collapsed they should still be in cytoscape they should be accessible. If someone runs a search on the graph for a certain element and it doesn't return because that node is collapsed then the data is incorrect right?
@ugurdogrusoz If you give collapsed nodes a class and they become display: none, the graph model will end up looking the same as it does now, but the nodes would still exist in cytoscape for manipulation.
Here is an example of filpping the nodes to display hidden, you would just create the meta-edges to the parent node as normal, and slap on the normal collapse node class onto the parent.
Just updating a class/style seems like a lot less processing than adding and removing nodes each time, so there would be a minimal performance bump there.
@Alexithemia I do understand what you're suggesting but if "the nodes would still exist in cytoscape for manipulation", that defeats the purpose. then we're only managing the complexity of the graph on the display but not in the memory. Besides, we have invested far too much to make such a change. Feel free to implement an alternative implementation (perhaps with an appropriate option that does your suggestion instead of the current behavior), compare its performance with the current implementation, and do a PR (on the "unstable" branch please) if you like though.
Have you considered not removing child nodes that would be collapsed and instead giving them a class that would style default to the nodes being display: none?
This way the nodes are still in the graph when collapsed and can still be searched/selected/removed through Cyto.
Could possibly be more performant not adding/removing elements all the time as well?