我正试图画一个网络图。我的代码非常简单。对于小案例研究,此代码运行良好。但对于具有更多顶点和圆弧的更大样本,我得到G不是平面误差。这个错误的原因是什么
D:\Anaconda3\lib\site-packages\networkx\drawing\layout.py in planar_layout(G, scale, center, dim) 945 is_planar, embedding = nx.check_planarity(G) 946 if not is_planar: --> 947 raise nx.NetworkXException("G is not planar.") 948 pos = nx.combinatorial_embedding_to_pos(embedding) 949 node_list = list(embedding)
NetworkXException:G不是平面
def createAttackGraphNonPlanar(pos):
G=nx.DiGraph(directed=True)
G.add_nodes_from([nodes_map[n] for n in nodes])
print(G.nodes())
G.add_edges_from([ (nodes_map[e[0]],nodes_map[e[1]]) for e in arcs])
nx.draw_planar(G, pos=pos, node_size=30, node_color='red', with_labels = True)
函数draw_planar用于从documentation中绘制planar graph
并非所有的图都是平面图
要绘制任何图形,请使用draw,例如(仅用于演示):
有关绘制图形的更多信息,请参见此link
相关问题 更多 >
编程相关推荐