FindHamiltonianPath¶
FindHamiltonianPath[g] gives the vertices of one path that visits every
vertex of g exactly once, or {} when the graph has none:
$ wo '{FindHamiltonianPath[CycleGraph[4]], FindHamiltonianPath[Graph[{1 <-> 2, 3 <-> 4}]]}'
{{1, 2, 3, 4}, {}}
Directed edges are followed in their own direction only:
FindHamiltonianPath[g, s, t] asks for a path from s to t: