Sorry if this has been asked before but I wonder how to detect minimum number of nodes for given Hamiltonian Path for fixed endpoints. Lets say below is a Hamiltonian path from $1$ to $16$;
And if we keep endpoints ($1$ is start and 16 is end) and say one can only move from $2$ to $3$ we still end up with the same path. So my question is how to detect those unnecessary nodes to remove. Is there any source, subject or type of algorithm that I can use?
P.S. I want to solve this question without generating all other possible Hamiltonian Paths for $4\times 4$ grid. Thanks in advance.