You might or might not be able to get exactly what you have shown , but something similar is possible using VBA. See this file.
There is a method called RerouteConnections , which is in the code ; you can run the macro both with this in , and after commenting it out , and see the difference.