replaced hamiltonian with shortest