iVis-at-Bilkent / cytoscape.js-expand-collapse

A Cytoscape.js extension to expand/collapse nodes for better management of complexity of compound graphs
MIT License
125 stars 33 forks source link

expand(nodes, option) does not respect the passed options #138

Open OskarHowe opened 2 years ago

OskarHowe commented 2 years ago

Hi, I have observed, that the expand(nodes, options) function does not apply correctly the passed options, when called.

Reproduce the issue:

  1. Display the graph with a layout and specify this layout in the options object layoutBy : {name: dagre} field
  2. Collapse all nodes and edges with 2.1. collapseAll(options) 2.2. collapseAllEdges()
  3. Change the layoutBy field in the options object, layoutBy : {name: breadthfirst}
  4. Expand any collapsed nodeA using 4.1. expandEdgesBetweenNodes([nodeA, ...neighbors])) 4.2. expand(nodeA, options)
  5. Notice that the graph you see is still in the dagre layout.

When you use instead:

  1. ...
  2. Expand all collapsed nodes using 4.1. expandAllEdges() 4.2. expandAll(options)
  3. Notice that the new layout has been applied.

Possible reason By having a quick look into your source code, I assume the problem results from these lines in the file: expandCollapseUtilities.js, function: expandNodeBaseFunction, lines 46 – 48:

if (single) { this.endOperation(layoutBy, node); }

In any other expand function, see expandAll(options), the nodes will always be rearranged by the endOperation after expanding. Here, the rearrangement is conditional, which may cause this bug.