for n in range(5, 46):
#n=5 #size of comb measured by length of the path, must be at least 3 for this program
N=floor((n-1)/2) #number left of center
M=ceil((n-1)/2) #number right of center
A=zero_matrix(QQ,4*(N+1)*(M+1)-3)
#matrix starts with 4 spots for initial states (only two are used for 0 and 0L)
#intermediate states are ordered (a,b,0,0),(a,b,1,0),(a,b,0,1),(a,b,1,1)
#a and b order by (1,0),(2,0),...,(N,0),(0,1),(1,1),...,(N,1),...,(0,M),(1,M),...,(N,M)
for k in IntegerRange(0,4*(N+1)*(M+1),4):
if k==4*(N+1)*(M+1)-4: #fully propogated case
A[k,k]=1
elif k>=4*(N+1)*(M+1)-4-4*N: #all right vertices propogated
A[k,k]=1/9
A[k,k+1]=2/9
A[k,k+4]=2/3
A[k+1,k+4]=1
elif k/4%(N+1)==N: #all left vertices propogated
A[k,k]=1/9
A[k,k+2]=2/9
A[k,k+(N+1)*4]=2/3
A[k+2,k+(N+1)*4]=1
elif k==0: #initial cases
A[k,k]=8/27
A[k,k+1]=4/27
A[k,k+4]=4/27
A[k,k+(N+1)*4]=4/27
A[k,k+6]=2/27
A[k,k+(N+1)*4+1]=2/27
A[k,k+(N+1)*4+4]=1/9
A[k+1,k+1]=1/9
A[k+1,k+6]=2/9
A[k+1,k+(N+1)*4+1]=2/9
A[k+1,k+(N+1)*4+4]=4/9
else: #all other cases
A[k,k]=1/81
A[k,k+1]=2/81
A[k,k+2]=2/81
A[k,k+3]=4/81
A[k,k+4]=2/27
A[k,k+6]=4/27
A[k,k+(N+1)*4]=2/27
A[k,k+(N+1)*4+1]=4/27
A[k,k+(N+1)*4+4]=4/9
A[k+1,k+4]=1/9
A[k+1,k+6]=2/9
A[k+1,k+(N+1)*4+4]=2/3
A[k+2,k+(N+1)*4]=1/9
A[k+2,k+(N+1)*4+1]=2/9
A[k+2,k+(N+1)*4+4]=2/3
A[k+3,k+(N+1)*4+4]=1
#show(A)
I=identity_matrix(RDF,4*(N+1)*(M+1)-3) #ept calculation process
for k in range(4*(N+1)*(M+1)-3):
I[k,4*(N+1)*(M+1)-4]=I[k,4*(N+1)*(M+1)-4]+1
B=(A-I).inverse()
print n
print "path EPT=",B[0,4*(N+1)*(M+1)-4]+2 #for propogation time starting along the path
print "leaf EPT=",B[1,4*(N+1)*(M+1)-4]+3 #for propogation time starting on a leaf
print ''