The changes in environmental parameters may demand switching between underlying topologies for better performance of distributed message passing applications. Arbitrary topology switching using distributed tree construction may lead to loss or redundancy in delivery of application messages. In this work, a set of algorithms has been proposed for dynamic switching between two spanning trees to offer better adaptivity towards the environment for different applications. Here, two extreme cases of spanning trees, a Breadth First Search (BFS) tree and a Depth First Search (DFS) tree, rooted at the core node, have been considered for switching. The core node initiates the switching and all other nodes cooperatively change their parents on the fly maintaining the DFS or BFS properties as required. However, the application remains transparent to the switching that assures the availability of the system at any instance of time. Simulation results show that each application message is delivered correctly to the destination without any loss or redundancy. The proposed scheme is scalable and the control message overhead for switching is linear with respect to the number of edges in the communication graph. Furthermore, there is no control message overhead to assure the delivery of application messages at the time of switching. © 2013, Springer Science+Business Media New York.