draw_networkx_edges(G, pos, edgelist=None, width=1.0, edge_color='k', style='solid', alpha=None, arrowstyle=None, arrowsize=10, edge_cmap=None, edge_vmin=None, edge_vmax=None, ax=None, arrows=True, label=None, node_size=300, nodelist=None, node_shape='o', connectionstyle='arc3', min_source_margin=0, min_target_margin=0)[source]

Draw the edges of the graph G.

This draws only the edges of the graph G.


A networkx graph


A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

edgelistcollection of edge tuples (default=G.edges())

Draw only specified edges

widthfloat or array of floats (default=1.0)

Line width of edges

edge_colorcolor or array of colors (default=’k’)

Edge color. Can be a single color or a sequence of colors with the same length as edgelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the edge_cmap and edge_vmin,edge_vmax parameters.

stylestring (default=solid line)

Edge line style e.g.: ‘-‘, ‘–’, ‘-.’, ‘:’ or words like ‘solid’ or ‘dashed’. (See matplotlib.patches.FancyArrowPatch: linestyle)

alphafloat or None (default=None)

The edge transparency

edge_cmapMatplotlib colormap, optional

Colormap for mapping intensities of edges

edge_vmin,edge_vmaxfloats, optional

Minimum and maximum for edge colormap scaling

axMatplotlib Axes object, optional

Draw the graph in the specified Matplotlib axes.

arrowsbool, optional (default=True)

For directed graphs, if True set default to drawing arrowheads. Otherwise set default to no arrowheads. Ignored if arrowstyle is set.

Note: Arrows will be the same color as edges.

arrowstylestr (default=’-|>’ if directed else ‘-‘)

For directed graphs and arrows==True defaults to ‘-|>’, otherwise defaults to ‘-‘.

See matplotlib.patches.ArrowStyle for more options.

arrowsizeint (default=10)

For directed graphs, choose the size of the arrow head’s length and width. See matplotlib.patches.FancyArrowPatch for attribute mutation_scale for more info.

connectionstylestring (default=”arc3”)

Pass the connectionstyle parameter to create curved arc of rounding radius rad. For example, connectionstyle=’arc3,rad=0.2’. See matplotlib.patches.ConnectionStyle and matplotlib.patches.FancyArrowPatch for more info.

node_sizescalar or array (default=300)

Size of nodes. Though the nodes are not drawn with this function, the node size is used in determining edge positioning.

nodelistlist, optional (default=G.nodes())

This provides the node order for the node_size array (if it is an array).

node_shapestring (default=’o’)

The marker used for nodes, used in determining edge positioning. Specification is as a matplotlib.markers marker, e.g. one of ‘so^>v<dph8’.

labelNone or string

Label for legend

min_source_marginint (default=0)

The minimum margin (gap) at the begining of the edge at the source.

min_target_marginint (default=0)

The minimum margin (gap) at the end of the edge at the target.

list of matplotlib.patches.FancyArrowPatch

FancyArrowPatch instances of the directed edges


For directed graphs, arrows are drawn at the head end. Arrows can be turned off with keyword arrows=False or by passing an arrowstyle without an arrow on the end.

Be sure to include node_size as a keyword argument; arrows are drawn considering the size of nodes.


>>> G = nx.dodecahedral_graph()
>>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> G = nx.DiGraph()
>>> G.add_edges_from([(1, 2), (1, 3), (2, 3)])
>>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
>>> alphas = [0.3, 0.4, 0.5]
>>> for i, arc in enumerate(arcs):  # change alpha values of arcs
...     arc.set_alpha(alphas[i])

Also see the NetworkX drawing examples at