Solution (source code)

= Solution

An $n$-step <self-avoiding walk> on a <graph> $G=(V,E)$ is a sequence $(v_0,v_1,\ldots,v_n)$ of $n+1$ distinct <graph vertices> such that $\{v_{i-1},v_i\}\in E$ for $1\leq i\leq n$. \b[It has $n$ edges and no repeated vertex], including its starting <graph vertex>. The $0$-step <self-avoiding walk> consists of its starting <graph vertex> alone.