# From 6.3 FE 2N=matrix(RDF,[[0.25,0,0.8],[.25,.25,.05],[0.5,.75,0]])show(N)
# From 6.3 FE 2 w/ some outflowN=matrix(RDF,[[0.2,0,0.8],[.2,.25,.05],[0.3,.55,0]])show(N)
0.20.20.30.00.250.550.80.050.0
# If include plant->plant, consumer -> consumerprint"Adjacency Matrix #1:"P=matrix(RDF,[[1,0,1],[1,1,1],[1,1,0]])show(P)print"Adjacency Matrix #1 - Normalized"P2=matrix(RDF,[[1/3,0,1/2],[1/3,1/2,1/2],[1/3,1/2,0]])# Normalizedshow(P2)print"Eigenvectors of normalized adj matrix #1"P2.eigenvectors_right()# If don't includeprint"Adjacency Matrix #2 - Normalized - Eigenvectors"Q=matrix(RDF,[[0,0,1],[1,0,1],[1,1,0]])Q2=matrix(RDF,[[0,0,1/2],[1/2,0,1/2],[1/2,1,0]])# Normalizedshow(Q2)Q2.eigenvectors_right()# Looks like principal eigenvector has largest value for consumer, which implies that is most important part of food web (I would expect producers to be the most important)
# Matrix of indirect flows where i = # of iterationsGindirect=zero_matrix(RDF,3,3)foriinsrange(2,100):Gindirect+=G^iifi%10==0:print"i = "+str(i)show(Gindirect)# Doesn't converge to 1 matrix