This example allows you add, move, or remove robots from the network (left-click, drag and drop, and right-click, respectively).
Robots exchange their coordinates and move incrementally to a proper location based on virtual forces that combine spring forces, to regulate the distance between nodes, and angular forces, to regulate the angles between nodes in absence of triangle. The latter has the effect of biconnecting the network, thereby making it tolerant to the failure of any single node. More details in this paper (or the author version if you do not have access).
You can test the algorithm yourself by downloading
angular-forces.jar, which includes
the source code + JBotSim. The JAR can be executed by
java -jar angularforces.jar in a terminal or directly from your file explorer (in this case, you may have to set the file as executable).