使用两个最低特征值和特征向量绘制numpy图

时间:2016-11-28 23:29:52

标签: python matlab numpy networkx

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

我有一些特征值和特征向量的数组来自节点图的拉普拉斯。我想做一些类似于MATLAB中的以下链接,但是在Python中。此外,我还希望下一个矢量大于Fielder,而不仅仅是Fielder矢量:

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

提前致谢!

1 个答案:

答案 0 :(得分:0)

此答案假设您已经在列表nodelist中有节点,并且两个向量vec1vec2的顺序相同。

Networkx使用dict(通常称为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

相关问题