Help:=proc(): print(`V(A,k)`): end: #V(A,k): all the k-letter words in the alphabet A V:=proc(A,k) local V1: if k=0 then RETURN({[]}): fi: V1:=V(A,k-1): {seq(seq([op(V1[i]), A[j]],j=1..nops(A)),i=1..nops(V1))}: end: #G(A,k): given an alphabet A and a pos. integer k #constructs the graph [V,E] whose set of vertices V #are all the k-letter words in A, and [u,v] is #an edge iff op(2..k,u)=op(1..k-1,v) # G:=proc(A,k) local V1,E1,i,j,v1: V1:=V(A,k): E1:={}: for i from 1 to nops(V1) do v1:=V1[i]: E1:=E1 union {seq([v1, [op(2..k,v1),A[j]]],j=1..nops(A))}: od: [V1,E1]: end: