To print a graph in Networkx, you can use one of the several methods provided by the matplotlib
library. Below is an example code snippet to print a graph:
main.py199 chars12 lines
Here, nx.draw
is used to plot the graph G
. The with_labels=True
option is used to print the node labels. Finally, plt.show()
is used to display the graph. You can customize the graph plot with various other options provided by matplotlib
.
gistlibby LogSnag