Gathering a swarm of robots through shortest paths