NetworkX

Previous topic

networkx.convert.to_edgelist

Next topic

networkx.convert.to_numpy_matrix

networkx.convert.from_edgelist

from_edgelist(edgelist, create_using=None)

Return a graph from a list of edges.

Parameters:

edgelist : list or iterator

Edge tuples

create_using : NetworkX graph

Use specified graph for result. Otherwise a new graph is created.

Examples

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

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