尝试使用源user_id和目标user_id访问边缘
https://www.amazon.in/Apple-iPhone-11-64GB-Green/dp/B07XVKBY68/ref=sr_1_7?keywords=iphone+11&qid=1573668357&sr=8-7
₹ 64,499.00
https://www.amazon.it/Apple-iPhone-64GB-Verde-Ricondizionato/dp/B082DN72G3/ref=sr_1_19?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&dchild=1&keywords=iphone+11&qid=1601755114&sr=8-19
744,89 €
https://www.amazon.it/Apple-iPhone-11-128GB-Verde/dp/B07XS5MSW4/ref=sr_1_1_sspa?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&dchild=1&keywords=iphone+11&qid=1601755114&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExNlhGMElFNUhJMTBJJmVuY3J5cHRlZElkPUEwMTI2OTMxMVpXWEtHQ1o5S0ZENCZlbmNyeXB0ZWRBZElkPUEwOTMyMTczMVdMMzlQOTRPTUE3SCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=
749,00 €
错误:
# so we can access the edge using the source user_id and the target user_id
G.edges([nodelist[0]][list(e.keys())[0]])
我正面临的另一个错误...
尝试列出所有节点
AttributeError Traceback (most recent call last)
<ipython-input-48-12593dd17b79> in <module>
1 # so we can access the edge using the source user_id and the target user_id
----> 2 G.edges([nodelist[0]][list(e.keys())[0]])
AttributeError: 'OutEdgeDataView' object has no attribute 'keys'
错误:
# listing all nodes
nodelist = G.nodes()
nodelist[:3]
答案 0 :(得分:1)
我相信您的错误是相关的。我不确定,因为您没有在上面的代码中定义变量e
,但是根据错误中的类型,您好像将其定义为e = G.edges()
并返回了{{1} }对象,而不是您想要的字典。您可以使用OutEdgeDataView
获得图形边缘的列表,它为您提供一个元组列表,其中元组的第一项是源节点,第二项是目标节点。然后,要获取与e = list(G.edges())
对应的边的边属性,您可以说nodelist[0]
。
对于第二个错误,G.nodes()不是列表,并且不支持切片。当您在上方定义G.edge[nodelist[0],the_tail_node]
时,可以执行nodelist
,然后可以根据需要进行切片。