def draw_networkx(G, pos=None, arrows=True, with_labels=True, **kwds):
 try:
  import matplotlib.pyplot as plt
 except ImportError:
  raise ImportError('Matplotlib required for draw()')
 except RuntimeError:
  print 'Matplotlib unable to open display'
  raise
 if (pos is None):
  pos = nx.drawing.spring_layout(G)
 node_collection = draw_networkx_nodes(G, pos, **kwds)
 edge_collection = draw_networkx_edges(G, pos, arrows=arrows, **kwds)
 if with_labels:
  draw_networkx_labels(G, pos, **kwds)
 plt.draw_if_interactive()

def draw_networkx ( G , pos = None , arrows = True , with_labels = True , ** kwds ) : try : import matplotlib . pyplot as plt except ImportError : raise ImportError ( 'Matplotlib required for draw()' ) except RuntimeError : print 'Matplotlib unable to open display' raise if ( pos is None ) : pos = nx . drawing . spring_layout ( G ) node_collection = draw_networkx_nodes ( G , pos , ** kwds ) edge_collection = draw_networkx_edges ( G , pos , arrows = arrows , ** kwds ) if with_labels : draw_networkx_labels ( G , pos , ** kwds ) plt . draw_if_interactive ( )
draw the graph g using matplotlib .