Moving Obstacle Avoidance and Topology Recovery for Multi-agent Systems