gh-35956: Fix several issues in find_hamiltonian
Part of #35902.
The method `find_hamiltonian` had multiple issues: it was not robust to
vertices with incomparable labels, it could loop forever if a vertex has
degree 1, a segfault was possible on small graphs, it was not properly
working for digraphs, etc.
We fix multiple issues and the method should now be safe.
### :memo: Checklist
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.
URL: https://github.com/sagemath/sage/pull/35956
Reported by: David Coudert
Reviewer(s): Dima Pasechnik