![](/img/trans.png)
[英]inheriting networkx Graph and using nx.connected_component_subgraphs
[英]after networkx library update nx.connected_component_subgraphs(G), this error genarated
gen=(G1.subgraph(c) for c in nx.connected_components(G1))
G1_LCC=max((G1.subgraph(c) for c in nx.connected_components(G1)),key=len)
G2_LCC=max((G2.subgraph(c) for c in nx.connected_components(G2)),key=len)
plt.figure()
nx.draw(G1_LCC,node_color="red",edge_color="grey",node_size="20")
plt.savefig("vill1.pdf")
它出什么問題了? 這是顯示錯誤。
TypeError: ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
您會收到TypeError
,因為node_size
應該是標量或數組,但您傳遞的是字符串( docs )。
將節點大小的值更改為標量將解決該問題。
nx.draw(G1_LCC, node_color="red", edge_color="grey", node_size=20)
是的,“大小”值不是字符串。 嘗試使用 int 或 float。
nx.draw(G1_LCC, node_color="red", edge_color="grey", node_size=20)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.