We need an animation that draws lots of circles in a snake pattern like the one of the website
As usual each node can have two possible values (0 or 1), so they can have two colors WHITE or BLACK, and we also need a function that animates the color changes. Maybe we can just reuse the update_fill function already present in the code
Each circle will be connected by a segment with the color=hamiltonian_color
i'd say that is better to put the code in a separate python file inside the project folder
Tip
In the website code i wrote a function that returns the realtive position in a $i,j$ grid of all the elements in the serpentine, i think translating this in python this will make your job easier.
I don't know how deep i have to go into the explanation of this function, but printing the output a couple of times should be enough. if you need any clarifiaction you can always ask
function Serpentine(i, nSH) {
//nSH represents the variable numSpinsHorizontal
if (i<nSH) return [i, 0]
if (i==nSH) return [nSH-1, 1]
if (i<=2*nSH) return [2*nSH-i, 2]
if (i==2*nSH+1) return [0,3]
let recursive=Serpentine(i%(2*(nSH+1)),nSH);
recursive[1]+=4*Math.floor(i/(2*nSH+2));
return recursive
}
We need an animation that draws lots of circles in a snake pattern like the one of the website
As usual each node can have two possible values (0 or 1), so they can have two colors
WHITE
orBLACK
, and we also need a function that animates the color changes. Maybe we can just reuse theupdate_fill
function already present in the codeEach circle will be connected by a segment with the color=
hamiltonian_color
i'd say that is better to put the code in a separate python file inside the project folder
Tip
In the website code i wrote a function that returns the realtive position in a $i,j$ grid of all the elements in the serpentine, i think translating this in python this will make your job easier.
I don't know how deep i have to go into the explanation of this function, but printing the output a couple of times should be enough. if you need any clarifiaction you can always ask