Gravitational collapse and topology change in spherically symmetric dynamical systems