#please do not post homework Kenneth Chan Math 454 HW 15 1. RoG:=proc(k,n) local V,E,i,j,T1,v,Neighs,Moves,m,pt: V:=[seq(seq(seq([i,j],j=1..n),i=1..k))]: for i from 1 to nops(V) do T1[V[i]]:=i: od: E:=[]: for i from 1 to nops(V) do pt:=V[i]: Moves:={[1..n,0],[0,1..n]}: A rook can either move left and right or up and down Neighs:={seq(pt+m,m in Moves)}: #But many of them fall off the board, Neighs:=Neighs intersect convert(V,set): #We append to the "list of neighbors" the set of neighbors of the current vertex BUT in terms of their "ids" (given by T1) #getting a description of the graph in "cannical form" E:=[op(E),{seq(T1[v],v in Neighs)}]: od: #We return the graph in "canonical form" where the vertices (members of V), are labelled by positive inetegers from 1 to nops(V) #together with the "dictionary" E,V: SAW:=SAWnu(RoG(k,n)): end: 2.NuGW([40,40],{[1,0],[0,1],[1,1],[2,2]}) any step with [1,0] or [0,1] will go above x=y SeqGW([20,20,20],{[1,0,0],[0,1,0],[0,0,1],[1,1,1,]}