To draw a graph with edges in NetworkX, you can use the networkx.draw() function. Here's an example:
main.py507 chars23 lines
In this example, we first create a directed graph G and then add edges to it. We then specify the position of each node using the spring_layout() function, and use nx.draw() to draw the graph with labels and a bold font. Finally, we use nx.get_edge_attributes() to get the weight of each edge, and nx.draw_networkx_edge_labels() to draw the edge labels.
Note that this example uses Matplotlib to actually show the graph. You may need to install it separately, if you haven't already.
gistlibby LogSnag