#NEWLINE# def draw_networkx_edges( G , pos , node_patches = None , edgelist = None , width = None , edge_color = None , style = 'solid' , alpha = None , edge_cmap = None , edge_vmin = None , edge_vmax = None , ax = None , arrows = True , arrow_style = None , connection_style = 'arc3' , color_weights = False , width_weights = False , **kwds ) : #NEWLINE# #INDENT# "Draw the edges of the graph G\n\n    This draws only the edges of the graph G.\n\n    Parameters\n    ----------\n    G : graph\n       A networkx graph\n\n    pos : dictionary\n       A dictionary with nodes as keys and positions as values.\n       If not specified a spring layout positioning will be computed.\n       See networkx.layout for functions that compute node positions.\n\n    ax : Matplotlib Axes object, optional\n       Draw the graph in the specified Matplotlib axes.\n\n    alpha: float\n       The edge transparency (default=1.0)\n\n    width`: float\n       Line width of edges (default =1.0)\n\n    edge_color: color string, or array of floats\n       Edge color. Can be a single color format string (default='r'),\n       or a sequence of colors with the same length as edgelist.\n       If numeric values are specified they will be mapped to\n       colors using the edge_cmap and edge_vmin,edge_vmax parameters.\n\n    edge_ cmap: Matplotlib colormap\n       Colormap for mapping intensities of edges (default=None)\n\n    edge_vmin,edge_vmax: floats\n       Minimum and maximum for edge colormap scaling (default=None)\n\n    style: string\n       Edge line style (default='solid') (solid|dashed|dotted,dashdot)\n    arrow: Bool\n       Whether to draw arrows or not for directed graphs\n    arrow_style: string\n       Arrow style used by matplotlib see FancyArrowPatch\n    connection_style: string\n       Connection style used by matplotlib, see FancyArrowPatch\n    color_weights: Bool\n       Whether to color the edges of a graph by their weight if the\n       graph has any.\n    width_weights: Bool\n       Whether to vary the thicknes of an edge by their weight, if the\n       graph has any.\n\n    Examples\n    --------\n    >>> G=nx.dodecahedral_graph()\n    >>> edges=nx.draw_networkx_edges(G,pos=nx.spring_layout(G))\n\n    Also see the NetworkX drawing examples at\n    http://networkx.lanl.gov/gallery.html\n\n    See Also\n    --------\n    draw()\n    draw_networkx()\n    draw_networkx_nodes()\n    draw_networkx_labels()\n    draw_networkx_edge_labels()\n\n    " #NEWLINE# try : #NEWLINE# #INDENT# import matplotlib #NEWLINE# import matplotlib.pylab as pylab #NEWLINE# import matplotlib.cbook as cb #NEWLINE# from matplotlib.colors import colorConverter , Colormap #NEWLINE# from matplotlib.collections import LineCollection #NEWLINE# import numpy #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# raise ImportError ( 'Matplotlib required for draw()' ) #NEWLINE# #UNINDENT# except RuntimeError : #NEWLINE# #INDENT# print ( 'Matplotlib unable to open display' ) #NEWLINE# raise #NEWLINE# #UNINDENT# if ( ax is None ) : #NEWLINE# #INDENT# ax = pylab . gca ( ) #NEWLINE# #UNINDENT# if ( edgelist is None ) : #NEWLINE# #INDENT# edgelist = G . edges ( ) #NEWLINE# #UNINDENT# if ( ( not edgelist ) or ( len ( edgelist ) == 0 ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# edge_pos = numpy . asarray ( [ ( pos [ e [ 0 ] ] , pos [ e [ 1 ] ] ) for e in edgelist ] ) #NEWLINE# if ( ( width is None ) and width_weights and is_weighted ( G ) ) : #NEWLINE# #INDENT# lw = edge_width_weight ( G , edgelist ) #NEWLINE# if ( alpha is None ) : #NEWLINE# #INDENT# alpha = 0.75 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( width is None ) : #NEWLINE# #INDENT# lw = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } . fromkeys ( maxx , 1.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if cb . iterable ( width ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# lwvals = list ( width . values ( ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# lwvals = width #NEWLINE# #UNINDENT# lw = dict ( list ( zip ( edgelist , lwvals ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if cb . is_scalar ( width ) : #NEWLINE# #INDENT# lw = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } . fromkeys ( edgelist , width ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise nx . NetworkXError ( 'Must provide a single scalar value or a list                                 of values for line width or None' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( edge_cmap is None ) : #NEWLINE# #INDENT# edge_cmap = cm . get_cmap ( mpl . rcParams [ 'image.cmap' ] ) #NEWLINE# #UNINDENT# if ( ( edge_color is None ) and color_weights and is_weighted ( G ) ) : #NEWLINE# #INDENT# edge_color = edge_color_weight ( G , edgelist ) #NEWLINE# if ( alpha is None ) : #NEWLINE# #INDENT# alpha = 0.75 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( edge_color is None ) : #NEWLINE# #INDENT# edge_color = 'k' #NEWLINE# #UNINDENT# #UNINDENT# e_colors = get_color_dict ( edge_color , edgelist , edge_vmin , edge_vmax , edge_cmap ) #NEWLINE# edge_patches = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( arrow_style is None ) : #NEWLINE# #INDENT# if G . is_directed ( ) : #NEWLINE# #INDENT# arrow_style = '-|>' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arrow_style = '-' #NEWLINE# #UNINDENT# #UNINDENT# if ( node_patches is None ) : #NEWLINE# #INDENT# node_patches = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } . fromkeys ( G . nodes ( ) , None ) #NEWLINE# #UNINDENT# for ( u , v ) in edgelist : #NEWLINE# #INDENT# edge_patches [ ( u , v ) ] = patches . FancyArrowPatch ( posA = pos [ u ] , posB = pos [ v ] , arrowstyle = arrow_style , connectionstyle = connection_style , patchA = node_patches [ u ] , patchB = node_patches [ v ] , shrinkA = 0.0 , shrinkB = 0.0 , mutation_scale = 20.0 , alpha = alpha , color = e_colors [ ( u , v ) ] , lw = lw [ ( u , v ) ] , linestyle = style , zorder = 1 ) #NEWLINE# ax . add_patch ( edge_patches [ ( u , v ) ] ) #NEWLINE# #UNINDENT# minx = numpy . amin ( numpy . ravel ( edge_pos [ : , : , 0 ] ) ) #NEWLINE# maxx = numpy . amax ( numpy . ravel ( edge_pos [ : , : , 0 ] ) ) #NEWLINE# miny = numpy . amin ( numpy . ravel ( edge_pos [ : , : , 1 ] ) ) #NEWLINE# maxy = numpy . amax ( numpy . ravel ( edge_pos [ : , : , 1 ] ) ) #NEWLINE# w = ( maxx - minx ) #NEWLINE# h = ( maxy - miny ) #NEWLINE# ( padx , pady ) = ( ( 0.05 * w ) , ( 0.05 * h ) ) #NEWLINE# corners = ( ( ( minx - padx ) , ( miny - pady ) ) , ( ( maxx + padx ) , ( maxy + pady ) ) ) #NEWLINE# ax . update_datalim ( corners ) #NEWLINE# ax . autoscale_view ( ) #NEWLINE# return edge_patches