Restore retention of collapsed in graph viewer on reload.

And do a little refactoring of the cylc_xdot module.
Merge pull request #663 from hjoliver/graph-viewer-collapse-reload

Restore retention of collapsed state in graph viewer on reload.