similar to this prototype http://jsfiddle.net/g5f16erz/ I use Cytoscape.js to create an interactive directed acyclic graph using the dagre layout.
In particular the following code is used to collapse and expand nodes:
cy.nodes().on('click', function(e) {
if (this.hasClass('open')) {
this.removeClass('open');
this.successors().removeClass('open').addClass('hidden');
} else {
var children = this.neighborhood('.hidden');
this.removeClass("collapsed");
children.removeClass("hidden");
children.incomers(".hidden").removeClass("hidden");
this.addClass('open');
}
});
Is there a way to recalculate the layout of the graph every time a node has been collapsed or expanded?
Thanks in advance