Updated topology generation logic.