习题3.3

1.代码实现

点击查看代码
import numpy as np
from scipy.sparse.linalg import eigs
import pylab as plt
L=[(1,2),(1,3),(1,4),(1,5),(1,6),(2,4),(2,5),(2,6),(3,1),(3,2),(4,5),(4,6),(5,3),(5,6),(6,3)]
w=np.zeros((6,6))
for i in range(len(L)):
    w[L[i][0]-1,L[i][1]-1]=1
r=np.sum(w,axis=1,keepdims=True)
P=w/r
val,vec=eigs(P.T,1);V=vec.real
V=V.flatten();
V=V/V.sum();print("V=",np.round(V,4))
plt.bar(range(1,len(w)+1),V,width=0.6,color='y')
plt.show()
print("可见这六篇文章的影响力大小排序依次为(由大到小):3,6,2,5,1,4")

2.运行结果

posted on 2024-10-15 00:27  克卜勒星球  阅读(4)  评论(0编辑  收藏  举报

导航