test of graph plotting

430 days ago by jason3

import matplotlib.pyplot as plt import networkx as nx plt.clf() G=nx.balanced_tree(2,1) pos=nx.spring_layout(G) # positions for all nodes # Full graph nx.draw_networkx_edges(G,pos) nx.draw_networkx_nodes(G,pos) V=G.nodes() # these are simple steps L1=V[:2] L2=V[2:] # nodes color nx.draw_networkx_nodes(G,pos,nodelist=L1,node_color='g') nx.draw_networkx_nodes(G,pos,nodelist=L2,node_color='b') #My qstn is How to plot it in sage plt.savefig("labels_and_colors.png")