auto arrange

Is there any procedure or function or example to implement a self-arrange the diagram?

thank you

Unfortunately not, you would have to do it programatically yourself.