I just observed that there are too many questions regarding resetting a cytoscape.js graph to its originally loaded state.
Following is a simple function you need to call to reset the graph:
cy.layout();
You can bind it to click events as and when needed.
Cheers!
To reset to original state:
To fit the randomly panned/zoomed graph to the div:
Hope it helps!