2016-11-28 81 views
0

如何使用与两个最低特征值(不同于0)相对应的特征向量作为x,y坐标来绘制图?使用两个最低特征值和特征向量在图中绘制numpy

我有从拉普拉斯节点图的特征值和特征向量的数组。我想做类似于MATLAB中的以下链接,但是使用Python。另外,而不只是菲尔德载体,我也希望接下来的矢量比菲尔德较大,以及:提前

https://www.mathworks.com/examples/matlab/mw/matlab-ex64540792-partition-graph-with-laplacian-matrix

谢谢!

+0

你可以显示你用来获取特征向量的代码吗? – Joel

回答

0

这个答案假定你已经有一个列表nodelist和两个向量vec1vec2的节点在相同的顺序。

Networkx使用一个字典(通常称为pos),其中pos[u]是节点u的(x,y)坐标。

import networkx as nx 

#your code here to define network and find the vectors. 
#Please edit a simple version of this code into your question so I can 
#add it here. 

pos = {node:(x,y) for node, x, y in zip(nodelist, vec1, vec2)} 
nx.draw_networkx(G, pos=pos) 

在定义pos,我用了一个dict comprehensionzip

相关问题