#ClosestEligibleMatches(k,f,i): #given an fpl f of size k, and i in [1,2k], finds the #shortest eligible match to be e_i(f) #For example, try: #ClosestEligibleMatches(3,FPL(3)[1],1); ClosestEligibleMatches:=proc(k,f,i) local gu,shi,mu,g: gu:=EligibleMatches(k,f,i): if gu={} then RETURN(FAIL): fi: shi:=min(seq(g[2], g in gu)): mu:={}: for g in gu do if g[2]=shi then mu:=mu union {g[1]}: fi: od: mu: end: #PathFrom(k,P1,f): Given a point P1 in [0,k+1]^2 #with degree 1, and an fpl f, #finds the path that starts with P1. #For example, try: #PathFrom(3,[1,0],FPL(3)[1]); PathFrom:=proc(k,P1,P2,f) local T,edg, i,j,lu: option remember: for i from 0 to k+1 do for j from 0 to k+1 do T[[i,j]]:={}: od: od: for edg in f do T[edg[1]]:=T[edg[1]] union {edg[2]}: T[edg[2]]:=T[edg[2]] union {edg[1]}: od: if nops(T[P1])<>1 then RETURN(FAIL): fi: gu:=[P1]: lu:=T[P1][1]: while nops(T[lu])=2 do gu:=[op(gu),lu]: lu:=(T[lu] minus {lu})[1]: od: gu: end: