Working IP version of is_hamiltonian