Documente Academic
Documente Profesional
Documente Cultură
JENIL MEHTA
17BCE0579
FACULTY: LOKESHKUMAR R
CODE:
import numpy as np
print("Enter number of nodes")
num_nodes = int(input())
print("Enter damping factor")
d=float(input())
r=list(map(float,input().split(',')))
matrix.append(r)
a=np.array(matrix)
d_matrix = np.array([[d]]*a.shape[1])
a_trans=a.T
for i in range(n):
a1 = np.matmul(a_trans, d_matrix)
d_matrix = a1
print(sorted_by_value)
OUTPUT:
CODE:
import numpy as np
adjacency_mtx = np.matrix([
[0,1,1,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1],
[0,0,0,0,1,0,1,0,0],
[0,0,1,0,0,0,1,0,0],
[0,1,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,1,1],
[0,0,0,0,0,1,0,0,1],
[0,0,0,0,0,0,0,0,0]
])
hub_score = np.matrix([ #initial guess
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1],
[1]
])
authority_score = np.matrix.transpose(adjacency_mtx)*hub_score
hub_score = adjacency_mtx*authority_score
auth={}
hub={}
for i in range(9):
auth[i+1]=int(authority_score[i][0])
hub[i+1]=int(hub_score[i][0])