import numpy as np


N=int (input("\n How many number of pages:"))
d = 0.85    #damping factor
eps = 1.0e-8  #epsilon quadratic error use for convergence

print("\b Please Enter the Adjacency Matrix for the Network")
print("\nType 1 if there is a link from a Page i to Page j els Type 0")


links =[]

outboundL = np.zeros((N,1),dtype=int)

for  i in range (0,N):
     for j in range (0,N):
         if Links[i][j]==1:
             outboundL[i]=outboundL[i]+1

M = np.zeros((N,N))

for  i in range (0,N):
     for j in range (0,N):
         if links[i][j]==1:
           M[i][j]  = 1/outboundL[j]
          

M = np.matrix(M)
oneColMat=np.matrix(np.ones((N,1),dtype=int))
 
R=np.matrix(np.full(N,1),1/N))
    
while True:
    Rnext = d*np.dot(M,R) +((1-d)/N)*oneColMat
    diff= np.subtract(Rnext,R)
    if np.linalg.norm(diff) < eps: break
  R=Rnext