from_edgelist

from_edgelist(edgelist, create_using=None)[source]

Returns a graph from a list of edges.

Parameters
edgelistlist or iterator

Edge tuples

create_usingNetworkX graph constructor, optional (default=nx.Graph)

Graph type to create. If graph instance, then cleared before populated.

Examples

>>> edgelist = [(0, 1)]  # single edge (0,1)
>>> G = nx.from_edgelist(edgelist)

or

>>> G = nx.Graph(edgelist)  # use Graph constructor