run rewiring_edge several times until it finds a connected graph