Prettify the Diagram

The nodes and links are moved to some other place in canvas. It will look like below image


after clicking the button, It should prettify the diagram. May be new node can be included(drag and drop).It should look like below image

If you are not depending on the users to manually position the nodes, the positioning must be done programmatically. You can either write your own code to set their positions or Node.locations, or you more commonly you can use a predefined Layout:

If you set your Diagram.layout the layout will automatically arrange all of the nodes and links. If you don’t want it to happen all of the time you can limit what causes the layout to he invalidated: