简体   繁体   中英

draw edges with networkx in python

I have a graph with float coordinate position(ex: (1.3, 2.75)) and draw my graph with nodes and some special edges. and G.edges is type of networkx.classes.reportviews.EdgeView, for example:

print(G.edges)

=>(((29.637096774193548, 61.74242424242425), (52.822580645161295, 35.76839826839827)),(...),...) and my code is:

nx.draw_networkx_edges(G, pos, edgelist=G.edges())

that

KeyError:(29.637096774193548, 61.74242424242425)

it solved. the edges add with its keys in dictoinary (pos) and i add ((x1,y1),(x2,y2)) to edges. i change my code and add(0,1) to edges that 0 assign to (x1,y1) and 1 assign to (x2,y2) in nodelist or pos.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM