目录
0.环境
1.前提
2.全部代码
0.环境
windows + eclipse + python
1.前提
我的邻接矩阵是固定的,11*11
2.全部代码
要将邻接矩阵使用numpy赋值
#计算矩阵特征值
import numpy as np
A = np.array([[0,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,1,1], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0],[1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0], [1,0,1,0,0,0,0,0,0,0,0]])
eig_values, eig_vectors = np.linalg.eig(A)print("特征值:", eig_values)
print("特征向量:", eig_vectors)
输出结果
--END--