A surface hopping algorithm for nonadiabatic minimum energy path calculations