networkx遇到节点没有位置

2024-10-02 12:33:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下内容: networkx: change node color in draw_circular

绘制一张有两个颜色节点的图片。在

我有一些数据,比如:

4556    5092    0.7000 
4556    4785    0.7500 
4556    5397    0.7000 
4556    5139    0.7500 
4556    5937    0.8333 
4556    6220    0.7000 
4556    5139    0.7500 
4556    6220    0.7063 
4559    4563    0.7500 
4559    4770    0.7500 
4559    4837    0.7500 
4559    5640    0.7500 
4559    4563    0.7500 
4559    4770    0.7500 
4559    4837    0.7500 
4559    5640    0.7500 
4561    4607    1.0000 
4561    4600    0.7500 
4561    4562    0.7500 
4561    5090    0.7500 
4561    5197    1.0000 
4561    5182    0.7500 
4561    5937    0.7500 
4561    6143    0.7500 
4561    5632    1.0000 
4561    5870    1.0000 
4561    6220    0.6756 
4561    6143    0.7500 
4561    6220    0.6750 
4562    4607    0.7500 
4562    5197    0.7500 
4562    5632    0.7500 
4562    5870    0.7500 
4562    6220    0.6656 
4564    4837    0.7500 
4564    4837    0.7500 
4566    5805    0.8750 
4566    5981    0.6729 
4571    4919    0.7000 
4571    6004    0.7500 
4571    6089    0.7000 
4571    6044    0.7500 
4571    6041    0.7000 
4571    5863    0.7500 
4571    6089    0.6398 

前两列是节点,第三列是边的长度。在

我的代码是:

^{pr2}$

1.txt是:https://gist.github.com/young001/5531613 2.txt是:https://gist.github.com/young001/5531619

回报是:

... 4.92, 483.05), 6090: (170.5, 1658.1), 6097: (240.99, 307.32), 6098: (486.58, 694.79), 6103: (1583.7, 107.5), 6104: (427.04, 394.65), 6106: (241.71, 1647.5), 6110: (886.42, 783.84), 6111: (1276.5, 1102.8), 6112: (1197.8, 1077.6), 6113: (1693.7, 1229.5), 6115: (986.75, 358.81), 6116: (109.71, 1317.5), 6118: (1179.3, 1208.9), 6119: (1182.6, 1013.3), 6122: (1336.5, 1581.2), 6125: (1184.4, 1383.5), 6128: (615.71, 85.5), 6131: (1147.7, 1198.8), 6133: (1286.3, 690.69), 6134: (1205.4, 684.59), 6136: (1148.7, 1188.5), 6139: (1195.1, 611.44), 6141: (1234.3, 840.18), 6143: (612.13, 1060.3)}
736
True
Traceback (most recent call last):
  File "dataplot.py", line 37, in <module>
    nx.draw_networkx_nodes(G,pos,nodelist=data1_list,node_size=20,node_color='r')
  File "/usr/local/lib/python2.7/dist-packages/networkx/drawing/nx_pylab.py", line 366, in draw_networkx_nodes
    raise nx.NetworkXError('Node %s has no position.'%e)
networkx.exception.NetworkXError: Node '4789' has no position.

为什么4789还没有呢?在


Tags: inpyhttpsnetworkxgithubtxtcomnode

热门问题