how to convert any arbitrary list to an adjaceny matrix in python?

六眼飞鱼酱① 提交于 2020-01-03 05:25:08

问题


I have 684 nodes and its corresponding temperature data.I calculated the correlation between all nodes and then reshape correlation list in adjacency matrix for further calculation. But after introducing lag in correlation I am not able to reshape the list in adjacency matrix.

I am able to reshape the list to adjacency matrix without lag but having problem when introducing the lag.

I tried

corr_k= []
for k in range(4):
    for i in range(len(lat)):
         for j in range(len(lon)):
            for m in range(len(lat)):
                for n in range(len(lon)):
                    corr_k.append( np.corrcoef ( air5[(365-k):(730-k),i,j] ,air5[365:730, m,n]))
                df = pd.Dataframe(corr_k)
A = np.reshape(corr_k, (684, 684))

Now the problem is when i am introducing lag say 4, I got the list as (684*684*4) [684 total no. of nodes]. So now for each lag how to form adjacency matrix from the list?

来源:https://stackoverflow.com/questions/57972598/how-to-convert-any-arbitrary-list-to-an-adjaceny-matrix-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!